unitedstates / congressional-record

A parser for the Congressional Record.
Other
128 stars 40 forks source link

Getting "AttributeError: 'NoneType' object has no attribute 'parent'" #33

Closed napsternxg closed 6 years ago

napsternxg commented 6 years ago

When I run my code via python2 using the following commands:

$ python -m congressionalrecord.cli "1994-02-11" "2017-09-27" json
Traceback (most recent call last):
  File "/homed/content/anaconda3/envs/python2/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/homed/content/anaconda3/envs/python2/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/content/anaconda3/envs/python2/lib/python2.7/site-packages/congressionalrecord/cli.py", line 75, in <module>
    main()
  File "/home/content/anaconda3/envs/python2/lib/python2.7/site-packages/congressionalrecord/cli.py", line 65, in main
    dl(args.start,end=args.end,do_mode='json')
  File "/homed/content/anaconda3/envs/python2/lib/python2.7/site-packages/congressionalrecord/fdsys/downloader.py", line 119, in __init__
    for crfile in self.bulkdownload(start,**kwargs):
  File "/homed/content/anaconda3/envs/python2/lib/python2.7/site-packages/congressionalrecord/fdsys/downloader.py", line 48, in bulkdownload
    crfile = ParseCRFile(parse_path,crdir)
  File "/homed/content/anaconda3/envs/python2/lib/python2.7/site-packages/congressionalrecord/fdsys/cr_parser.py", line 466, in __init__
    self.gen_file_metadata()
  File "/homed/content/anaconda3/envs/python2/lib/python2.7/site-packages/congressionalrecord/fdsys/cr_parser.py", line 197, in gen_file_metadata
    self.doc_ref = self.cr_dir.mods.find('accessid', text=self.access_path).parent
AttributeError: 'NoneType' object has no attribute 'parent'
AlJohri commented 6 years ago

I fixed this issue back in the day. if you look at self.access_path its CREC-1994-02-22-pt1-Pgnull-2.

https://github.com/propublica/Capitol-Words/pull/88

nclarkjudd commented 6 years ago

A bad programmer (<---) must have ignored this regression while refactoring code. I'll get to it maybe this weekend.

napsternxg commented 6 years ago

I have fixed it in the code and have send a PR. I also added the related test file to check for this. All tests pass.