diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-06-23 11:08:02 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-06-23 11:08:02 +0200 |
commit | c2c4442d49ded35ad81d9cbf4487aaa30973cc7b (patch) | |
tree | 0b63e1fd185fd9fb9df915a1406fb69c5a85a19c /ishtar_common | |
parent | 00c2577c6b2d7891e4688fa95c580d0a9c596c82 (diff) | |
download | Ishtar-c2c4442d49ded35ad81d9cbf4487aaa30973cc7b.tar.bz2 Ishtar-c2c4442d49ded35ad81d9cbf4487aaa30973cc7b.zip |
Import: upper/lower case formaters
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/data_importer.py | 24 | ||||
-rw-r--r-- | ishtar_common/models_imports.py | 6 |
2 files changed, 29 insertions, 1 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index b777850c9..ea3054110 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -337,6 +337,30 @@ class InseeFormater(Formater): return code + "-" + exp[1] +class UpperCaseFormater(UnicodeFormater): + """ + To upper case + """ + + def format(self, value): + value = super(UpperCaseFormater, self).format(value) + if not value: + return value + return value.upper() + + +class LowerCaseFormater(UnicodeFormater): + """ + To lower case + """ + + def format(self, value): + value = super(LowerCaseFormater, self).format(value) + if not value: + return value + return value.lower() + + class YearFormater(Formater): def format(self, value): value = value.strip() diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 5d522df27..a90e16373 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -54,7 +54,7 @@ from ishtar_common.utils import create_slug, \ from ishtar_common.data_importer import Importer, ImportFormater, \ IntegerFormater, FloatFormater, UnicodeFormater, DateFormater, \ TypeFormater, YearFormater, StrToBoolean, FileFormater, InseeFormater, \ - ImporterError + ImporterError, UpperCaseFormater, LowerCaseFormater from ishtar_common.utils import task @@ -790,6 +790,8 @@ IMPORTER_TYPES = ( ('TypeFormater', _("Type")), ('YearFormater', _("Year")), ('InseeFormater', _("INSEE code")), + ('UpperFormater', _("Upper case")), + ('LowerFormater', _("Lower case")), ('StrToBoolean', _("String to boolean")), ('FileFormater', pgettext_lazy("filesystem", "File")), ('UnknowType', _("Unknow type")) @@ -805,6 +807,8 @@ IMPORTER_TYPES_DCT = { 'StrToBoolean': StrToBoolean, 'FileFormater': FileFormater, 'InseeFormater': InseeFormater, + 'UpperFormater': UpperCaseFormater, + 'LowerFormater': LowerCaseFormater, 'UnknowType': None, } |