More documentation

This commit is contained in:
Antonio de la Rosa 2021-06-01 11:50:24 +02:00
parent c96ed2e491
commit d88139030b
2 changed files with 38 additions and 6 deletions

View file

@ -2,7 +2,10 @@ import time
from datetime import date, datetime, tzinfo
import arrow
# from babel.dates import format_date, format_datetime, format_time, get_timezone, UTC
from settings import config
try:
from settings import config
except:
config={}
#from paramecio.citoplasma.sessions import get_session
from os import environ
@ -147,7 +150,7 @@ def now(utc=False, tz=''):
Args:
utc (bool): If True, the datetime is returned in UTC timezone
tz (str): Timezone name, example: Europe/Madrid. If set the datetime is returned in the timezone selected
tz (str, optional): Timezone name, example: Europe/Madrid. If set the datetime is returned in the timezone selected
Returns:
str: Return actual datetime
@ -174,7 +177,7 @@ def today(utc=False,tz=''):
Args:
utc (bool): If True, the date is returned in UTC timezone
tz (str): Timezone name, example: Europe/Madrid. If set the date is returned in the timezone selected
tz (str, optional): Timezone name, example: Europe/Madrid. If set the date is returned in the timezone selected
Returns:
str: Return actual date with 00:00:00 how time
@ -235,7 +238,7 @@ def timestamp_to_datetime_local(timestamp, tz=''):
Args:
timestamp (int): The timestamp for convert in datetime
tz (str): If you want convert to other timezone, set it.
tz (str, optional): If you want convert to other timezone, set it.
Returns:
@ -287,7 +290,7 @@ def local_to_gmt(timeform, sql_format_time=sql_format_time):
Args:
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
sql_format_time (str): by default, the format is YYYYMMDDHHmmss, you can put other formatted str formats for date, here.
sql_format_time (str, optional): by default, the format is YYYYMMDDHHmmss, you can put other formatted str formats for date, here.
Returns:
If timeform is False, return False, if timeform is valid, return the datetime formatted
@ -306,7 +309,7 @@ def gmt_to_local(timeform, sql_format_time=sql_format_time):
Args:
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
sql_format_time (str): by default, the format is YYYYMMDDHHmmss, you can put other formatted str formats for date, here.
sql_format_time (str, optional): by default, the format is YYYYMMDDHHmmss, you can put other formatted str formats for date, here.
Returns:
If timeform is False, return False, if timeform is valid, return the datetime formatted

View file

@ -7,8 +7,23 @@ from flask import session
from paramecio2.libraries.keyutils import create_key_encrypt
# Need unittest
"""Functions and classes for process forms"""
def pass_values_to_form(post, arr_form, yes_error=True, pass_values=True):
"""Function for pass a dict with form values for check using forms dict
Values dict and Forms dict need have the same key. A forms dict is maked of a serie of paramecio2 forms elements, used for check the value.
Args:
post (dict): Dict composed by a series of values. The keys need to be equal to keys of arr_form dict.
arr_form (dict): Dict composed by a series or forms objects. The keys need to be equal to keys of post dict.
yes_error (bool): Show errors in txt_error form variables.
pass_values (bool): Pass default values or values from post dict to arr_form dict items
Returns:
dict: Return arr_form dict with checked values from post dict.
"""
if pass_values:
def get_value(key):
@ -44,12 +59,26 @@ def pass_values_to_form(post, arr_form, yes_error=True, pass_values=True):
return arr_form
class CheckForm():
"""Simple class for make similar check to pass_values_to_form. More simple.
"""
def __init__(self):
self.error=0
def check(self, post, arr_form):
"""Simple method for pass a dict with form values for check using forms dict
Values dict and Forms dict need have the same key. A forms dict is maked of a serie of paramecio2 forms elements, used for check the value.
Args:
post (dict): Dict composed by a series of values. The keys need to be equal to keys of arr_form dict.
arr_form (dict): Dict composed by a series or forms objects. The keys need to be equal to keys of post dict.
Returns:
dict: Return arr_form dict with checked values from post dict.
"""
for k in arr_form.keys():