diff options
Diffstat (limited to 'python/markit_red.py')
| -rw-r--r-- | python/markit_red.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/python/markit_red.py b/python/markit_red.py index 0cc3d5b2..f0405c4d 100644 --- a/python/markit_red.py +++ b/python/markit_red.py @@ -16,23 +16,34 @@ def request_payload(payload): if 'Delta' in payload['report']: path = os.path.join(path, "Deltas") - with zipfile.ZipFile(io.BytesIO(r.content)) as z: - for f in z.namelist(): - if f.endswith("xml"): - z.extract(f, path=path) - res.append(f) + try: + with zipfile.ZipFile(io.BytesIO(r.content)) as z: + for f in z.namelist(): + if f.endswith("xml"): + z.extract(f, path=path) + res.append(f) + except zipfile.BadZipFile: + print(r.content) return res def download_report(report): - if "Entity" in report: - version = 11 - elif "RED" in report: - version= 9 - else: - version = 10 + version_mapping = {"REDEntity": 11, + "REDEntityDelta": 11, + "REDEntityMapped": 11, + "REDObligation": 10, + "REDObligationDelta": 10, + "REDObligationMapped": 10, + "REDSROObligation": 10, + "REDobligationpreferred": 10, + "CredIndexAnnex": 10, + "CredIndexAnnexSplit": 10, + "REDIndexCodes": 9, + "redindexclassification": 9, + "redindexclassificationdelta": 9} + payload = {'user': 'GuillaumeHorel', 'password': 'password', - 'version': version, + 'version': version_mapping[report], 'report': report} if report in ['CredIndexAnnex', 'CredIndexAnnexSplit']: |
