Package: elex-clarity
A CLI tool for pulling in election results from sites using Clarity (the “election night reporting” product describedhere). This package is hosted on pypi.Please use theGithub issue trackerto submit bugs or request features.Table of ContentsOverviewInstallationUsageDevelopmentReleasing a New VersionOverviewThis libraryProvides a simple CLI tool for pulling in and formatting election results from a Clarity-backed website or local fileSeparates data retrieval from data formattingBy default, returns results formatted like so{"2020-11-03_GA_G_P":{"id":"2020-11-03_GA_G_P","source":"clarity","precinctsReportingPct":100.0,"counts":{"donald_j_trump_i_rep":2461837,"joseph_r_biden_dem":2474507,"jo_jorgensen_lib":62138},"office":"P","lastUpdated":"2020-11-20T20:37:06Z","subunits":{"appling":{"id":"appling","counts":{"donald_j_trump_i_rep":6526,"joseph_r_biden_dem":1779,"jo_jorgensen_lib":36}},...}}}InstallationMake sure you have python 3.7+ installedOptional: we recommend that you set up avirtualenvand activate itpip installelex-clarityUsageAll CLI commands require a Clarity election ID and state postal code. For exampleelexclarity 105369 GAThe election ID can be found by navigating to the election in question in whichever results site you’re viewing. For example, for Georgia, the Secretary of State’s website links toelection results. Following theCurrent Election Resultslink you get to a clarity page with many election results pages. Looking at the 2020-current results will lead tohttps://results.enr.clarityelections.com/GA/105369/web.264614/#/summary, which contains the election ID right after the state postal code.Other parametersTitleNameDescriptionTypeRequired?Defaultstylewhat broad type of formatting should be done?one of [default, raw]NdefaultoutputTypewhat specific type of formatting should be done?one of [results, settings, summary]Nresultslevelwhat level of data should be fetched/returned?one of [precinct, county, state]NcountycountyNameName of county to get results from if counties have their own pagesstringN–officeIDwhat office ID(s) should be returned?a comma separated list of office IDsN–countyMappingan object with race names (as provided via Clarity) mapped to some other identifier that should be used in results formatting. Sample formats can be found in thetests/fixturesfolderobjectN–voteCompletionModethe method that should be used to determine whether a precinct is fully reportingstringNpercentReportingprecinctsReportingPcta county-level override for the precincts reprting percent that applies to all subunits, given as a mapping between county IDs and percents (does not change the value of the reportingStatus field)objectN–filenamethe path to read results from (if you don’t want to ping a Clarity site)stringN–Example invocationsRetrieving raw data:elexclarity 105369 GA--outputType=summary--style=rawelexclarity 105369 GA--outputType=settings--style=rawelexclarity 105369 GA--level=precinct--style=rawelexclarity 106043 CA--countyNameSanta_Clara--level=precinctRetrieving + formatting settings (for presidential races):elexclarity 105369 GA--outputType=settings--officeID=PRetrieving + formatting results:elexclarity 105369 GA--level=precinct--countyMapping='{"Worth":"13321"}'elexclarity 105369 GA--level=precinctelexclarity 105369 GA--level=precinct--voteCompletionMode=voteTypeselexclarity 105369 GA--level=countyelexclarity 106210 WV--level=county--countyMapping='<mappingjson>'elexclarity 105369 WV--level=stateFormatting data from a local file:elexclarity 105369 GA--level=precinct--filename="tests/fixtures/results/ga_atkinson_precincts_11-3.xml"--countyMapping='<mappingjson>'elexclarity 105369 GA--level=county--filename="tests/fixtures/ga_counties_11-3.xml"--countyMapping='<mappingjson>'DevelopmentClone this repositorypip install-rrequirements.txttoxYou should see some code coverage info and test resultsIf the above was successful, you are ready for developmentReleasing a New VersionIn preparation for a new release:Decide what the next version will be per semantic versioningMake a new branch namedrelease/<versionnumber>Update the changelog with all changes that will be included in the releaseCommit your changes and make a PR againstmainOnce the changes are merged, tagmain(ordevelopfor a beta release) with the release’s version number and push that tag (git push--tags)Mergemainintodevelop