advent-of-code-data 2.0.3__tar.gz → 2.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/PKG-INFO +26 -27
  2. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/README.md +25 -26
  3. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/advent_of_code_data.egg-info/PKG-INFO +26 -27
  4. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/aocd/__init__.py +6 -0
  5. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/aocd/get.py +20 -3
  6. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/pyproject.toml +1 -1
  7. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/tests/test_aocd.py +11 -0
  8. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/LICENSE +0 -0
  9. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/advent_of_code_data.egg-info/SOURCES.txt +0 -0
  10. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/advent_of_code_data.egg-info/dependency_links.txt +0 -0
  11. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/advent_of_code_data.egg-info/entry_points.txt +0 -0
  12. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/advent_of_code_data.egg-info/requires.txt +0 -0
  13. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/advent_of_code_data.egg-info/top_level.txt +0 -0
  14. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/aocd/_ipykernel.py +0 -0
  15. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/aocd/cli.py +0 -0
  16. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/aocd/cookies.py +0 -0
  17. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/aocd/examples.py +0 -0
  18. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/aocd/exceptions.py +0 -0
  19. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/aocd/models.py +0 -0
  20. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/aocd/post.py +0 -0
  21. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/aocd/py.typed +0 -0
  22. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/aocd/runner.py +0 -0
  23. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/aocd/types.py +0 -0
  24. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/aocd/utils.py +0 -0
  25. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/setup.cfg +0 -0
  26. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/tests/test_auth.py +0 -0
  27. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/tests/test_cli.py +0 -0
  28. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/tests/test_cookies.py +0 -0
  29. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/tests/test_date_finding.py +0 -0
  30. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/tests/test_date_introspection.py +0 -0
  31. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/tests/test_example_parser.py +0 -0
  32. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/tests/test_get_data.py +0 -0
  33. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/tests/test_models.py +0 -0
  34. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/tests/test_runner.py +0 -0
  35. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/tests/test_submit.py +0 -0
  36. {advent_of_code_data-2.0.3 → advent_of_code_data-2.0.4}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: advent-of-code-data
3
- Version: 2.0.3
3
+ Version: 2.0.4
4
4
  Summary: Get your puzzle data with a single import
5
5
  Author-email: Wim Jeantine-Glenn <hey@wimglenn.com>
6
6
  License: MIT
@@ -44,7 +44,7 @@ data in a string:
44
44
  '1\n2\n3\n7\n11\n13\n17\n19\n23\n31...
45
45
  ```
46
46
 
47
- If you\'d just like to print or keep your own raw input files, there\'s
47
+ If you'd just like to print or keep your own raw input files, there's
48
48
  a script for that:
49
49
 
50
50
  ``` bash
@@ -109,18 +109,17 @@ export AOC_SESSION=cafef00db01dfaceba5eba11deadbeef
109
109
  *Note:* Windows users should use `set` instead of `export` here.
110
110
 
111
111
  The session ID is a cookie which is set when you login to AoC. You can
112
- find it with your browser inspector. If you\'re hacking on AoC at all
112
+ find it with your browser inspector. If you're hacking on AoC at all
113
113
  you probably already know these kind of tricks, but if you need help
