Skip to content

Instantly share code, notes, and snippets.

@kragen
Created December 14, 2008 19:24
Show Gist options
  • Save kragen/35772 to your computer and use it in GitHub Desktop.
Save kragen/35772 to your computer and use it in GitHub Desktop.
<type 'exceptions.AttributeError'>
Python 2.5: /usr/bin/python2.5
Sun Dec 14 15:58:45 2008
A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.
/home/kragen/devel/watchdog-git/import/parse/fec_crude_csv.py in <module>()
535 destdir = sys.argv.pop(1)
536 pattern = sys.argv[1] if len(sys.argv) > 1 else None
537 stash_efilings(destdir=destdir, filepattern=pattern)
538 else:
539 # pprint is unacceptable --- it made the script run 40× slower.
stash_efilings = <function stash_efilings at 0xb7805534>
destdir = 'fucked-data'
filepattern undefined
pattern = 'sample-fec-data/tmp/*'
/home/kragen/devel/watchdog-git/import/parse/fec_crude_csv.py in
stash_efilings(destdir='fucked-data', filepattern='sample-fec-data/tmp/*',
save_orig=False)
504 if destdir is None: destdir = tempfile.mkdtemp()
505
506 for cover_record, records in parse_efilings(filepattern):
507 report_id = cover_record['report_id']
508 dirpath = os.path.join(destdir, report_id[-2:], report_id)
cover_record = {'address': '1736 East Sunshine, Suite 913 Springfield MO 65804 ',
'committee': 'Rely On Your Beliefs Fund', 'filer_id': 'C00344648', 'format_version':
'3.00', 'report_id': '39723', 'this_report_id': '39723', 'type': None}
records = <generator object at 0xb78227ec>
global parse_efilings = <function parse_efilings at 0xb78054c4>
filepattern = 'sample-fec-data/tmp/*'
/home/kragen/devel/watchdog-git/import/parse/fec_crude_csv.py in
parse_efilings(filepattern='sample-fec-data/tmp/*')
488 for filename in glob.glob(filepattern):
489 sys.stderr.write('parsing efilings file %s\n' % filename)
490 for parsed_file in readfile_generic(filename):
491 yield parsed_file
492 now = time.time()
parsed_file = ({'address': '1736 East Sunshine, Suite 913 Springfield MO 65804 ',
'committee': 'Rely On Your Beliefs Fund', 'filer_id': 'C00344648', 'format_version':
'3.00', 'report_id': '39723', 'this_report_id': '39723', 'type': None}, <generator
object at 0xb78227ec>)
global readfile_generic = <function readfile_generic at 0xb780548c>
filename = 'sample-fec-data/tmp/39775.fec'
/home/kragen/devel/watchdog-git/import/parse/fec_crude_csv.py in
readfile_generic(filename='sample-fec-data/tmp/39775.fec')
479 else:
480 _, basename = os.path.split(filename)
481 return [read_filing(file(filename).read(), basename)]
482
483 EFILINGS_PATH = '../data/crawl/fec/electronic/'
global read_filing = <function read_filing at 0xb780541c>
builtinfile = <type 'file'>
filename = 'sample-fec-data/tmp/39775.fec'
).read undefined
basename = '39775.fec'
/home/kragen/devel/watchdog-git/import/parse/fec_crude_csv.py in
read_filing(astring='HDR,FEC,3.00,Region\'s Own Software,2.00,,FEC-238..."Spencer
Bachus","H","AL","6",,,,,,,,,N,YED0127 \n', filename='39775.fec')
456 if header_record.get('report_id'): # The field may be missing or empty.
457 cover_record['report_id'] = \
458 re.match('(?i)fec-\s*(\d+)$', header_record['report_id']).group(1)
459 else:
460 cover_record['report_id'] = cover_record['this_report_id']
global re = <module 're' from '/usr/lib/python2.5/re.pyc'>
re.match = <function match at 0xb7d24c6c>
header_record = {'ef_type': 'FEC', 'fec_ver': '3.00', 'name_delim': '^', 'record_type':
'HDR', 'report_id': 'FEC-23808 F3XN', 'rpt_number': '1', 'soft_name': "Region's Own
Software", 'soft_ver': '2.00'}
).group undefined
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'group'
The above is a description of an error in a Python program. Here is
the original traceback:
Traceback (most recent call last):
File "parse/fec_crude_csv.py", line 537, in <module>
stash_efilings(destdir=destdir, filepattern=pattern)
File "parse/fec_crude_csv.py", line 506, in stash_efilings
for cover_record, records in parse_efilings(filepattern):
File "parse/fec_crude_csv.py", line 490, in parse_efilings
for parsed_file in readfile_generic(filename):
File "parse/fec_crude_csv.py", line 481, in readfile_generic
return [read_filing(file(filename).read(), basename)]
File "parse/fec_crude_csv.py", line 458, in read_filing
re.match('(?i)fec-\s*(\d+)$', header_record['report_id']).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment