{ "info": { "author": "Jeremy Bowers", "author_email": "jeremy.bowers@nytimes.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# APFAKE\n\n![screen shot 2018-03-19 at 10 21 06 am](https://user-images.githubusercontent.com/109988/37601020-67598cd4-2b5f-11e8-9bfc-be939317eb46.png)\n\nHave you ever thought \"I should record the AP API test that's coming in a half hour\" only to find out that it actually concluded a half hour AGO? I've done this several times. And if I've done it before, I have to assume others have done it as well.\n\nTaking the FINAL JSON state file of an AP API election test (e.g., what happens if you hit the test URL after a test has run but before it's zeroed out in the moments before a new test or a live election), `apfake` will generate a file of zeros and then `n` intermediate states between the zeros and the final file with a smoothly incrementing set of votes.\n\nIn short: If you give it the last file of a test, `apfake` will generate all the missing files for you.\n\n## CAVEATS\n* `apfake` does not call races.\n* `apfake` votes do not properly match actual election night spikes when ballots are counted.\n* `apfake` precincts reporting and precincts reporting percentages are probably wrong.\n* `apfake` does not work on zeros or initialization data. It needs the format `&results=ru` from the AP API.\n\n## USAGE\n### Installing\n`apfake` is easiest to install straight from PyPi. It requires a Python 3 environment.\n```\npip install apfake\n```\n\n### Using\n```\napfake -f 2018-03-20-final.json -n 10 -d /tmp/foo/ -r 2018-03-20\n```\n\n`apfake` accepts four command-line options, two are required.\n\n* `-f, --final-results-path` **REQUIRED** The path to the final results JSON file.\n* `-n, --number` **REQUIRED** The number of files to generate.\n* `-r, --racedate` *OPTIONAL* The `YYYY-MM-DD` racedate of the election. If the file specified in `final-results-path` has a racedate in the filename, this will be used. Otherwise, `apfake` will raise a `ValueError`.\n* `-d, --data-directory` *OPTIONAL* A directory or set of directories to write the data to. `apfake` will create these directories if they do not exist, and will also create a directory named for the `racedate` to hold the output files. Defaults to `/tmp/`.\n\n## DEBUGGING WITCHERY\nThis is the shape that `apfake` expects your JSON to have. If you use the format `&results=ru` it will probably work. If you use a different format, it might work, though YMMV.\n```\n\"\"\"\nresults.keys()\ndict_keys(['electionDate', 'timestamp', 'races', 'nextrequest'])\n\nresults['races'][0].keys()\ndict_keys(['test', 'raceID', 'raceType', 'raceTypeID', 'officeID', 'officeName', 'party', 'seatName', 'reportingUnits'])\n\nresult['races][0]['reportingUnits'][0].keys()\ndict_keys(['statePostal', 'stateName', 'level', 'lastUpdated', 'precinctsReporting', 'precinctsTotal', 'precinctsReportingPct', 'candidates'])\n\nresults['races'][0]['reportingUnits'][0]['candidates'][0].keys()\ndict_keys(['first', 'last', 'party', 'incumbent', 'candidateID', 'polID', 'ballotOrder', 'polNum', 'voteCount'])\n\"\"\"\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/newsdev/apfake", "keywords": "election race candidate democracy news associated press", "license": "Apache License 2.0", "maintainer": "", "maintainer_email": "", "name": "apfake", "package_url": "https://pypi.org/project/apfake/", "platform": "", "project_url": "https://pypi.org/project/apfake/", "project_urls": { "Homepage": "https://github.com/newsdev/apfake" }, "release_url": "https://pypi.org/project/apfake/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "Command-line interface for extrapolating test data from a single AP API JSON file.", "version": "0.0.3" }, "last_serial": 3978829, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "668cc8e2fb08db8622f20ac5ebfb2701", "sha256": "dc515e0052fb77aeee771eda0bcae018d2854a58ed34a951a9d524929c1db6c5" }, "downloads": -1, "filename": "apfake-0.0.1.tar.gz", "has_sig": false, "md5_digest": "668cc8e2fb08db8622f20ac5ebfb2701", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4197, "upload_time": "2018-03-19T14:40:31", "url": "https://files.pythonhosted.org/packages/26/68/59f54c4b9dbb86b3c4a800b4cc95e98d1a39a17589c176d50f6f080815c9/apfake-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "dff30ee2019d56fcba35cd26959bb0dc", "sha256": "769f1f76a21613fb4fb7f8349834428fdc91d88d2f1ff16c4a91987be51eb860" }, "downloads": -1, "filename": "apfake-0.0.2.tar.gz", "has_sig": false, "md5_digest": "dff30ee2019d56fcba35cd26959bb0dc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4120, "upload_time": "2018-06-19T19:27:24", "url": "https://files.pythonhosted.org/packages/9a/b1/3e2f79151a4a022470c0e8c35858e938482f0741cf5ee60aa62f0f8da3d3/apfake-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "5b6d606480c5b17f5ea7c37f5124e8db", "sha256": "5a20f9ec1396f8f2dba3b66291cf9aa7d95f25dd050b3f93bd0a848c5e2bb89f" }, "downloads": -1, "filename": "apfake-0.0.3.tar.gz", "has_sig": false, "md5_digest": "5b6d606480c5b17f5ea7c37f5124e8db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4122, "upload_time": "2018-06-19T19:55:27", "url": "https://files.pythonhosted.org/packages/97/51/9f0d9601b6fe60cdc3bfbba128c7f3dd1b77816c20cccdaedcd665e04ae3/apfake-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5b6d606480c5b17f5ea7c37f5124e8db", "sha256": "5a20f9ec1396f8f2dba3b66291cf9aa7d95f25dd050b3f93bd0a848c5e2bb89f" }, "downloads": -1, "filename": "apfake-0.0.3.tar.gz", "has_sig": false, "md5_digest": "5b6d606480c5b17f5ea7c37f5124e8db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4122, "upload_time": "2018-06-19T19:55:27", "url": "https://files.pythonhosted.org/packages/97/51/9f0d9601b6fe60cdc3bfbba128c7f3dd1b77816c20cccdaedcd665e04ae3/apfake-0.0.3.tar.gz" } ] }