|
@@ -101,12 +101,38 @@ class ParseMapping:
|
|
|
def get_internal_names(self) -> dict:
|
|
|
'''
|
|
|
'''
|
|
|
- return self._get_info(key="internal_name")
|
|
|
+
|
|
|
+ if all(["internal_name" in d for d in self._mapping]):
|
|
|
+ internal_names = [d["internal_name"] for d in self._mapping]
|
|
|
+
|
|
|
+ elif all(["internal_name" not in d for d in self._mapping]):
|
|
|
+ internal_names = list(range(len(self._mapping)))
|
|
|
+
|
|
|
+
|
|
|
+ else:
|
|
|
+ err = ("Incorrectly filled mapping. Internal names should "
|
|
|
+ "either be in all or in neither of the fields")
|
|
|
+ self._log.error(err)
|
|
|
+ raise Exception(err)
|
|
|
+
|
|
|
+ return internal_names
|
|
|
|
|
|
def get_mongo_names(self) -> dict:
|
|
|
'''
|
|
|
'''
|
|
|
- return self._get_info(key="mongo_name")
|
|
|
+ if all(["mongo_name" in d for d in self._mapping]):
|
|
|
+ mongo_names = [d["mongo_name"] for d in self._mapping]
|
|
|
+
|
|
|
+ elif all(["mongo_name" not in d for d in self._mapping]):
|
|
|
+ mongo_names = list(range(len(self._mapping)))
|
|
|
+
|
|
|
+ else:
|
|
|
+ err = ("Incorrectly filled mapping. Mongo names should "
|
|
|
+ "either be in all or in neither of the fields")
|
|
|
+ self._log.error(err)
|
|
|
+ raise Exception(err)
|
|
|
+
|
|
|
+ return mongo_names
|
|
|
|
|
|
def get_types(self) -> dict:
|
|
|
'''
|
|
@@ -144,7 +170,7 @@ class ParseMapping:
|
|
|
else:
|
|
|
err = ("Incorrectly filled mapping. Column numbers should ",
|
|
|
"either in all or in neither of the fields")
|
|
|
- self.log.err(err)
|
|
|
+ self._log.err(err)
|
|
|
raise Exception(err)
|
|
|
|
|
|
return column_numbers
|