114
- with that part then you can [look
115
- here](https://github.com/wimglenn/advent-of-code/issues/1).
114
+ with that part then you can [look here](https://github.com/wimglenn/advent-of-code/issues/1).
116
115
 
117
- *Note:* If you don\'t like the env var, you could also keep your
116
+ *Note:* If you don't like the env var, you could also keep your
118
117
  token(s) in files. By default the location is `~/.config/aocd/token`.
119
118
  Set the `AOCD_DIR` environment variable to some existing directory if
120
119
  you wish to use another location to store token(s).
121
120
 
122
- *New in version 0.9.0.* There\'s a utility script `aocd-token` which
123
- attempts to find session tokens from your browser\'s cookie storage.
121
+ *New in version 0.9.0.* There's a utility script `aocd-token` which
122
+ attempts to find session tokens from your browser's cookie storage.
124
123
  This feature is experimental and requires you to additionally install
125
124
  the package `browser-cookie3`. Only Chrome, Firefox, and Edge browsers
126
125
  are currently supported. On macOS, you may get an authentication dialog
@@ -145,7 +144,7 @@ submit(my_answer, part="a", day=25, year=2017)
145
144
  ```
146
145
 
147
146
  Note that the same filename introspection of year/day also works for
148
- automated submission. There\'s also introspection of the \"level\", i.e.
147
+ automated submission. There's also introspection of the "level", i.e.
149
148
  part a or part b, aocd can automatically determine if you have already
150
149
  completed part a or not and submit your answer for the correct part
151
150
  accordingly. In this case, just use:
@@ -159,14 +158,14 @@ The response message from AoC will be printed in the terminal. If you
159
158
  gave the right answer, then the puzzle will be refreshed in your web
160
159
  browser (so you can read the instructions for the next part, for
161
160
  example). **Proceed with caution!** If you submit wrong guesses, your
162
- user **WILL** get rate-limited by Eric, so don\'t call submit until
163
- you\'re fairly confident you have a correct answer!
161
+ user **WILL** get rate-limited by Eric, so don't call submit until
162
+ you're fairly confident you have a correct answer!
164
163
 
165
164
  *New in version 2.0.0*: Prevent submission of an answer when it is
166
165
  certain the value is incorrect. For example, if the server previously
167
- told you that your answer \"1234\" was too high, then aocd will remember
166
+ told you that your answer "1234" was too high, then aocd will remember
168
167
  this info and prevent you from subsequently submitting an even higher
169
- value such as \"1300\".
168
+ value such as "1300".
170
169
 
171
170
  ## Models
172
171
 
@@ -197,15 +196,15 @@ aocd will not submit that answer again. You've previously guessed 299 and the se
197
196
  That's not the right answer; your answer is too high. If you're stuck, there are some general tips on the about page, or you can ask for hints on the subreddit. Please wait one minute before trying again. (You guessed 299.) [Return to Day 20]
198
197
  ```
199
198
 
199
+ *New in version 2.0.4:* Added convenience `from aocd import puzzle`,
200
+ to return a `Puzzle` instance bound to the auto-detected day/year/user.
201
+
200
202
  Your own solutions can be executed by writing and using an
201
203
  [entry-point](https://packaging.python.org/specifications/entry-points/)
202
204
  into your code, registered in the group `"adventofcode.user"`. Your
203
205
  entry-point should resolve to a callable, and it will be called with
204
- three keyword arguments: `year`, `day`, and `data`. For example, [my
205
- entry-point is called
206
- \"wim\"](https://github.com/wimglenn/advent-of-code-wim/blob/d033366c16fba50e413f2fa7df32e8a0eac9542f/setup.py#L36)
207
- and running against [my
208
- code](https://github.com/wimglenn/advent-of-code-wim/blob/main/aoc_wim/__init__.py)
206
+ three keyword arguments: `year`, `day`, and `data`. For example, [my entry-point is called "wim"](https://github.com/wimglenn/advent-of-code-wim/blob/d033366c16fba50e413f2fa7df32e8a0eac9542f/setup.py#L36)
207
+ and running against [my code](https://github.com/wimglenn/advent-of-code-wim/blob/main/aoc_wim/__init__.py)
209
208
  (after `pip install advent-of-code-wim`) would be like this:
210
209
 
211
210
  ``` python
@@ -214,7 +213,7 @@ code](https://github.com/wimglenn/advent-of-code-wim/blob/main/aoc_wim/__init__.
214
213
  ('XLZAKBGZ', '10656')
215
214
  ```
216
215
 
217
- If you\'ve never written a plugin before, see
216
+ If you've never written a plugin before, see
218
217
  <https://entrypoints.readthedocs.io/> for more info about plugin systems
219
218
  based on Python entry-points.
220
219
 
@@ -222,8 +221,8 @@ based on Python entry-points.
222
221
 
223
222
  *New in version 0.8.0.*
224
223
 
225
- Ever tried running your code against other people\'s inputs? AoC is full
226
- of tricky edge cases. You may find that sometimes you\'re only getting
224
+ Ever tried running your code against other people's inputs? AoC is full
225
+ of tricky edge cases. You may find that sometimes you're only getting
227
226
  the right answer by luck, and your code will fail on some other dataset.
228
227
  Using aocd, you can collect a few different auth tokens for each of your
229
228
  accounts (github/google/reddit/twitter) and verify your answers across
@@ -240,7 +239,7 @@ the `aoc` console script:
240
239
  As you can see above, I actually had incorrect code for [2017 Day 20:
241
240
  Particle Swarm](https://adventofcode.com/2017/day/20), but that
242
241
  [bug](https://github.com/wimglenn/advent-of-code-wim/commit/31e454270001c6d06b46014fe5dafd03e29507b8)
243
- only showed up for the google token\'s dataset. Whoops. Also, it looks
242
+ only showed up for the google token's dataset. Whoops. Also, it looks
244
243
  like my algorithm for [2017 Day 13: Packet
245
244
  Scanners](https://adventofcode.com/2017/day/13) was kinda garbage. Too
246
245
  slow. According to [AoC FAQ](https://adventofcode.com/about):
@@ -253,7 +252,7 @@ By the way, the `aoc` runner will kill your code if it takes more than
253
252
  option, e.g. `--timeout=120`.
254
253
 
255
254
  *New in version 1.1.0:* Added option `--quiet` to suppress any output
256
- from plugins so it doesn\'t mess up the `aoc` runner\'s display.
255
+ from plugins so it doesn't mess up the `aoc` runner's display.
257
256
 
258
257
  *New in version 2.0.0:* You can verify your code against the example
259
258
  input data and answers, scraped from puzzle pages where available, using
@@ -262,7 +261,7 @@ instead of passing the full user input data.
262
261
 
263
262
  ## How does this library work?
264
263
 
265
- It will automatically get today\'s data at import time, if used within
264
+ It will automatically get today's data at import time, if used within
266
265
  the interactive interpreter. Otherwise, the date is found by
267
266
  introspection of the path and file name from which `aocd` module was
268
267
  imported.
@@ -277,8 +276,8 @@ xmas_problem_2016_25b_dawg.py
277
276
  ~/src/aoc/2015/p8.py
278
277
  ```
279
278
 
280
- A filename like `problem_one.py` will not work, so don\'t do that. If
281
- you don\'t like weird frame hacks, just use the `aocd.get_data()`
279
+ A filename like `problem_one.py` will not work, so don't do that. If
280
+ you don't like weird frame hacks, just use the `aocd.get_data()`
282
281
  function instead and have a nice day!
283
282
 
284
283
  ## Cache invalidation?
@@ -287,7 +286,7 @@ function instead and have a nice day!
287
286
  avoid hitting the AoC servers any more often than strictly necessary
288
287
  (this also speeds things up). All data is persisted in plain text files
289
288
  under `~/.config/aocd`. To remove any caches, you may simply delete
290
- whatever files you want under that directory tree. If you\'d prefer to
289
+ whatever files you want under that directory tree. If you'd prefer to
291
290
  use a different path, then export an `AOCD_DIR` environment variable
292
291
  with the desired location.
293
292
 
@@ -20,7 +20,7 @@ data in a string:
20
20
  '1\n2\n3\n7\n11\n13\n17\n19\n23\n31...
21
21
  ```
22
22
 
23
- If you\'d just like to print or keep your own raw input files, there\'s
23
+ If you'd just like to print or keep your own raw input files, there's
24
24
  a script for that:
25
25
 
26
26
  ``` bash
@@ -85,18 +85,17 @@ export AOC_SESSION=cafef00db01dfaceba5eba11deadbeef
85
85
  *Note:* Windows users should use `set` instead of `export` here.
86
86
 
87
87
  The session ID is a cookie which is set when you login to AoC. You can
88
- find it with your browser inspector. If you\'re hacking on AoC at all
88
+ find it with your browser inspector. If you're hacking on AoC at all
89
89
  you probably already know these kind of tricks, but if you need help
90
- with that part then you can [look
91
- here](https://github.com/wimglenn/advent-of-code/issues/1).
90
+ with that part then you can [look here](https://github.com/wimglenn/advent-of-code/issues/1).
92
91
 
93
- *Note:* If you don\'t like the env var, you could also keep your
92
+ *Note:* If you don't like the env var, you could also keep your
94
93
  token(s) in files. By default the location is `~/.config/aocd/token`.
95
94
  Set the `AOCD_DIR` environment variable to some existing directory if
96
95
  you wish to use another location to store token(s).
97
96
 
98
- *New in version 0.9.0.* There\'s a utility script `aocd-token` which
99
- attempts to find session tokens from your browser\'s cookie storage.
97
+ *New in version 0.9.0.* There's a utility script `aocd-token` which
98
+ attempts to find session tokens from your browser's cookie storage.
100
99
  This feature is experimental and requires you to additionally install
101
100
  the package `browser-cookie3`. Only Chrome, Firefox, and Edge browsers
102
101
  are currently supported. On macOS, you may get an authentication dialog
@@ -121,7 +120,7 @@ submit(my_answer, part="a", day=25, year=2017)
121
120
  ```
122
121
 
123
122
  Note that the same filename introspection of year/day also works for
124
- automated submission. There\'s also introspection of the \"level\", i.e.
123
+ automated submission. There's also introspection of the "level", i.e.
125
124
  part a or part b, aocd can automatically determine if you have already
126
125
  completed part a or not and submit your answer for the correct part
127
126
  accordingly. In this case, just use:
@@ -135,14 +134,14 @@ The response message from AoC will be printed in the terminal. If you
135
134
  gave the right answer, then the puzzle will be refreshed in your web
136
135
  browser (so you can read the instructions for the next part, for
137
136
  example). **Proceed with caution!** If you submit wrong guesses, your
138
- user **WILL** get rate-limited by Eric, so don\'t call submit until
139
- you\'re fairly confident you have a correct answer!
137
+ user **WILL** get rate-limited by Eric, so don't call submit until
138
+ you're fairly confident you have a correct answer!
140
139
 
141
140
  *New in version 2.0.0*: Prevent submission of an answer when it is
142
141
  certain the value is incorrect. For example, if the server previously
143
- told you that your answer \"1234\" was too high, then aocd will remember
142
+ told you that your answer "1234" was too high, then aocd will remember
144
143
  this info and prevent you from subsequently submitting an even higher
145
- value such as \"1300\".
144
+ value such as "1300".
146
145
 
147
146
  ## Models
148
147
 
@@ -173,15 +172,15 @@ aocd will not submit that answer again. You've previously guessed 299 and the se
173
172
  That's not the right answer; your answer is too high. If you're stuck, there are some general tips on the about page, or you can ask for hints on the subreddit. Please wait one minute before trying again. (You guessed 299.) [Return to Day 20]
174
173
  ```
175
174
 
175
+ *New in version 2.0.4:* Added convenience `from aocd import puzzle`,
176
+ to return a `Puzzle` instance bound to the auto-detected day/year/user.
177
+
176
178
  Your own solutions can be executed by writing and using an
177
179
  [entry-point](https://packaging.python.org/specifications/entry-points/)
178
180
  into your code, registered in the group `"adventofcode.user"`. Your
179
181
  entry-point should resolve to a callable, and it will be called with
180
- three keyword arguments: `year`, `day`, and `data`. For example, [my
181
- entry-point is called
182
- \"wim\"](https://github.com/wimglenn/advent-of-code-wim/blob/d033366c16fba50e413f2fa7df32e8a0eac9542f/setup.py#L36)
183
- and running against [my
184
- code](https://github.com/wimglenn/advent-of-code-wim/blob/main/aoc_wim/__init__.py)
182
+ three keyword arguments: `year`, `day`, and `data`. For example, [my entry-point is called "wim"](https://github.com/wimglenn/advent-of-code-wim/blob/d033366c16fba50e413f2fa7df32e8a0eac9542f/setup.py#L36)
183
+ and running against [my code](https://github.com/wimglenn/advent-of-code-wim/blob/main/aoc_wim/__init__.py)
185
184
  (after `pip install advent-of-code-wim`) would be like this:
186
185
 
187
186
  ``` python
@@ -190,7 +189,7 @@ code](https://github.com/wimglenn/advent-of-code-wim/blob/main/aoc_wim/__init__.
190
189
  ('XLZAKBGZ', '10656')
191
190
  ```
192
191
 
193
- If you\'ve never written a plugin before, see
192
+ If you've never written a plugin before, see
194
193
  <https://entrypoints.readthedocs.io/> for more info about plugin systems
195
194
  based on Python entry-points.
196
195
 
@@ -198,8 +197,8 @@ based on Python entry-points.
198
197
 
199
198
  *New in version 0.8.0.*
200
199
 
201
- Ever tried running your code against other people\'s inputs? AoC is full
202
- of tricky edge cases. You may find that sometimes you\'re only getting
200
+ Ever tried running your code against other people's inputs? AoC is full
201
+ of tricky edge cases. You may find that sometimes you're only getting
203
202
  the right answer by luck, and your code will fail on some other dataset.
204
203
  Using aocd, you can collect a few different auth tokens for each of your
205
204
  accounts (github/google/reddit/twitter) and verify your answers across
@@ -216,7 +215,7 @@ the `aoc` console script:
216
215
  As you can see above, I actually had incorrect code for [2017 Day 20:
217
216
  Particle Swarm](https://adventofcode.com/2017/day/20), but that
218
217
  [bug](https://github.com/wimglenn/advent-of-code-wim/commit/31e454270001c6d06b46014fe5dafd03e29507b8)
219
- only showed up for the google token\'s dataset. Whoops. Also, it looks
218
+ only showed up for the google token's dataset. Whoops. Also, it looks
220
219
  like my algorithm for [2017 Day 13: Packet
221
220
  Scanners](https://adventofcode.com/2017/day/13) was kinda garbage. Too
222
221
  slow. According to [AoC FAQ](https://adventofcode.com/about):
@@ -229,7 +228,7 @@ By the way, the `aoc` runner will kill your code if it takes more than
229
228
  option, e.g. `--timeout=120`.
230
229
 
231
230
  *New in version 1.1.0:* Added option `--quiet` to suppress any output
232
- from plugins so it doesn\'t mess up the `aoc` runner\'s display.
231
+ from plugins so it doesn't mess up the `aoc` runner's display.
233
232
 
234
233
  *New in version 2.0.0:* You can verify your code against the example
235
234
  input data and answers, scraped from puzzle pages where available, using
@@ -238,7 +237,7 @@ instead of passing the full user input data.
238
237
 
239
238
  ## How does this library work?
240
239
 
241
- It will automatically get today\'s data at import time, if used within
240
+ It will automatically get today's data at import time, if used within
242
241
  the interactive interpreter. Otherwise, the date is found by
243
242
  introspection of the path and file name from which `aocd` module was
244
243
  imported.
@@ -253,8 +252,8 @@ xmas_problem_2016_25b_dawg.py
253
252
  ~/src/aoc/2015/p8.py
254
253
  ```
255
254
 
256
- A filename like `problem_one.py` will not work, so don\'t do that. If
257
- you don\'t like weird frame hacks, just use the `aocd.get_data()`
255
+ A filename like `problem_one.py` will not work, so don't do that. If
256
+ you don't like weird frame hacks, just use the `aocd.get_data()`
258
257
  function instead and have a nice day!
259
258
 
260
259
  ## Cache invalidation?
@@ -263,7 +262,7 @@ function instead and have a nice day!
263
262
  avoid hitting the AoC servers any more often than strictly necessary
264
263
  (this also speeds things up). All data is persisted in plain text files
265
264
  under `~/.config/aocd`. To remove any caches, you may simply delete
266
- whatever files you want under that directory tree. If you\'d prefer to
265
+ whatever files you want under that directory tree. If you'd prefer to
267
266
  use a different path, then export an `AOCD_DIR` environment variable
268
267
  with the desired location.
269
268
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: advent-of-code-data
3
- Version: 2.0.3
3
+ Version: 2.0.4
4
4
  Summary: Get your puzzle data with a single import
5
5
  Author-email: Wim Jeantine-Glenn <hey@wimglenn.com>
6
6
  License: MIT
@@ -44,7 +44,7 @@ data in a string:
44
44
  '1\n2\n3\n7\n11\n13\n17\n19\n23\n31...
45
45
  ```
46
46
 
47
- If you\'d just like to print or keep your own raw input files, there\'s
47
+ If you'd just like to print or keep your own raw input files, there's
48
48
  a script for that:
49
49
 
50
50
  ``` bash
@@ -109,18 +109,17 @@ export AOC_SESSION=cafef00db01dfaceba5eba11deadbeef
109
109
  *Note:* Windows users should use `set` instead of `export` here.
110
110
 
111
111
  The session ID is a cookie which is set when you login to AoC. You can
112
- find it with your browser inspector. If you\'re hacking on AoC at all
112
+ find it with your browser inspector. If you're hacking on AoC at all
113
113
  you probably already know these kind of tricks, but if you need help
114
- with that part then you can [look
115
- here](https://github.com/wimglenn/advent-of-code/issues/1).
114
+ with that part then you can [look here](https://github.com/wimglenn/advent-of-code/issues/1).
116
115
 
117
- *Note:* If you don\'t like the env var, you could also keep your
116
+ *Note:* If you don't like the env var, you could also keep your
118
117
  token(s) in files. By default the location is `~/.config/aocd/token`.
119
118
  Set the `AOCD_DIR` environment variable to some existing directory if
120
119
  you wish to use another location to store token(s).
121
120
 
122
- *New in version 0.9.0.* There\'s a utility script `aocd-token` which
123
- attempts to find session tokens from your browser\'s cookie storage.
121
+ *New in version 0.9.0.* There's a utility script `aocd-token` which
122
+ attempts to find session tokens from your browser's cookie storage.
124
123
  This feature is experimental and requires you to additionally install
125
124
  the package `browser-cookie3`. Only Chrome, Firefox, and Edge browsers
126
125
  are currently supported. On macOS, you may get an authentication dialog
@@ -145,7 +144,7 @@ submit(my_answer, part="a", day=25, year=2017)
145
144
  ```
146
145
 
147
146
  Note that the same filename introspection of year/day also works for
148
- automated submission. There\'s also introspection of the \"level\", i.e.
147
+ automated submission. There's also introspection of the "level", i.e.
149
148
  part a or part b, aocd can automatically determine if you have already
150
149
  completed part a or not and submit your answer for the correct part
151
150
  accordingly. In this case, just use:
@@ -159,14 +158,14 @@ The response message from AoC will be printed in the terminal. If you
159
158
  gave the right answer, then the puzzle will be refreshed in your web
160
159
  browser (so you can read the instructions for the next part, for
161
160
  example). **Proceed with caution!** If you submit wrong guesses, your
162
- user **WILL** get rate-limited by Eric, so don\'t call submit until
163
- you\'re fairly confident you have a correct answer!
161
+ user **WILL** get rate-limited by Eric, so don't call submit until
162
+ you're fairly confident you have a correct answer!
164
163
 
165
164
  *New in version 2.0.0*: Prevent submission of an answer when it is
166
165
  certain the value is incorrect. For example, if the server previously
167
- told you that your answer \"1234\" was too high, then aocd will remember
166
+ told you that your answer "1234" was too high, then aocd will remember
168
167
  this info and prevent you from subsequently submitting an even higher
169
- value such as \"1300\".
168
+ value such as "1300".
170
169
 
171
170
  ## Models
172
171
 
@@ -197,15 +196,15 @@ aocd will not submit that answer again. You've previously guessed 299 and the se
197
196
  That's not the right answer; your answer is too high. If you're stuck, there are some general tips on the about page, or you can ask for hints on the subreddit. Please wait one minute before trying again. (You guessed 299.) [Return to Day 20]
198
197
  ```
199
198
 
199
+ *New in version 2.0.4:* Added convenience `from aocd import puzzle`,
200
+ to return a `Puzzle` instance bound to the auto-detected day/year/user.
201
+
200
202
  Your own solutions can be executed by writing and using an
201
203
  [entry-point](https://packaging.python.org/specifications/entry-points/)
202
204
  into your code, registered in the group `"adventofcode.user"`. Your
203
205
  entry-point should resolve to a callable, and it will be called with
204
- three keyword arguments: `year`, `day`, and `data`. For example, [my
205
- entry-point is called
206
- \"wim\"](https://github.com/wimglenn/advent-of-code-wim/blob/d033366c16fba50e413f2fa7df32e8a0eac9542f/setup.py#L36)
207
- and running against [my
208
- code](https://github.com/wimglenn/advent-of-code-wim/blob/main/aoc_wim/__init__.py)
206
+ three keyword arguments: `year`, `day`, and `data`. For example, [my entry-point is called "wim"](https://github.com/wimglenn/advent-of-code-wim/blob/d033366c16fba50e413f2fa7df32e8a0eac9542f/setup.py#L36)
207
+ and running against [my code](https://github.com/wimglenn/advent-of-code-wim/blob/main/aoc_wim/__init__.py)
209
208
  (after `pip install advent-of-code-wim`) would be like this:
210
209
 
211
210
  ``` python
@@ -214,7 +213,7 @@ code](https://github.com/wimglenn/advent-of-code-wim/blob/main/aoc_wim/__init__.
214
213
  ('XLZAKBGZ', '10656')
215
214
  ```
216
215
 
217
- If you\'ve never written a plugin before, see
216
+ If you've never written a plugin before, see
218
217
  <https://entrypoints.readthedocs.io/> for more info about plugin systems
219
218
  based on Python entry-points.
220
219
 
@@ -222,8 +221,8 @@ based on Python entry-points.
222
221
 
223
222
  *New in version 0.8.0.*
224
223
 
225
- Ever tried running your code against other people\'s inputs? AoC is full
226
- of tricky edge cases. You may find that sometimes you\'re only getting
224
+ Ever tried running your code against other people's inputs? AoC is full
225
+ of tricky edge cases. You may find that sometimes you're only getting
227
226
  the right answer by luck, and your code will fail on some other dataset.
228
227
  Using aocd, you can collect a few different auth tokens for each of your
229
228
  accounts (github/google/reddit/twitter) and verify your answers across
@@ -240,7 +239,7 @@ the `aoc` console script:
240
239
  As you can see above, I actually had incorrect code for [2017 Day 20:
241
240
  Particle Swarm](https://adventofcode.com/2017/day/20), but that
242
241
  [bug](https://github.com/wimglenn/advent-of-code-wim/commit/31e454270001c6d06b46014fe5dafd03e29507b8)
243
- only showed up for the google token\'s dataset. Whoops. Also, it looks
242
+ only showed up for the google token's dataset. Whoops. Also, it looks
244
243
  like my algorithm for [2017 Day 13: Packet
245
244
  Scanners](https://adventofcode.com/2017/day/13) was kinda garbage. Too
246
245
  slow. According to [AoC FAQ](https://adventofcode.com/about):
@@ -253,7 +252,7 @@ By the way, the `aoc` runner will kill your code if it takes more than
253
252
  option, e.g. `--timeout=120`.
254
253
 
255
254
  *New in version 1.1.0:* Added option `--quiet` to suppress any output
256
- from plugins so it doesn\'t mess up the `aoc` runner\'s display.
255
+ from plugins so it doesn't mess up the `aoc` runner's display.
257
256
 
258
257
  *New in version 2.0.0:* You can verify your code against the example
259
258
  input data and answers, scraped from puzzle pages where available, using
@@ -262,7 +261,7 @@ instead of passing the full user input data.
262
261
 
263
262
  ## How does this library work?
264
263
 
265
- It will automatically get today\'s data at import time, if used within
264
+ It will automatically get today's data at import time, if used within
266
265
  the interactive interpreter. Otherwise, the date is found by
267
266
  introspection of the path and file name from which `aocd` module was
268
267
  imported.
@@ -277,8 +276,8 @@ xmas_problem_2016_25b_dawg.py
277
276
  ~/src/aoc/2015/p8.py
278
277
  ```
279
278
 
280
- A filename like `problem_one.py` will not work, so don\'t do that. If
281
- you don\'t like weird frame hacks, just use the `aocd.get_data()`
279
+ A filename like `problem_one.py` will not work, so don't do that. If
280
+ you don't like weird frame hacks, just use the `aocd.get_data()`
282
281
  function instead and have a nice day!
283
282
 
284
283
  ## Cache invalidation?
@@ -287,7 +286,7 @@ function instead and have a nice day!
287
286
  avoid hitting the AoC servers any more often than strictly necessary
288
287
  (this also speeds things up). All data is persisted in plain text files
289
288
  under `~/.config/aocd`. To remove any caches, you may simply delete
290
- whatever files you want under that directory tree. If you\'d prefer to
289
+ whatever files you want under that directory tree. If you'd prefer to
291
290
  use a different path, then export an `AOCD_DIR` environment variable
292
291
  with the desired location.
293
292
 
@@ -15,6 +15,7 @@ from . import types
15
15
  from . import utils
16
16
  from .exceptions import AocdError
17
17
  from .get import get_data
18
+ from .get import get_puzzle
18
19
  from .get import get_day_and_year
19
20
  from .post import submit as _impartial_submit
20
21
 
@@ -29,6 +30,7 @@ __all__ = [
29
30
  "get_data",
30
31
  "models",
31
32
  "post",
33
+ "puzzle",
32
34
  "runner",
33
35
  "submit",
34
36
  "types",
@@ -37,6 +39,7 @@ __all__ = [
37
39
 
38
40
  if t.TYPE_CHECKING:
39
41
  data: str
42
+ puzzle: models.Puzzle
40
43
  submit = _impartial_submit
41
44
 
42
45
 
@@ -44,6 +47,9 @@ def __getattr__(name: str) -> t.Any:
44
47
  if name == "data":
45
48
  day, year = get_day_and_year()
46
49
  return get_data(day=day, year=year)
50
+ if name == "puzzle":
51
+ day, year = get_day_and_year()
52
+ return get_puzzle(day=day, year=year)
47
53
  if name == "submit":
48
54
  try:
49
55
  day, year = get_day_and_year()
@@ -4,7 +4,6 @@ import datetime
4
4
  import os
5
5
  import re
6
6
  import traceback
7
- import typing as t
8
7
  from logging import getLogger
9
8
  from logging import Logger
10
9
 
@@ -33,6 +32,22 @@ def get_data(
33
32
  If `block` is True and the puzzle is still locked, will wait until unlock
34
33
  before returning data.
35
34
  """
35
+ puzzle = get_puzzle(session, day, year, block)
36
+ return puzzle.input_data
37
+
38
+
39
+ def get_puzzle(
40
+ session: str | None = None,
41
+ day: int | None = None,
42
+ year: int | None = None,
43
+ block: bool = False,
44
+ ) -> Puzzle:
45
+ """
46
+ Get puzzle for day (1-25) and year (2015+).
47
+ User's session cookie (str) is needed - puzzle inputs differ by user.
48
+ If `block` is True and the puzzle is still locked, will wait until unlock
49
+ before returning puzzle.
50
+ """
36
51
  if session is None:
37
52
  user = default_user()
38
53
  else:
@@ -45,13 +60,15 @@ def get_data(
45
60
  log.info("most recent year=%s", year)
46
61
  puzzle = Puzzle(year=year, day=day, user=user)
47
62
  try:
48
- return puzzle.input_data
63
+ puzzle.input_data
49
64
  except PuzzleLockedError:
50
65
  if not block:
51
66
  raise
52
67
  q = block == "q"
53
68
  blocker(quiet=q, until=(year, day))
54
- return puzzle.input_data
69
+ return puzzle
70
+ else:
71
+ return puzzle
55
72
 
56
73
 
57
74
  def most_recent_year() -> int:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "advent-of-code-data"
7
- version = "2.0.3"
7
+ version = "2.0.4"
8
8
  description = "Get your puzzle data with a single import"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -52,3 +52,14 @@ def test_data_in_interactive_mode(monkeypatch, mocker, freezer):
52
52
  def test_attribute_errors_have_context():
53
53
  with pytest.raises(AttributeError("module 'aocd' has no attribute 'nope'")):
54
54
  aocd.nope
55
+
56
+
57
+ def test_import_puzzle(mocker):
58
+ fake_stack = [("~/2023/q21.py", 1, "<test>", "from aocd import data")]
59
+ mocker.patch("aocd.get.traceback.extract_stack", return_value=fake_stack)
60
+ mocker.patch("aocd.models.Puzzle.input_data", "test puzzle")
61
+ from aocd import puzzle
62
+
63
+ assert puzzle.year == 2023
64
+ assert puzzle.day == 21
65
+ assert puzzle.input_data == "test puzzle"