datamule 2.0.7__py3-none-any.whl → 2.0.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- datamule/datamule/datamule_mysql_rds.py +2 -0
- datamule/document/document.py +2 -2
- datamule/document/tables/tables.py +10 -9
- {datamule-2.0.7.dist-info → datamule-2.0.9.dist-info}/METADATA +1 -1
- {datamule-2.0.7.dist-info → datamule-2.0.9.dist-info}/RECORD +7 -7
- {datamule-2.0.7.dist-info → datamule-2.0.9.dist-info}/WHEEL +0 -0
- {datamule-2.0.7.dist-info → datamule-2.0.9.dist-info}/top_level.txt +0 -0
datamule/document/document.py
CHANGED
@@ -231,13 +231,13 @@ class Document:
|
|
231
231
|
with open(output_filename, 'w',encoding='utf-8') as f:
|
232
232
|
json.dump(self.data, f, indent=2)
|
233
233
|
|
234
|
-
def parse_tables(self):
|
234
|
+
def parse_tables(self,must_exist_in_mapping=True):
|
235
235
|
if self.extension != '.xml':
|
236
236
|
self._tables = []
|
237
237
|
else:
|
238
238
|
# Use the property to trigger parsing if needed
|
239
239
|
data = self.data
|
240
|
-
tables = Tables(document_type = self.type, accession=self.accession, data=data)
|
240
|
+
tables = Tables(document_type = self.type, accession=self.accession, data=data,must_exist_in_mapping=must_exist_in_mapping)
|
241
241
|
self._tables = tables.tables
|
242
242
|
|
243
243
|
@property
|
@@ -64,14 +64,14 @@ def seperate_data(tables_dict, data):
|
|
64
64
|
|
65
65
|
return data_list
|
66
66
|
|
67
|
-
def apply_mapping(flattened_data, mapping_dict, accession):
|
67
|
+
def apply_mapping(flattened_data, mapping_dict, accession, must_exist_in_mapping=False):
|
68
68
|
"""Apply mapping to flattened data and add accession"""
|
69
69
|
|
70
70
|
# Handle case where flattened_data is a list of dictionaries
|
71
71
|
if isinstance(flattened_data, list):
|
72
72
|
results = []
|
73
73
|
for data_dict in flattened_data:
|
74
|
-
results.
|
74
|
+
results.extend(apply_mapping(data_dict, mapping_dict, accession,must_exist_in_mapping))
|
75
75
|
return results
|
76
76
|
|
77
77
|
# Original logic for single dictionary
|
@@ -85,10 +85,11 @@ def apply_mapping(flattened_data, mapping_dict, accession):
|
|
85
85
|
ordered_row[new_key] = None
|
86
86
|
|
87
87
|
# Add any remaining keys that weren't in the mapping
|
88
|
-
|
89
|
-
|
88
|
+
if not must_exist_in_mapping:
|
89
|
+
for key, value in flattened_data.items():
|
90
|
+
ordered_row[key] = value
|
90
91
|
|
91
|
-
return ordered_row
|
92
|
+
return [ordered_row]
|
92
93
|
|
93
94
|
# should have table type, accession, data
|
94
95
|
class Table:
|
@@ -99,7 +100,7 @@ class Table:
|
|
99
100
|
|
100
101
|
|
101
102
|
class Tables():
|
102
|
-
def __init__(self,document_type,accession,data):
|
103
|
+
def __init__(self,document_type,accession,data,must_exist_in_mapping=True):
|
103
104
|
self.document_type = document_type
|
104
105
|
self.accession = accession
|
105
106
|
self.data = data
|
@@ -107,9 +108,9 @@ class Tables():
|
|
107
108
|
# to fill in
|
108
109
|
self.tables = []
|
109
110
|
|
110
|
-
self.parse_tables()
|
111
|
+
self.parse_tables(must_exist_in_mapping=must_exist_in_mapping)
|
111
112
|
|
112
|
-
def parse_tables(self):
|
113
|
+
def parse_tables(self,must_exist_in_mapping=True):
|
113
114
|
# first select dict
|
114
115
|
|
115
116
|
try:
|
@@ -125,5 +126,5 @@ class Tables():
|
|
125
126
|
|
126
127
|
for table_name, flattened_data in data_dicts:
|
127
128
|
mapping_dict = tables_dict[table_name]['mapping']
|
128
|
-
mapped_data = apply_mapping(flattened_data, mapping_dict, self.accession)
|
129
|
+
mapped_data = apply_mapping(flattened_data, mapping_dict, self.accession,must_exist_in_mapping)
|
129
130
|
self.tables.append(Table(mapped_data, table_name, self.accession))
|
@@ -10,13 +10,13 @@ datamule/submission.py,sha256=7rtN3EEB50iU7E-B_i-e0JHY382EIgmDcrS1KRZ1mUc,15886
|
|
10
10
|
datamule/data/listed_filer_metadata.csv,sha256=dT9fQ8AC5P1-Udf_UF0ZkdXJ88jNxJb_tuhi5YYL1rc,2426827
|
11
11
|
datamule/datamule/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
datamule/datamule/datamule_lookup.py,sha256=e8djAg-ctSyHiKk7BjbtgugZ3p8roUjzsym5z3AihUg,9468
|
13
|
-
datamule/datamule/datamule_mysql_rds.py,sha256=
|
13
|
+
datamule/datamule/datamule_mysql_rds.py,sha256=Mw3o21p7ZBPvL4vhRot4cAlM8Hf2FDAjuBjTp5WzpHU,11935
|
14
14
|
datamule/datamule/downloader.py,sha256=aTyVUuIwynPtHB0Z9BvCasy9Ao5wfHptNAsjN-7yDTk,18525
|
15
15
|
datamule/datamule/sec_connector.py,sha256=VwOaODpHoAWy8JIky6kLR1-orW_PB61RHw7pIGRpkow,3288
|
16
16
|
datamule/document/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
|
-
datamule/document/document.py,sha256=
|
17
|
+
datamule/document/document.py,sha256=OtfIvHRxdIXmNq5lOpBiLQw9P4o9OYScdpJxNEX51Yc,14477
|
18
18
|
datamule/document/tables/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
|
-
datamule/document/tables/tables.py,sha256=
|
19
|
+
datamule/document/tables/tables.py,sha256=8riSAof6o-Gxoo0SkiQAE61fw8NmzDnEhJe6dATzmvA,4487
|
20
20
|
datamule/document/tables/tables_13fhr.py,sha256=-6tWcaTyNsb0XuW0WMBrYir9Zn1wLZL0laKxRYfPNyg,4265
|
21
21
|
datamule/document/tables/tables_25nse.py,sha256=kpoOcIpra6i3Wx_6pUCj1fkx0wUbMhx7pc8yUkrBJb4,980
|
22
22
|
datamule/document/tables/tables_informationtable.py,sha256=L7qSNTiyr45iIa8z4gm7pKw_meHjIqMFc1SF5Y6XAGg,1658
|
@@ -50,7 +50,7 @@ datamule/seclibrary/bq.py,sha256=C8sb_rpXTvchprrFLcbRar4Qi0XWW25tnv1YsHSS5o4,180
|
|
50
50
|
datamule/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
51
51
|
datamule/utils/construct_submissions_data.py,sha256=NB_hvfxlRXPyt4Fgc-5qA8vJRItkLhBedCSTaxwW7Jg,5887
|
52
52
|
datamule/utils/format_accession.py,sha256=60RtqoNqoT9zSKVb1DeOv1gncJxzPTFMNW4SNOVmC_g,476
|
53
|
-
datamule-2.0.
|
54
|
-
datamule-2.0.
|
55
|
-
datamule-2.0.
|
56
|
-
datamule-2.0.
|
53
|
+
datamule-2.0.9.dist-info/METADATA,sha256=HPPYbuYA54lDhy82ZrZ8io3OsQNh-ZJRGfMUKO8V0cQ,560
|
54
|
+
datamule-2.0.9.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
55
|
+
datamule-2.0.9.dist-info/top_level.txt,sha256=iOfgmtSMFVyr7JGl_bYSTDry79JbmsG4p8zKq89ktKk,9
|
56
|
+
datamule-2.0.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|