Open dwillis opened 6 years ago
Is the example for Kentucky a new-style Clarity site? I’m seeing this error when following the README and curious if it’s part of this issue:
>>> import clarify
>>> j = clarify.Jurisdiction(url='http://results.enr.clarityelections.com/KY/15261/30235/en/summary.html', level='state')
>>> j.report_url('xml')
'https://results.enr.clarityelections.com/KY/15261/30235/reports/detailxml.zip'
>>> subs = j.get_subjurisdictions()
>>> subs[0].name
'Boone'
>>> subs[-1].report_url('xml')
'https://results.enr.clarityelections.com/KY/Woodford/15382/27566/reports/detailxml.zip'
(At this point I download and extract the Woodford XML to /tmp/detail.xml
)
>>> p = clarify.Parser()
>>> p.parse("/tmp/detail.xml")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/private/tmp/clarify/.venv/lib/python3.6/site-packages/clarify/parser.py", line 47, in parse
self.voter_turnout = float(election_voter_turnout[2])
IndexError: list index out of range
@migurski No, Kentucky is an older Clarity site, so this looks like a separate issue. Thanks for flagging it, though!
Ah cool — is there a current Clarity example that demonstrates working behavior?
Just updated the README to use one.
Oh boo
Also Colorado, if you need another test case.
The README example is Georgia, which uses the new Clarity 'Web02' format for new elections, but the README example is for an older GA election that uses the older summary.html results URL format. The most recent GA election result page is "http://results.enr.clarityelections.com/GA/91639/Web02-state.221451/#/". The "j.report_url('xml')" step from the README does NOT work with the new Web02 format, but "j.get_subjurisdictions()" does work properly. There's a get_latest_summary_url() method that works with Web02, but the report_url() does not use this.
@kyoung2112 Thanks - we'll get that fixed on j.report_url('xml')
It looks like there's now a new URL format that behaves pretty similarly to the WV and GA cases, but not exactly so it again breaks the code: https://results.enr.clarityelections.com/KY/103779/web.255599/#/reporting
@bxjw Thanks - just pushed a fix for this but have not done a release yet. If you install directly from GitHub it should work.
@dwillis Most 2020 elections are now using the web.XXXXXX
URL format, for example the GA 2020 general election here: https://results.enr.clarityelections.com/GA/105369/web.264614/#/summary
Installing from source current as of posting, neither this link nor the KY link posted previously work for j.report_url('xml')
- it returns None.
Edit: KY and GA do work for subjurisdictions it just takes a bit.
Like West Virginia, which clarify fails to parse and return any information from.