aoc-helper


Nameaoc-helper JSON
Version 1.9.2 PyPI version JSON
download
home_page
SummaryA helper package for Advent of Code
upload_time2023-12-19 05:57:11
maintainer
docs_urlNone
authorStarwort, salt-die
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # `aoc_helper`

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

@salt-die's aoc_helper package, rewritten from the ground up

## Automation

This project aims to be compliant with the [Advent of Code Automation Guidelines](https://www.reddit.com/r/adventofcode/wiki/faqs/automation). Here are the strategies it uses:

- Once inputs are downloaded, they are cached in `~/.config/aoc_helper/YEAR/DAY.in` (or a similar path for Windows users) - [`interface.fetch`](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L97-L155) (lines [107-108](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L107-L108), [152](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L152))
- The `User-Agent` header declares the package name, version, and my contact info - [`data.HEADERS`](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/data.py#L20-L25), [used](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L118) [in](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L139) [every](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L210) [outbound](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L266) [request](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L341)
- If requesting input before the puzzle unlocks, [the library will wait for unlock before sending any requests](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L130-L133) (except on day 1, where it will send a request to validate the session token)
- If sending an answer too soon after an incorrect one, [the library will wait the cooldown specified in the response](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L231-L234) (sending only one extra request; it *is* however possible for a user to send multiple requests in quick succession, by repeatedly calling `submit` before the cooldown is over)
- Advent of Code will not be queried at all [if the puzzle has already been solved](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L182-L190) or [if an answer has already been submitted](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L193-L199)
- If, for some reason, the user decides they wish to clear their cache (for example, if they believe their input to be corrupted) they can do so by using the [`aoc clean`](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/main.py#L91-L121) command.

## Installation

Install `aoc_helper` with `pip`!

```bash
pip install aoc_helper
# install the dependencies required for the Command Line Interface
pip install aoc_helper[cli]
# install the dependencies required for colour
pip install aoc_helper[fancy]
# install all additional dependencies
pip install aoc_helper[cli,fancy]
# or
pip install aoc_helper[full]
```

## Configuration

When you first use any function that interfaces with Advent of Code, you will be prompted to enter your session token.

Your session token is stored as a *HTTPOnly cookie*. This means there is no way of extracting it with JavaScript, you either must
use a browser extension such as [EditThisCookie](http://www.editthiscookie.com/), or follow [this guide](https://github.com/wimglenn/advent-of-code-wim/issues/1)

This token is stored in `~/.config/aoc_helper/token.txt` (`C:\Users\YOUR_USERNAME\.config\aoc_helper\token.txt` on Windows,
probably), and other `aoc_helper` data is stored in this folder (such as your input and submission caches).

If, for whatever reason, you feel the need to clear your caches, you can do so by deleting the relevant folders in `aoc_helper`'s
configuration folder.

## Command Line Interface

`aoc_helper` has a command line interface, accessed by running `python -m aoc_helper` or `aoc` followed by the command line arguments. Its commands are detailed below:

### `fetch`

`aoc fetch <DAY> [--year <YEAR>]`

Fetch your input for a given day.  
YEAR is the current year by default.

Examples (written during 2020):

```bash
aoc fetch 2 # fetches input for 2020 day 2
aoc fetch 24 --year 2019 # fetches input for 2019 day 24
```

### `submit`

`aoc submit <DAY> <PART> <ANSWER> [--year <YEAR>]`

Submits your answer for a given day and part.  
YEAR is the current year by default.

Examples (written during 2020):

```bash
aoc submit 2 1 643 # submits 643 as the answer for 2020 day 2 part 1
aoc submit 24 1 12531574 --year 2019 # submits 12531574 as the answer for 2019 day 2 part 1
```

### `template`

`aoc template <DAYS> [--year YEAR]`

Generates templates for your advent of code folder.  
YEAR is the current year by default.

`DAYS` must be a comma-separated list of date ranges, which may be one of:

- `all`, to generate a template for every day in the year
- A single integer in the range \[1, 25] to generate a single template
- A pair of integers in the range \[1, 25], separated with a hyphen, to generate template for each day in the range

Note that even if a day is included in the list of days more than once (including implicitly, within ranges or `all`), it will only be generated once.

Filenames are formatted as `day_NUMBER.py` where `NUMBER` is the 2-digit day number.

Examples (written during 2020):

```bash
aoc template all # generates day_01.py to day_25.py, with aoc_helper methods referencing 2020, in the current folder
aoc template 3 --year 2019 # generates day_03.py, with aoc_helper methods referencing 2019, in the current folder
aoc template 3-5 --year 2017 # generates day_03.py to day_05.py, with aoc_helper methods referencing 2017, in the current folder
aoc template 3-5,7,9,9-10 # generates files for days 3, 4, 5, 7, 9, and 10
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "aoc-helper",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Starwort, salt-die",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/a6/2a/1cd944b5f3cf8b4a92a3166ce2cfececeacede45d48dfb9ed702891be6d8/aoc_helper-1.9.2.tar.gz",
    "platform": null,
    "description": "# `aoc_helper`\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n@salt-die's aoc_helper package, rewritten from the ground up\n\n## Automation\n\nThis project aims to be compliant with the [Advent of Code Automation Guidelines](https://www.reddit.com/r/adventofcode/wiki/faqs/automation). Here are the strategies it uses:\n\n- Once inputs are downloaded, they are cached in `~/.config/aoc_helper/YEAR/DAY.in` (or a similar path for Windows users) - [`interface.fetch`](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L97-L155) (lines [107-108](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L107-L108), [152](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L152))\n- The `User-Agent` header declares the package name, version, and my contact info - [`data.HEADERS`](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/data.py#L20-L25), [used](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L118) [in](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L139) [every](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L210) [outbound](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L266) [request](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L341)\n- If requesting input before the puzzle unlocks, [the library will wait for unlock before sending any requests](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L130-L133) (except on day 1, where it will send a request to validate the session token)\n- If sending an answer too soon after an incorrect one, [the library will wait the cooldown specified in the response](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L231-L234) (sending only one extra request; it *is* however possible for a user to send multiple requests in quick succession, by repeatedly calling `submit` before the cooldown is over)\n- Advent of Code will not be queried at all [if the puzzle has already been solved](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L182-L190) or [if an answer has already been submitted](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/interface.py#L193-L199)\n- If, for some reason, the user decides they wish to clear their cache (for example, if they believe their input to be corrupted) they can do so by using the [`aoc clean`](https://github.com/Starwort/aoc_helper/blob/master/aoc_helper/main.py#L91-L121) command.\n\n## Installation\n\nInstall `aoc_helper` with `pip`!\n\n```bash\npip install aoc_helper\n# install the dependencies required for the Command Line Interface\npip install aoc_helper[cli]\n# install the dependencies required for colour\npip install aoc_helper[fancy]\n# install all additional dependencies\npip install aoc_helper[cli,fancy]\n# or\npip install aoc_helper[full]\n```\n\n## Configuration\n\nWhen you first use any function that interfaces with Advent of Code, you will be prompted to enter your session token.\n\nYour session token is stored as a *HTTPOnly cookie*. This means there is no way of extracting it with JavaScript, you either must\nuse a browser extension such as [EditThisCookie](http://www.editthiscookie.com/), or follow [this guide](https://github.com/wimglenn/advent-of-code-wim/issues/1)\n\nThis token is stored in `~/.config/aoc_helper/token.txt` (`C:\\Users\\YOUR_USERNAME\\.config\\aoc_helper\\token.txt` on Windows,\nprobably), and other `aoc_helper` data is stored in this folder (such as your input and submission caches).\n\nIf, for whatever reason, you feel the need to clear your caches, you can do so by deleting the relevant folders in `aoc_helper`'s\nconfiguration folder.\n\n## Command Line Interface\n\n`aoc_helper` has a command line interface, accessed by running `python -m aoc_helper` or `aoc` followed by the command line arguments. Its commands are detailed below:\n\n### `fetch`\n\n`aoc fetch <DAY> [--year <YEAR>]`\n\nFetch your input for a given day.  \nYEAR is the current year by default.\n\nExamples (written during 2020):\n\n```bash\naoc fetch 2 # fetches input for 2020 day 2\naoc fetch 24 --year 2019 # fetches input for 2019 day 24\n```\n\n### `submit`\n\n`aoc submit <DAY> <PART> <ANSWER> [--year <YEAR>]`\n\nSubmits your answer for a given day and part.  \nYEAR is the current year by default.\n\nExamples (written during 2020):\n\n```bash\naoc submit 2 1 643 # submits 643 as the answer for 2020 day 2 part 1\naoc submit 24 1 12531574 --year 2019 # submits 12531574 as the answer for 2019 day 2 part 1\n```\n\n### `template`\n\n`aoc template <DAYS> [--year YEAR]`\n\nGenerates templates for your advent of code folder.  \nYEAR is the current year by default.\n\n`DAYS` must be a comma-separated list of date ranges, which may be one of:\n\n- `all`, to generate a template for every day in the year\n- A single integer in the range \\[1, 25] to generate a single template\n- A pair of integers in the range \\[1, 25], separated with a hyphen, to generate template for each day in the range\n\nNote that even if a day is included in the list of days more than once (including implicitly, within ranges or `all`), it will only be generated once.\n\nFilenames are formatted as `day_NUMBER.py` where `NUMBER` is the 2-digit day number.\n\nExamples (written during 2020):\n\n```bash\naoc template all # generates day_01.py to day_25.py, with aoc_helper methods referencing 2020, in the current folder\naoc template 3 --year 2019 # generates day_03.py, with aoc_helper methods referencing 2019, in the current folder\naoc template 3-5 --year 2017 # generates day_03.py to day_05.py, with aoc_helper methods referencing 2017, in the current folder\naoc template 3-5,7,9,9-10 # generates files for days 3, 4, 5, 7, 9, and 10\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A helper package for Advent of Code",
    "version": "1.9.2",
    "project_urls": {
        "Homepage": "https://github.com/Starwort/aoc_helper"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c976eda2035c7a704cba6fa6b9eacab81349c6652249e06fdadf3c7fefccb3ec",
                "md5": "9ddbd978e92abb00f05b170389d3086a",
                "sha256": "b8f4d3f2b205c61e865d23a92fd09de896e16e70ad701d0eafc13dab3afe4795"
            },
            "downloads": -1,
            "filename": "aoc_helper-1.9.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9ddbd978e92abb00f05b170389d3086a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 31768,
            "upload_time": "2023-12-19T05:57:08",
            "upload_time_iso_8601": "2023-12-19T05:57:08.183275Z",
            "url": "https://files.pythonhosted.org/packages/c9/76/eda2035c7a704cba6fa6b9eacab81349c6652249e06fdadf3c7fefccb3ec/aoc_helper-1.9.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a62a1cd944b5f3cf8b4a92a3166ce2cfececeacede45d48dfb9ed702891be6d8",
                "md5": "d508392b926d5e1b248ccd5ae0ebf202",
                "sha256": "500a7c9a862ebed20fed46067cdd5b36d9bc3c387f90abf564df6346da0be7a3"
            },
            "downloads": -1,
            "filename": "aoc_helper-1.9.2.tar.gz",
            "has_sig": false,
            "md5_digest": "d508392b926d5e1b248ccd5ae0ebf202",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 31946,
            "upload_time": "2023-12-19T05:57:11",
            "upload_time_iso_8601": "2023-12-19T05:57:11.029385Z",
            "url": "https://files.pythonhosted.org/packages/a6/2a/1cd944b5f3cf8b4a92a3166ce2cfececeacede45d48dfb9ed702891be6d8/aoc_helper-1.9.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-19 05:57:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Starwort",
    "github_project": "aoc_helper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "aoc-helper"
}
        
Elapsed time: 0.17539s