Open Kirkman opened 4 years ago
I was using clarify 0.4.0 installed via pip.
It looks like the most recent commit (f9bfb09876a1c2f0b68034aa0494a31aaf009250) in this repo solves my issue.
However, I also found that, in 0.4.0, simply deleting the second line here ...
for subjurisdiction_el in vt_el.xpath('./Precinct') + vt_el.xpath('./County'):
subjurisdiction = self.get_result_jurisdiction(subjurisdiction_el.attrib['name'])
subjurisdiction = self._get_or_create_result_jurisdiction(subjurisdiction_el)
...resolved the issue as well.
Oh, interesting, thanks!
Do you anticipate a version bump for Clarify soon on PyPi incorporating that change?
I seem to be having a similar issue. I'm trying to parse Fort Bend County, TX results , and there are a few odd precinct names. Here is the output I get from the parser:
Traceback (most recent call last): File "
", line 1, in File "/usr/local/lib/python3.9/site-packages/clarify/parser.py", line 51, in parse self._contests = self._parse_contests(tree) File "/usr/local/lib/python3.9/site-packages/clarify/parser.py", line 284, in _parse_contests return [self._parse_contest(el) for el in contest_els] File "/usr/local/lib/python3.9/site-packages/clarify/parser.py", line 284, in return [self._parse_contest(el) for el in contest_els] File "/usr/local/lib/python3.9/site-packages/clarify/parser.py", line 312, in _parse_contest for c in self._parse_choices(contest_el, contest): File "/usr/local/lib/python3.9/site-packages/clarify/parser.py", line 369, in _parse_choices return [self._parse_choice(c_el, contest) File "/usr/local/lib/python3.9/site-packages/clarify/parser.py", line 369, in return [self._parse_choice(c_el, contest) File "/usr/local/lib/python3.9/site-packages/clarify/parser.py", line 409, in _parse_choice subjurisdiction = self.get_result_jurisdiction(subjurisdiction_el.attrib['name']) File "/usr/local/lib/python3.9/site-packages/clarify/parser.py", line 219, in get_result_jurisdiction return self._result_jurisdiction_lookup[name] KeyError: '1134 M68'
Last night ran into an issue with a LiveVoterTurnout XML file that Clarify wouldn't parse.
Basically, each Contest had a
Intrastate New Resident
precinct listed. But the master Precincts list didn't include it.This led to a KeyError:
I'm attaching the ZIP file for reference. If I get some time next week I may try to see if I can find a solution and submit a pull request, but wanted to let you know about it.
lincoln-county.zip