Created
January 19, 2009 12:53
-
-
Save kragen/48975 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 9c421b3e3a771f015f300aa6439aa7028500b2fa Mon Sep 17 00:00:00 2001 | |
From: kragen <[email protected]> | |
Date: Mon, 19 Jan 2009 10:49:47 -0200 | |
Subject: [PATCH] fixing error where a single 2.x file would raise StopIteration and kill the whole zipfile | |
--- | |
import/parse/fec_crude_csv.py | 7 ++++++- | |
1 files changed, 6 insertions(+), 1 deletions(-) | |
diff --git a/import/parse/fec_crude_csv.py b/import/parse/fec_crude_csv.py | |
index 2151f17..5e8b0e5 100755 | |
--- a/import/parse/fec_crude_csv.py | |
+++ b/import/parse/fec_crude_csv.py | |
@@ -368,6 +368,8 @@ def decode_headerline(line): | |
return headers | |
+class FilingFormatNotDocumented(Exception): pass | |
+ | |
# Note that normally we are reading from a zipfile, and Python’s | |
# stupid zipfile interface doesn’t AFAICT give us the option of | |
# streaming reads — it insists on reading the whole zipfile element at | |
@@ -393,7 +395,7 @@ def readstring(astring): | |
# It’s probably the old 2.x format that we don’t support yet | |
# because we can’t find docs; return without yielding | |
# anything. | |
- return | |
+ raise FilingFormatNotDocumented(astring[:20]) | |
headerdict = decode_headerline(headerline) | |
yield headerdict | |
@@ -524,6 +526,9 @@ def stash_efilings(destdir = None, filepattern = None, save_orig = False): | |
if issubclass(eclass, KeyboardInterrupt): raise | |
if issubclass(eclass, StopIteration): raise # let it propagate | |
if issubclass(eclass, GeneratorExit): raise # let the generator die | |
+ if issubclass(eclass, FilingFormatNotDocumented): | |
+ # We don't bother to log these; we know they happen. | |
+ return | |
pathname = cover_record.get('pathname') | |
report_id = cover_record.get('this_report_id') | |
-- | |
1.5.6.3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment