datamule 2.0.5__py3-none-any.whl → 2.0.7__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.
Files changed (34) hide show
  1. datamule/document/document.py +33 -18
  2. datamule/document/tables/tables.py +129 -0
  3. datamule/document/{mappings/thirteenfhr.py → tables/tables_13fhr.py} +8 -4
  4. datamule/document/{mappings/twentyfivense.py → tables/tables_25nse.py} +7 -2
  5. datamule/document/{mappings/information_table.py → tables/tables_informationtable.py} +7 -3
  6. datamule/document/{mappings/npx.py → tables/tables_npx.py} +7 -0
  7. datamule/document/{mappings/ownership.py → tables/tables_ownership.py} +37 -9
  8. datamule/document/{mappings/proxy_voting_record.py → tables/tables_proxyvotingrecord.py} +7 -0
  9. datamule/document/{mappings/sbsef.py → tables/tables_sbsef.py} +7 -0
  10. datamule/document/{mappings/sdr.py → tables/tables_sdr.py} +7 -0
  11. datamule/document/tables/utils.py +26 -0
  12. datamule/submission.py +50 -15
  13. {datamule-2.0.5.dist-info → datamule-2.0.7.dist-info}/METADATA +1 -1
  14. {datamule-2.0.5.dist-info → datamule-2.0.7.dist-info}/RECORD +17 -32
  15. datamule/document/mappings/atsn.py +0 -208
  16. datamule/document/mappings/cfportal.py +0 -346
  17. datamule/document/mappings/d.py +0 -125
  18. datamule/document/mappings/ex102_abs.py +0 -63
  19. datamule/document/mappings/ex99a_sdr.py +0 -1
  20. datamule/document/mappings/ex99c_sdr.py +0 -0
  21. datamule/document/mappings/ex99g_sdr.py +0 -0
  22. datamule/document/mappings/ex99i_sdr.py +0 -0
  23. datamule/document/mappings/nmfp.py +0 -275
  24. datamule/document/mappings/onefourtyfour.py +0 -68
  25. datamule/document/mappings/sbs.py +0 -0
  26. datamule/document/mappings/schedule13.py +0 -117
  27. datamule/document/mappings/submission_metadata.py +0 -9
  28. datamule/document/mappings/ta.py +0 -0
  29. datamule/document/mappings/twentyfourf2nt.py +0 -100
  30. datamule/document/processing.py +0 -732
  31. datamule/document/table.py +0 -315
  32. /datamule/document/{mappings → tables}/__init__.py +0 -0
  33. {datamule-2.0.5.dist-info → datamule-2.0.7.dist-info}/WHEEL +0 -0
  34. {datamule-2.0.5.dist-info → datamule-2.0.7.dist-info}/top_level.txt +0 -0
