Package: aoc-helper
aoc_helper@salt-die's aoc_helper package, rewritten from the ground upAutomationThis project aims to be compliant with theAdvent of Code Automation Guidelines. 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(lines107-108,152)TheUser-Agentheader declares the package name, version, and my contact info -data.HEADERS,usedineveryoutboundrequestIf requesting input before the puzzle unlocks,the library will wait for unlock before sending any requests(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(sending only one extra request; itishowever possible for a user to send multiple requests in quick succession, by repeatedly callingsubmitbefore the cooldown is over)Advent of Code will not be queried at allif the puzzle has already been solvedorif an answer has already been submittedIf, 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 theaoc cleancommand.InstallationInstallaoc_helperwithpip!pipinstallaoc_helper# install the dependencies required for the Command Line Interfacepipinstallaoc_helper[cli]# install the dependencies required for colourpipinstallaoc_helper[fancy]# install all additional dependenciespipinstallaoc_helper[cli,fancy]# orpipinstallaoc_helper[full]ConfigurationWhen 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 aHTTPOnly cookie. This means there is no way of extracting it with JavaScript, you either must
use a browser extension such asEditThisCookie, or followthis guideThis token is stored in~/.config/aoc_helper/token.txt(C:\Users\YOUR_USERNAME\.config\aoc_helper\token.txton Windows,
probably), and otheraoc_helperdata 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 inaoc_helper's
configuration folder.Command Line Interfaceaoc_helperhas a command line interface, accessed by runningpython -m aoc_helperoraocfollowed by the command line arguments. Its commands are detailed below:fetchaoc fetch <DAY> [--year <YEAR>]Fetch your input for a given day.YEAR is the current year by default.Examples (written during 2020):aocfetch2# fetches input for 2020 day 2aocfetch24--year2019# fetches input for 2019 day 24submitaoc 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):aocsubmit21643# submits 643 as the answer for 2020 day 2 part 1aocsubmit24112531574--year2019# submits 12531574 as the answer for 2019 day 2 part 1templateaoc template <DAYS> [--year YEAR]Generates templates for your advent of code folder.YEAR is the current year by default.DAYSmust be a comma-separated list of date ranges, which may be one of:all, to generate a template for every day in the yearA single integer in the range [1, 25] to generate a single templateA pair of integers in the range [1, 25], separated with a hyphen, to generate template for each day in the rangeNote that even if a day is included in the list of days more than once (including implicitly, within ranges orall), it will only be generated once.Filenames are formatted asday_NUMBER.pywhereNUMBERis the 2-digit day number.Examples (written during 2020):aoctemplateall# generates day_01.py to day_25.py, with aoc_helper methods referencing 2020, in the current folderaoctemplate3--year2019# generates day_03.py, with aoc_helper methods referencing 2019, in the current folderaoctemplate3-5--year2017# generates day_03.py to day_05.py, with aoc_helper methods referencing 2017, in the current folderaoctemplate3-5,7,9,9-10# generates files for days 3, 4, 5, 7, 9, and 10