mirror of
https://github.com/yweber/lodel2.git
synced 2025-11-02 04:20:55 +01:00
Code cleaning on datahandlers/datas.py
This commit is contained in:
parent
822ad1bea2
commit
915817b6bd
1 changed files with 10 additions and 11 deletions
|
|
@ -7,9 +7,9 @@ from lodel.context import LodelContext
|
|||
|
||||
LodelContext.expose_modules(globals(), {
|
||||
'lodel.leapi.datahandlers.datas_base': ['Boolean', 'Integer', 'Varchar',
|
||||
'DateTime', 'Text', 'File'],
|
||||
'DateTime', 'Text', 'File'],
|
||||
'lodel.exceptions': ['LodelException', 'LodelExceptions',
|
||||
'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
|
||||
'LodelFatalError', 'DataNoneValid', 'FieldValidationError']})
|
||||
|
||||
|
||||
##@brief Data field designed to handle formated strings
|
||||
|
|
@ -26,7 +26,7 @@ build its content'
|
|||
def __init__(self, format_string, field_list, **kwargs):
|
||||
self._field_list = field_list
|
||||
self._format_string = format_string
|
||||
super().__init__(internal='automatic',**kwargs)
|
||||
super().__init__(internal='automatic', **kwargs)
|
||||
|
||||
def _construct_data(self, emcomponent, fname, datas, cur_value):
|
||||
ret = self._format_string % tuple(
|
||||
|
|
@ -49,7 +49,7 @@ max_length and regex'
|
|||
# @param **kwargs
|
||||
def __init__(self, regex='', max_length=10, **kwargs):
|
||||
self.regex = regex
|
||||
self.compiled_re = re.compile(regex)#trigger an error if invalid regex
|
||||
self.compiled_re = re.compile(regex) # trigger an error if invalid regex
|
||||
super(self.__class__, self).__init__(max_length=max_length, **kwargs)
|
||||
|
||||
##@brief Check and cast value in appropriate type
|
||||
|
|
@ -106,7 +106,8 @@ be internal")
|
|||
if not inspect.isclass(emcomponent):
|
||||
cls = emcomponent.__class__
|
||||
return cls.__name__
|
||||
|
||||
|
||||
|
||||
##@brief Data field designed to handle concatenated fields
|
||||
class Concat(FormatString):
|
||||
help = 'Automatic strings concatenation'
|
||||
|
|
@ -116,11 +117,11 @@ class Concat(FormatString):
|
|||
# @param field_list list : List of field to use
|
||||
# @param separator str
|
||||
# @param **kwargs
|
||||
def __init__(self, field_list, separator = ' ', **kwargs):
|
||||
def __init__(self, field_list, separator=' ', **kwargs):
|
||||
format_string = separator.join(['%s' for _ in field_list])
|
||||
super().__init__(
|
||||
format_string = format_string, field_list = field_list, **kwargs)
|
||||
|
||||
super().__init__(format_string=format_string,
|
||||
field_list=field_list,
|
||||
**kwargs)
|
||||
|
||||
|
||||
class Password(Varchar):
|
||||
|
|
@ -129,7 +130,6 @@ class Password(Varchar):
|
|||
pass
|
||||
|
||||
|
||||
|
||||
class VarcharList(Varchar):
|
||||
help = 'DataHandler designed to make a list out of a string.'
|
||||
base_type = 'varchar'
|
||||
|
|
@ -140,7 +140,6 @@ class VarcharList(Varchar):
|
|||
self.delimiter = str(delimiter)
|
||||
super().__init__(**kwargs)
|
||||
|
||||
|
||||
def construct_data(self, emcomponent, fname, datas, cur_value):
|
||||
result = cur_value.split(self.delimiter)
|
||||
return result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue