datamule 2.0.6__py3-none-any.whl → 2.0.8__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.
@@ -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.append(apply_mapping(data_dict, mapping_dict, accession))
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
- for key, value in flattened_data.items():
89
- ordered_row[key] = value
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))
datamule/submission.py CHANGED
@@ -250,7 +250,7 @@ class Submission:
250
250
  def parse_xbrl(self):
251
251
  if self._xbrl:
252
252
  return
253
-
253
+
254
254
  for idx, doc in enumerate(self.metadata.content['documents']):
255
255
  if doc['type'] in ['EX-100.INS','EX-101.INS']:
256
256
  document = self._load_document_by_index(idx)
@@ -310,8 +310,8 @@ class Submission:
310
310
 
311
311
  if xbrl_record.get('_context'):
312
312
  context = xbrl_record['_context']
313
- period_start_date = context.get('context_period_instant') or context.get('context_period_startdate')
314
- period_end_date = context.get('context_period_enddate')
313
+ period_start_date = context.get('period_instant') or context.get('period_startdate')
314
+ period_end_date = context.get('period_enddate')
315
315
 
316
316
  # Create record in the format expected by construct_fundamentals
317
317
  record = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: datamule
3
- Version: 2.0.6
3
+ Version: 2.0.8
4
4
  Summary: Work with SEC submissions at scale.
5
5
  Home-page: https://github.com/john-friedman/datamule-python
6
6
  Author: John Friedman
@@ -6,7 +6,7 @@ datamule/package_updater.py,sha256=Z9zaa_y0Z5cknpRn8oPea3gg4kquFHfpfhduKKCZ6NU,9
6
6
  datamule/portfolio.py,sha256=YViG1JgJ9SFhg8N3tOOhBI8oc6Pmi2vwnHeHmlkC_5U,12119
7
7
  datamule/portfolio_compression_utils.py,sha256=8OPYEN5zAdV1FiTxgVN3S7cTKs99Elv74bwgoIJP4QY,12654
8
8
  datamule/sheet.py,sha256=Ws_YRtpvewLVioarngVMe8cgG_sp11MP9_goGbRaiWE,23952
9
- datamule/submission.py,sha256=tX1r-KeytnvZRcyeVeBVOS9KbT0baOs7eOgE9qGPU0g,15918
9
+ 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
@@ -14,9 +14,9 @@ datamule/datamule/datamule_mysql_rds.py,sha256=P5vL3RJnOwLz25hPKuoYmxSX7XeDe83YE
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=SMsofx2xmO92pGEM0lQt9cm7lxfuGT8WqcFvL4rxOVk,14406
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=qGGMG2p85AKfS5uBY96m77qREyTtsA7BqfqjELT-x0U,4273
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.6.dist-info/METADATA,sha256=j3-QjEqEptbptQCKn52ImVShwyjvurA0v-Bqt4aXel8,560
54
- datamule-2.0.6.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
55
- datamule-2.0.6.dist-info/top_level.txt,sha256=iOfgmtSMFVyr7JGl_bYSTDry79JbmsG4p8zKq89ktKk,9
56
- datamule-2.0.6.dist-info/RECORD,,
53
+ datamule-2.0.8.dist-info/METADATA,sha256=gaqli_hX9EdM_jVeAO8uGdh4xJQO5iOXI8wi0BL-oUc,560
54
+ datamule-2.0.8.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
55
+ datamule-2.0.8.dist-info/top_level.txt,sha256=iOfgmtSMFVyr7JGl_bYSTDry79JbmsG4p8zKq89ktKk,9
56
+ datamule-2.0.8.dist-info/RECORD,,