Skip to content

Commit f18fba4

Browse files
feat: add user agent to github repo link
Signed-off-by: Saurav Sharma <[email protected]>
1 parent bea8f72 commit f18fba4

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
**Status & Info:**
66

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

1111
## Usage
1212

@@ -44,7 +44,7 @@ After importing a library you can use either two decorator present which are sol
4444
For example:-
4545

4646
```python
47-
@advent_of_code_py.submit(2018,3,1,session_list="<session-name>")
47+
@advent_of_code_py.submit(2018, 3, 1, session_list=["<session-name>"])
4848
def puzzle_2018_3_1(input=None):
4949
# do some calculation with data and return final output
5050
return final_output
@@ -81,8 +81,6 @@ will run the appropriate function as well as submit as desired if the function w
8181
prints its output if the function was decorated by solve decorator.
8282

8383
[advent_of_code_link]: https://adventofcode.com
84-
[black_badge]: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge
85-
[black_link]: https://github.com/ambv/black
8684
[license_badge]: https://img.shields.io/github/license/iamsauravsharma/advent-of-code-py.svg?style=for-the-badge
8785
[license_link]: LICENSE
8886
[project_badge]: https://img.shields.io/pypi/v/advent-of-code-py?style=for-the-badge&color=blue&logo=python

advent_of_code_py/puzzle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __call__(self, input: Optional[str] = None):
5151
for session in self.sessions:
5252
if input is None:
5353
input = get_cache_file_data(self.year, self.day, session)
54-
answer = self.function(input)
54+
answer = str(self.function(input))
5555
if answer is not None:
5656
if self.operation_type == OperationType.SUBMIT:
5757
message = submit_output(
@@ -96,7 +96,7 @@ def submit(
9696
session_list: Optional[List[str]] = None,
9797
):
9898
"""
99-
Puzzle decorator used to submit a solution to advent_of_code server and provide
99+
Puzzle decorator used to submit a solution to advent of code server and provide
100100
result. If input_file is not present then it tries to download file and cache it
101101
for submitting solution else it require to be provided with input_file path which
102102
input it can use.

advent_of_code_py/server_action.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ def download_input(year: int, day: int, session: str):
2121
session_value = get_session_value(session)
2222
if not input_data_is_downloaded(year, day, session):
2323
input_url = INPUT_URL.format(year, day)
24-
html_data = requests.get(input_url, cookies={"session": session_value})
24+
html_data = requests.get(
25+
input_url,
26+
cookies={"session": session_value},
27+
headers={"User-Agent": "github.com/iamsauravsharma/advent-of-code-py"},
28+
)
2529
save_input_to_cache(year, day, session, html_data.text)
2630

2731

@@ -38,7 +42,10 @@ def submit_output(year: int, day: int, part: int, session: str, output: str) ->
3842
data = {"level": part, "answer": output}
3943
save_last_submission_time(year, day, session)
4044
response = requests.post(
41-
submit_url, data, cookies={"session": session_value}
45+
submit_url,
46+
data,
47+
cookies={"session": session_value},
48+
headers={"User-Agent": "github.com/iamsauravsharma/advent-of-code-py"},
4249
)
4350
if response.status_code != 200:
4451
message = (

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ advent-of-code-py = "advent_of_code_py.cli:main"
3333
dev = ["nox>=2024.10.9", "pytest>=8", "ruff>=0.8.3"]
3434

3535
[tool.ruff.lint]
36-
select = ["I"]
36+
extend-select = ["I"]
3737

3838
[build-system]
3939
requires = ["setuptools>=61"]

0 commit comments

Comments
 (0)