Skip to content

Commit 23db332

Browse files
author
Saurav Sharma
committed
refactor: use latest maintain dependency
Signed-off-by: Saurav Sharma <[email protected]>
1 parent 87234dc commit 23db332

File tree

8 files changed

+224
-257
lines changed

8 files changed

+224
-257
lines changed

.github/workflows/release_note.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v3
13-
with:
14-
fetch-depth: 0
15-
- name: Generate a changelog
16-
uses: orhun/git-cliff-action@v1
17-
id: git-cliff
18-
with:
19-
config: cliff.toml
20-
args: -vv --current --strip header
21-
env:
22-
OUTPUT: CHANGELOG.md
23-
- name: Create GitHub release
24-
uses: softprops/action-gh-release@v1
25-
with:
26-
body_path: ${{ steps.git-cliff.outputs.changelog }}
27-
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
- name: Generate a changelog
16+
uses: orhun/git-cliff-action@v1
17+
id: git-cliff
18+
with:
19+
config: cliff.toml
20+
args: -vv --current --strip header
21+
env:
22+
OUTPUT: CHANGELOG.md
23+
- name: Create GitHub release
24+
uses: softprops/action-gh-release@v1
25+
with:
26+
body_path: ${{ steps.git-cliff.outputs.changelog }}
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
11
# Advent-of-code-py
2+
23
[Advent of Code][advent_of_code_link] helper CLI and library for python projects.
34

45
**Status & Info:**
56

6-
| Code style | License | Project Version |
7-
| :---: | :---: | :---: |
7+
| Code style | License | Project Version |
8+
| :--------------------------------------: | :--------------------------------------------: | :------------------------------------: |
89
| [![Code style][black_badge]][black_link] | [![License: MIT][license_badge]][license_link] | [![PyPI][project_badge]][project_link] |
910

1011
## Usage
1112

1213
### Installation
14+
1315
To install advent-of-code-py run following command which installs advent-of-code-py CLI and advent_of_code_py library.
16+
1417
```bash
1518
pip install advent-of-code-py
1619
```
1720

18-
__OR__
21+
**OR**
1922

2023
```bash
2124
poetry add advent-of-code-py
2225
```
2326

2427
### Usage
28+
2529
Initially for advent-of-code-py to work it need session value or session ID which you can obtain by viewing cookie while visiting advent of code server.
2630
After collecting session cookie value you need to add those values in config using advent-of-code-py CLI
31+
2732
```bash
2833
advent-of-code-py config add <session-name> <session-value>
2934
```
3035

3136
Now you can import library by using
37+
3238
```python
3339
import advent_of_code_py
3440
```
3541

3642
After importing a library you can use either two decorator present which are solve and submit decorator for a function of puzzle
3743

3844
For example:-
45+
3946
```python
4047
@advent_of_code_py.submit(2018,3,1,session_list="<session-name>")
4148
def puzzle_2018_3_1(input=None):
@@ -44,16 +51,19 @@ def puzzle_2018_3_1(input=None):
4451
```
4552

4653
Now after decorating function now you can call function like regular function call
54+
4755
```python
4856
puzzle_2018_3_1()
4957
```
58+
5059
After calling function `final_output` value will be submitted by library to Advent of Code server for 2018 year day 3
5160
problem, then returns whether the submitted answer was correct or not. If session value is not provided then
5261
the solution will be submitted to all session value present in config file.
5362

5463
You can also use advent-of-code-py builtin Initializer and runner to create appropriate CLI for problem so
5564
problem can be run from CLI instead of modifying python file every time to run appropriate function
5665
To set advent-of-code-py puzzle as CLI
66+
5767
```python
5868
@advent_of_code_py.advent_runner()
5969
def main_cli():
@@ -64,18 +74,16 @@ def main_cli():
6474
# add other functions ...
6575
return initializer
6676
```
77+
6778
Now you can set main_cli as entry points, and it will create CLI with the appropriate name and function which was added.
6879
So for example to run function puzzle_2018_3_1() you have to run command as `entry-point-name run p_3_1` which
6980
will run the appropriate function as well as submit as desired if the function was decorated by submit decorator or else
7081
prints its output if the function was decorated by solve decorator.
7182

7283
[advent_of_code_link]: https://adventofcode.com
73-
7484
[black_badge]: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge
7585
[black_link]: https://github.com/ambv/black
76-
7786
[license_badge]: https://img.shields.io/github/license/iamsauravsharma/advent-of-code-py.svg?style=for-the-badge
7887
[license_link]: LICENSE
79-
8088
[project_badge]: https://img.shields.io/pypi/v/advent-of-code-py?style=for-the-badge&color=blue&logo=python
8189
[project_link]: https://pypi.org/project/advent-of-code-py

advent_of_code_py/cache_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pathlib import Path
66
from typing import Optional
77

8-
import appdirs
8+
from platformdirs import user_cache_dir
99

1010

1111
def input_data_is_downloaded(year: int, day: int, session: str) -> bool:
@@ -93,7 +93,7 @@ def _join_path(
9393
year: int, day: int, session: str, file_type: Optional[str] = None
9494
) -> str:
9595
"""Return desire path for a cache folders or files"""
96-
cache_location = appdirs.user_cache_dir(appname="advent-of-code")
96+
cache_location = user_cache_dir(appname="advent-of-code")
9797
cache_file = os.path.join(cache_location, str(session), str(year), str(day))
9898
if file_type == "input_file":
9999
cache_file = os.path.join(cache_file, "input.txt")

advent_of_code_py/config_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55
from typing import List
66

7-
import appdirs
7+
from platformdirs import user_config_dir
88

99

1010
class Data:
@@ -51,7 +51,7 @@ def _read_json_file(config_file: str) -> Data:
5151

5252
def _config_file_data() -> str:
5353
"""Get Config file location"""
54-
config_location = appdirs.user_config_dir()
54+
config_location = user_config_dir()
5555
config_file = os.path.join(config_location, "aoc-config.json")
5656
config_file = Path(config_file)
5757
return config_file

advent_of_code_py/initializer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def run_all(self):
4141

4242
def list_functions(self):
4343
"""List all of the function and its alias"""
44-
for (keys, value) in self.function_list.items():
44+
for keys, value in self.function_list.items():
4545
print(
4646
"{:10} -> {}.{}".format(
4747
keys, inspect.getmodule(value.get_function()).__name__, value

advent_of_code_py/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""utility module used to find latest year and day for advent of code problems"""
22
import datetime
33

4-
from dateutil.tz import gettz
4+
from pytz import timezone
55

6-
EASTERN = gettz("America/New_York")
6+
EASTERN = timezone("US/Eastern")
77

88

99
def get_current_year() -> int:

0 commit comments

Comments
 (0)