summaryrefslogtreecommitdiff
path: root/ishtar_common/data_importer.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/data_importer.py')
-rw-r--r--ishtar_common/data_importer.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py
index 43c07873e..95763ae09 100644
--- a/ishtar_common/data_importer.py
+++ b/ishtar_common/data_importer.py
@@ -61,11 +61,11 @@ def pre_importer_action(func):
class ImportFormater(object):
def __init__(self, field_name, formater=None, required=True, through=None,
through_key=None, through_dict=None,
- through_unicity_keys=None, duplicate_fields=[], regexp=None,
- regexp_formater_args=[], force_value=None,
+ through_unicity_keys=None, duplicate_fields=None, regexp=None,
+ regexp_formater_args=None, force_value=None,
post_processing=False, concat=False, concat_str=False,
comment="", force_new=None, export_field_name=None,
- label=""):
+ value_format=None, label=""):
self.field_name = field_name
if export_field_name:
self.export_field_name = export_field_name
@@ -77,9 +77,10 @@ class ImportFormater(object):
self.through_key = through_key
self.through_dict = through_dict
self.through_unicity_keys = through_unicity_keys
- self.duplicate_fields = duplicate_fields
+ self.duplicate_fields = duplicate_fields or []
self.regexp = regexp
- self.regexp_formater_args = regexp_formater_args
+ self.value_format = value_format
+ self.regexp_formater_args = regexp_formater_args or []
# write this value even if a value exists
self.force_value = force_value
# post process after import
@@ -1312,7 +1313,6 @@ class Importer(object):
self.DB_TARGETS["{}-{}".format(idx_col + 1, field_name)],
idx_v)
for idx, v in enumerate(values):
- value = None
try:
if formater.regexp_formater_args:
args = []
@@ -1330,6 +1330,8 @@ class Importer(object):
self.errors.append((idx_line + 1, idx_col + 1, e.message))
c_values.append('')
return
+ if formater.value_format and value is not None and value != "":
+ value = formater.value_format.format(value)
formated_values.append(value)
if hasattr(func, 'match_table'):
if field_name not in self.match_table: