datamule 2.3.6__py3-none-any.whl → 2.3.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.

Potentially problematic release.


This version of datamule might be problematic. Click here for more details.

@@ -6,14 +6,13 @@ from secsgml.parse_sgml import transform_metadata_string
6
6
  from secsgml.utils import bytes_to_str
7
7
  from ..sec.utils import headers
8
8
  import tarfile
9
- import zstandard as zstd
10
- import gzip
11
9
  import urllib.request
12
10
  from secxbrl import parse_inline_xbrl
13
11
  from company_fundamentals import construct_fundamentals
14
12
  from decimal import Decimal
15
13
  from ..utils.format_accession import format_accession
16
14
  from .tar_submission import tar_submission
15
+ import zstandard as zstd
17
16
 
18
17
  # probably needs rework later
19
18
  class FundamentalsAccessor:
@@ -22,10 +21,19 @@ class FundamentalsAccessor:
22
21
  self._cache = {}
23
22
  self._all_data = None
24
23
 
25
- def __getattr__(self, category):
26
- if category not in self._cache:
27
- self._cache[category] = self.submission.parse_fundamentals(categories=[category])
28
- return self._cache[category]
24
+ def __getattr__(self, name):
25
+ # Try as category first
26
+ try:
27
+ if name not in self._cache:
28
+ result = self.submission.parse_fundamentals(categories=[name])
29
+ if result: # Only cache if we got actual data
30
+ self._cache[name] = result
31
+ return result
32
+ except:
33
+ pass
34
+
35
+ # Fall back to dict behavior
36
+ return getattr(self._get_all_data(), name)
29
37
 
30
38
  def _get_all_data(self):
31
39
  if self._all_data is None:
@@ -98,6 +106,10 @@ class Submission:
98
106
 
99
107
  if response.getcode() == 200:
100
108
  sgml_content=response.read()
109
+ content_type = response.headers.get('Content-Type', '')
110
+ if content_type == 'application/zstd':
111
+ dctx = zstd.ZstdDecompressor()
112
+ sgml_content = dctx.decompress(sgml_content)
101
113
  else:
102
114
  raise ValueError(f"URL: {url}, Error: {response.getcode()}")
103
115
 
@@ -109,6 +121,7 @@ class Submission:
109
121
  metadata = transform_metadata_string(metadata)
110
122
 
111
123
  self.metadata = Document(type='submission_metadata', content=metadata, extension='.json',filing_date=None,accession=None,path=None)
124
+
112
125
  self.filing_date= f"{self.metadata.content['filing-date'][:4]}-{self.metadata.content['filing-date'][4:6]}-{self.metadata.content['filing-date'][6:8]}"
113
126
 
114
127
  self.documents_obj_list = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: datamule
3
- Version: 2.3.6
3
+ Version: 2.3.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
@@ -43,7 +43,7 @@ datamule/seclibrary/bq.py,sha256=TOP0WA6agDKu4vE1eHd62NDpAc02LDDrOP-g1bJpxbw,180
43
43
  datamule/sheet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
44
  datamule/sheet/sheet.py,sha256=Dw979JGygS566N0Iwsvqk0h1s26GfbrIHDWiBaS2oH8,10711
45
45
  datamule/submission/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
- datamule/submission/submission.py,sha256=_dcQFZ0f8Me4-R5E92_HHNb_k2shcspRgQeN3s5-db4,16836
46
+ datamule/submission/submission.py,sha256=I_7F658vTW1C_dsogIXdxXnV3W1Gbfj_6uzse1YHgY0,17343
47
47
  datamule/submission/tar_submission.py,sha256=lkm1neVLW2_-G26VylL6Rzx98Cavvml0Qd2wlJHD0bw,3075
48
48
  datamule/tables/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
49
  datamule/tables/tables.py,sha256=Z3Eu6bdjiaNx4pgXlTMwk2Q-DhpMpEAygF2kJdp-Pu8,5722
@@ -65,7 +65,7 @@ datamule/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
65
  datamule/utils/construct_submissions_data.py,sha256=NB_hvfxlRXPyt4Fgc-5qA8vJRItkLhBedCSTaxwW7Jg,5887
66
66
  datamule/utils/format_accession.py,sha256=60RtqoNqoT9zSKVb1DeOv1gncJxzPTFMNW4SNOVmC_g,476
67
67
  datamule/utils/pdf.py,sha256=Z9xrdVhKex2YdvjYsaPaygRE_J6P_JNiUGkwflz2Hw0,735
68
- datamule-2.3.6.dist-info/METADATA,sha256=njsh6r7ekNM3iYGV1GIAns0_fMAlxYy6nOcxlRrHIeI,609
69
- datamule-2.3.6.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
70
- datamule-2.3.6.dist-info/top_level.txt,sha256=iOfgmtSMFVyr7JGl_bYSTDry79JbmsG4p8zKq89ktKk,9
71
- datamule-2.3.6.dist-info/RECORD,,
68
+ datamule-2.3.8.dist-info/METADATA,sha256=wJ1iQL5mMQ6hyK9Wqh27ohWjZmCoZmi3XfXC5PwCwL8,609
69
+ datamule-2.3.8.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
70
+ datamule-2.3.8.dist-info/top_level.txt,sha256=iOfgmtSMFVyr7JGl_bYSTDry79JbmsG4p8zKq89ktKk,9
71
+ datamule-2.3.8.dist-info/RECORD,,