@@ -1,315 +0,0 @@
1
- from .mappings.atsn import *
2
- from .mappings.cfportal import *
3
- from .mappings.ex99a_sdr import *
4
- from .mappings.ex99c_sdr import *
5
- from .mappings.ex99g_sdr import *
6
- from .mappings.ex99i_sdr import *
7
- from .mappings.nmfp import *
8
- from .mappings.npx import *
9
- from .mappings.onefourtyfour import *
10
- from .mappings.ownership import *
11
- from .mappings.proxy_voting_record import *
12
- from .mappings.sbs import *
13
- from .mappings.sbsef import *
14
- from .mappings.schedule13 import *
15
- from .mappings.sdr import *
16
- from .mappings.ta import *
17
- from .mappings.thirteenfhr import *
18
- from .mappings.twentyfivense import *
19
- from .mappings.twentyfourf2nt import *
20
- from .mappings.information_table import *
21
- from .mappings.submission_metadata import *
22
- from .mappings.ex102_abs import *
23
- from .mappings.d import *
24
-
25
- from pathlib import Path
26
- import csv
27
- # need to check if mappings correctly create new columns
28
- class Table():
29
- def __init__(self, data, type,accession):
30
- if isinstance(data,dict):
31
- data = [data]
32
- self.type = type
33
- self.data = data
34
- self.accession = accession
35
- self.columns = self.determine_columns_complete()
36
-
37
- def determine_columns_complete(self):
38
- if not self.data:
39
- return []
40
- return list(set().union(*(row.keys() for row in self.data)))
41
-
42
-
43
- def determine_columns(self):
44
- if len(self.data) == 0:
45
- return []
46
-
47
- return self.data[0].keys()
48
-
49
- def add_column(self,column_name,value):
50
- for row in self.data:
51
- row[column_name] = value
52
-
53
- def map_data(self):
54
- # Add the accession column to all rows first, ensuring it will be first
55
- self.add_column('accession', self.accession)
56
-
57
-
58
- # ATS-N, types: metadata_ats,cover_ats,part_one_ats,part_two_ats,part_three_ats,part_four_ats
59
- if self.type == 'metadata_ats':
60
- mapping_dict = metadata_ats_dict
61
- elif self.type == 'cover_ats':
62
- mapping_dict = cover_ats_dict
63
- elif self.type == 'part_one_ats':
64
- mapping_dict = part_one_ats_dict
65
- elif self.type == 'part_two_ats':
66
- mapping_dict = part_two_ats_dict
67
- elif self.type == 'part_three_ats':
68
- mapping_dict = part_three_ats_dict
69
- elif self.type == 'part_four_ats':
70
- mapping_dict = part_four_ats_dict
71
- # CFPORTAL
72
- elif self.type == 'metadata_cfportal':
73
- mapping_dict = metadata_cfportal_dict
74
- elif self.type == 'identifying_information_cfportal':
75
- mapping_dict = identifying_information_cfportal_dict
76
- elif self.type == 'form_of_organization_cfportal':
77
- mapping_dict = form_of_organization_cfportal_dict
78
- elif self.type == 'successions_cfportal':
79
- mapping_dict = successions_cfportal_dict
80
- elif self.type == 'control_relationships_cfportal':
81
- mapping_dict = control_relationships_cfportal_dict
82
- elif self.type == 'disclosure_answers_cfportal':
83
- mapping_dict = disclosure_answers_cfportal_dict
84
- elif self.type == 'non_securities_related_business_cfportal':
85
- mapping_dict = non_securities_related_business_cfportal_dict
86
- elif self.type == 'escrow_arrangements_cfportal':
87
- mapping_dict = escrow_arrangements_cfportal_dict
88
- elif self.type == 'execution_cfportal':
89
- mapping_dict = execution_cfportal_dict
90
- elif self.type == 'schedule_a_cfportal':
91
- mapping_dict = schedule_a_cfportal_dict
92
- elif self.type == 'schedule_b_cfportal':
93
- mapping_dict = schedule_b_cfportal_dict
94
- elif self.type == 'schedule_c_cfportal':
95
- mapping_dict = schedule_c_cfportal_dict
96
- elif self.type == 'schedule_d_cfportal':
97
- mapping_dict = schedule_d_cfportal_dict
98
- elif self.type == 'criminal_drip_info_cfportal':
99
- mapping_dict = criminal_drip_info_cfportal_dict
100
- elif self.type == 'regulatory_drip_info_cfportal':
101
- mapping_dict = regulatory_drip_info_cfportal_dict
102
- elif self.type == 'civil_judicial_drip_info_cfportal':
103
- mapping_dict = civil_judicial_drip_info_cfportal_dict
104
- elif self.type == 'bankruptcy_sipc_drip_info_cfportal':
105
- mapping_dict = bankruptcy_sipc_drip_info_cfportal_dict
106
- elif self.type == 'bond_drip_info_cfportal':
107
- mapping_dict = bond_drip_info_cfportal_dict
108
- elif self.type == 'judgement_drip_info_cfportal':
109
- mapping_dict = judgement_drip_info_cfportal_dict
110
-
111
- # SDR
112
-
113
- # Information Table
114
- elif self.type == 'information_table':
115
- mapping_dict = information_table_dict
116
-
117
- # NFMP
118
- elif self.type == 'metadata_nmfp':
119
- mapping_dict = metadata_nmfp_dict
120
- elif self.type == 'general_information_nmfp':
121
- mapping_dict = general_information_nmfp_dict
122
- elif self.type == 'series_level_info_nmfp':
123
- mapping_dict = series_level_info_nmfp_dict
124
- elif self.type == 'class_level_info_nmfp':
125
- mapping_dict = class_level_info_nmfp_dict
126
- elif self.type == 'schedule_of_portfolio_securities_info_nmfp':
127
- mapping_dict = schedule_of_portfolio_securities_info_nmfp_dict
128
- elif self.type == 'signature_nmfp':
129
- mapping_dict = signature_nmfp_dict
130
-
131
- # NPX
132
- elif self.type == 'npx':
133
- mapping_dict = npx_dict
134
-
135
- # 144
136
- elif self.type == 'signatures_144':
137
- mapping_dict = signatures_144_dict
138
- elif self.type == 'securities_sold_in_past_3_months_144':
139
- mapping_dict = securities_sold_in_past_3_months_144_dict
140
- elif self.type == 'securities_to_be_sold_144':
141
- mapping_dict = securities_to_be_sold_144_dict
142
- elif self.type == 'securities_information_144':
143
- mapping_dict = securities_information_144_dict
144
- elif self.type == 'issuer_information_144':
145
- mapping_dict = issuer_information_144_dict
146
- elif self.type == 'metadata_144':
147
- mapping_dict = metadata_144_dict
148
-
149
- # Ownership
150
- elif self.type == 'non_derivative_holding_ownership':
151
- mapping_dict = non_derivative_holding_ownership_dict
152
- elif self.type == 'non_derivative_transaction_ownership':
153
- mapping_dict = non_derivative_transaction_ownership_dict
154
- elif self.type == 'derivative_transaction_ownership':
155
- mapping_dict = derivative_transaction_ownership_dict
156
- elif self.type == 'derivative_holding_ownership':
157
- mapping_dict = derivative_holding_ownership_dict
158
- elif self.type == 'reporting_owner_ownership':
159
- mapping_dict = reporting_owner_ownership_dict
160
- elif self.type == 'metadata_ownership':
161
- mapping_dict = metadata_ownership_dict
162
- elif self.type == 'owner_signature_ownership':
163
- mapping_dict = owner_signature_ownership_dict
164
-
165
- # Proxy Voting Record
166
- elif self.type == 'proxy_voting_record':
167
- mapping_dict = proxy_voting_record_dict
168
-
169
- # SBS
170
-
171
- # SBSEF
172
- elif self.type == 'sbsef':
173
- mapping_dict = sbsef_dict
174
-
175
- # Schedule 13
176
- elif self.type == 'metadata_schedule_13':
177
- mapping_dict = metadata_schedule_13_dict
178
- elif self.type == 'cover_schedule_13':
179
- mapping_dict = cover_schedule_13_dict
180
- elif self.type == 'reporting_person_details_schedule_13':
181
- mapping_dict = reporting_person_details_schedule_13_dict
182
- elif self.type == 'item_1_schedule_13':
183
- mapping_dict = item_1_schedule_13_dict
184
- elif self.type == 'item_2_schedule_13':
185
- mapping_dict = item_2_schedule_13_dict
186
- elif self.type == 'item_3_schedule_13':
187
- mapping_dict = item_3_schedule_13_dict
188
- elif self.type == 'item_4_schedule_13':
189
- mapping_dict = item_4_schedule_13_dict
190
- elif self.type == 'item_5_schedule_13':
191
- mapping_dict = item_5_schedule_13_dict
192
- elif self.type == 'item_6_schedule_13':
193
- mapping_dict = item_6_schedule_13_dict
194
- elif self.type == 'item_7_schedule_13':
195
- mapping_dict = item_7_schedule_13_dict
196
- elif self.type == 'item_8_schedule_13':
197
- mapping_dict = item_8_schedule_13_dict
198
- elif self.type == 'item_9_schedule_13':
199
- mapping_dict = item_9_schedule_13_dict
200
- elif self.type == 'item_10_schedule_13':
201
- mapping_dict = item_10_schedule_13_dict
202
- elif self.type == 'signature_schedule_13':
203
- mapping_dict = signature_schedule_13_dict
204
-
205
- # D
206
- elif self.type == 'issuer_list_d':
207
- mapping_dict = issuer_list_d_dict
208
- elif self.type == 'metadata_d':
209
- mapping_dict = metadata_d_dict
210
- elif self.type == 'offering_data_d':
211
- mapping_dict = offering_data_d_dict
212
- elif self.type == 'primary_issuer_d':
213
- mapping_dict = primary_issuer_d_dict
214
- elif self.type == 'related_persons_list_d':
215
- mapping_dict = related_persons_d_dict
216
- # SDR
217
- elif self.type == 'sdr':
218
- mapping_dict = sdr_dict
219
-
220
- # TA
221
-
222
- # 13F-HR
223
- elif self.type == '13fhr':
224
- mapping_dict = thirteenfhr_dict
225
-
226
- # 25-NSE
227
- elif self.type == '25nse':
228
- mapping_dict = twentyfive_nse_dict
229
-
230
- # 24F-2NT
231
- elif self.type == 'metadata_24f_2nt':
232
- mapping_dict = metadata_24f_2nt_dict
233
- elif self.type == 'item_1_24f2nt':
234
- mapping_dict = item_1_24f2nt_dict
235
- elif self.type == 'item_2_24f2nt':
236
- mapping_dict = item_2_24f2nt_dict
237
- elif self.type == 'item_3_24f2nt':
238
- mapping_dict = item_3_24f2nt_dict
239
- elif self.type == 'item_4_24f2nt':
240
- mapping_dict = item_4_24f2nt_dict
241
- elif self.type == 'item_5_24f2nt':
242
- mapping_dict = item_5_24f2nt_dict
243
- elif self.type == 'item_6_24f2nt':
244
- mapping_dict = item_6_24f2nt_dict
245
- elif self.type == 'item_7_24f2nt':
246
- mapping_dict = item_7_24f2nt_dict
247
- elif self.type == 'item_8_24f2nt':
248
- mapping_dict = item_8_24f2nt_dict
249
- elif self.type == 'item_9_24f2nt':
250
- mapping_dict = item_9_24f2nt_dict
251
- elif self.type == 'signature_info_schedule_a':
252
- mapping_dict = signature_24f2nt_dict
253
- # ABS
254
- elif self.type == 'assets_ex102_absee':
255
- mapping_dict = assets_dict_ex102_abs
256
- elif self.type =='properties_ex102_absee':
257
- mapping_dict = properties_dict_ex102_abs
258
- # submission metadata
259
- elif self.type == 'document_submission_metadata':
260
- mapping_dict = document_submission_metadata_dict
261
-
262
-
263
- else:
264
- mapping_dict = {}
265
-
266
- # Update mapping dictionary to include accession at the beginning
267
- # Create a new mapping with accession as the first key
268
- new_mapping = {'accession': 'accession'}
269
- # Add the rest of the mapping
270
- new_mapping.update(mapping_dict)
271
- mapping_dict = new_mapping
272
-
273
- # apply the mapping to the data
274
- for row in self.data:
275
- ordered_row = {}
276
- # First add all keys from the mapping dict in order
277
- for old_key, new_key in mapping_dict.items():
278
- if old_key in row:
279
- ordered_row[new_key] = row.pop(old_key)
280
-
281
- # Then add any remaining keys that weren't in the mapping
282
- for key, value in row.items():
283
- ordered_row[key] = value
284
-
285
- # Replace the original row with the ordered row
286
- row.clear()
287
- row.update(ordered_row)
288
-
289
- # Update the columns after mapping
290
- columns = set(self.columns)
291
- # remove the old columns that are now in the mapping
292
- columns.difference_update(mapping_dict.keys())
293
- # add the new columns from the mapping
294
- columns.update(mapping_dict.values())
295
- # add the accession column to the columns
296
- columns.add('accession')
297
-
298
- self.columns = list(columns)
299
-
300
- def write_csv(self, output_file):
301
- output_file = Path(output_file)
302
- fieldnames = self.columns
303
-
304
- # Check if the file already exists
305
- if output_file.exists():
306
- # Append to existing file without writing header
307
- with open(output_file, 'a', newline='') as csvfile:
308
- writer = csv.DictWriter(csvfile, fieldnames=fieldnames, quoting=csv.QUOTE_ALL)
309
- writer.writerows(self.data)
310
- else:
311
- # Create new file with header
312
- with open(output_file, 'w', newline='') as csvfile:
313
- writer = csv.DictWriter(csvfile, fieldnames=fieldnames, quoting=csv.QUOTE_ALL)
314
- writer.writeheader()
315
- writer.writerows(self.data)
File without changes