WordleFetch 1.0.0__py3-none-any.whl
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.
- WordleFetch/Cli.py +116 -0
- WordleFetch/Theme.py +7 -0
- WordleFetch/Wordle.py +31 -0
- WordleFetch/__init__.py +3 -0
- wordlefetch-1.0.0.dist-info/METADATA +47 -0
- wordlefetch-1.0.0.dist-info/RECORD +10 -0
- wordlefetch-1.0.0.dist-info/WHEEL +5 -0
- wordlefetch-1.0.0.dist-info/entry_points.txt +2 -0
- wordlefetch-1.0.0.dist-info/licenses/LICENSE +9 -0
- wordlefetch-1.0.0.dist-info/top_level.txt +1 -0
WordleFetch/Cli.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import logging
|
|
3
|
+
import argparse
|
|
4
|
+
import datetime
|
|
5
|
+
from .Theme import *
|
|
6
|
+
from .Wordle import fetch_wordle_data
|
|
7
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
8
|
+
logger = logging.getLogger("WordleFetch")
|
|
9
|
+
|
|
10
|
+
running_as_main = False
|
|
11
|
+
|
|
12
|
+
def main():
|
|
13
|
+
parser = argparse.ArgumentParser(
|
|
14
|
+
description="WordleFetch\nget the answers\nyou want quickly.",
|
|
15
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
16
|
+
prog="wordlefetch"
|
|
17
|
+
)
|
|
18
|
+
display_flags = parser.add_argument_group("Display Flags (can be used more than once!)")
|
|
19
|
+
Configuration_flags = parser.add_argument_group("Advanced configuration flags")
|
|
20
|
+
Misc_Flags = parser.add_argument_group("Miscellaneous flags")
|
|
21
|
+
|
|
22
|
+
Misc_Flags.add_argument(
|
|
23
|
+
"-V", "--version",
|
|
24
|
+
action="store_true",
|
|
25
|
+
help="Shows installed\nWordleFetch package\nversion and exits"
|
|
26
|
+
)
|
|
27
|
+
Configuration_flags.add_argument(
|
|
28
|
+
"-u", "--url",
|
|
29
|
+
action="store",
|
|
30
|
+
help="Allows using a\ndifferent url instead\nof normal url."
|
|
31
|
+
)
|
|
32
|
+
Configuration_flags.add_argument(
|
|
33
|
+
"-d", "--customdate",
|
|
34
|
+
action="store",
|
|
35
|
+
help="Allows using a\ndifferent date instead\nof todays date."
|
|
36
|
+
)
|
|
37
|
+
display_flags.add_argument(
|
|
38
|
+
"-H", "--header",
|
|
39
|
+
action="append_const",
|
|
40
|
+
dest="displayflags",
|
|
41
|
+
const="header",
|
|
42
|
+
help="Adds showing\nthe header"
|
|
43
|
+
)
|
|
44
|
+
display_flags.add_argument(
|
|
45
|
+
"-A", "--answer",
|
|
46
|
+
action="append_const",
|
|
47
|
+
dest="displayflags",
|
|
48
|
+
const="answer",
|
|
49
|
+
help="Adds showing\nthe Wordle answer"
|
|
50
|
+
)
|
|
51
|
+
display_flags.add_argument(
|
|
52
|
+
"-D", "--date-display",
|
|
53
|
+
action="append_const",
|
|
54
|
+
dest="displayflags",
|
|
55
|
+
const="date",
|
|
56
|
+
help="Adds showing\nthe date"
|
|
57
|
+
)
|
|
58
|
+
display_flags.add_argument(
|
|
59
|
+
"-E", "--editor",
|
|
60
|
+
action="append_const",
|
|
61
|
+
dest="displayflags",
|
|
62
|
+
const="editor",
|
|
63
|
+
help="Adds showing\nthe Wordle editor"
|
|
64
|
+
)
|
|
65
|
+
display_flags.add_argument(
|
|
66
|
+
"-I", "--id",
|
|
67
|
+
action="append_const",
|
|
68
|
+
dest="displayflags",
|
|
69
|
+
const="id",
|
|
70
|
+
help="Adds showing\nthe Wordle ID"
|
|
71
|
+
)
|
|
72
|
+
display_flags.add_argument(
|
|
73
|
+
"-L", "--launch",
|
|
74
|
+
action="append_const",
|
|
75
|
+
dest="displayflags",
|
|
76
|
+
const="days_since_launch",
|
|
77
|
+
help="Adds showing\ndays since\nWordle launch"
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
args = parser.parse_args()
|
|
82
|
+
|
|
83
|
+
if args.version:
|
|
84
|
+
try:
|
|
85
|
+
package_version = version('WordleFetch')
|
|
86
|
+
print(package_version)
|
|
87
|
+
sys.exit(0)
|
|
88
|
+
except PackageNotFoundError:
|
|
89
|
+
logger.error(
|
|
90
|
+
"Error: Pip package not found. To resolve this error, "
|
|
91
|
+
"please install the package from PyPI with: "
|
|
92
|
+
"pip install WordleFetch"
|
|
93
|
+
)
|
|
94
|
+
if running_as_main:
|
|
95
|
+
sys.exit(1)
|
|
96
|
+
else:
|
|
97
|
+
pass
|
|
98
|
+
if args.customdate:
|
|
99
|
+
entered_date = datetime.datetime.strptime(args.customdate, "%Y-%m-%d").date()
|
|
100
|
+
else:
|
|
101
|
+
entered_date = datetime.date.today()
|
|
102
|
+
|
|
103
|
+
if args.url:
|
|
104
|
+
entered_url = args.url
|
|
105
|
+
else:
|
|
106
|
+
entered_url = f'https://www.nytimes.com/svc/wordle/v2/{entered_date:%Y-%m-%d}.json'
|
|
107
|
+
|
|
108
|
+
data_fetch = fetch_wordle_data(date=entered_date, url=entered_url)
|
|
109
|
+
|
|
110
|
+
if not args.displayflags:
|
|
111
|
+
args.displayflags = ['header', 'answer', 'date', 'editor']
|
|
112
|
+
for item in args.displayflags:
|
|
113
|
+
print(data_fetch[item])
|
|
114
|
+
if __name__ == "__main__":
|
|
115
|
+
main()
|
|
116
|
+
running_as_main = True
|
WordleFetch/Theme.py
ADDED
WordleFetch/Wordle.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
import json
|
|
3
|
+
import urllib.request
|
|
4
|
+
import logging
|
|
5
|
+
from .Theme import *
|
|
6
|
+
logger = logging.getLogger("WordleFetch")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_wordle_display(data):
|
|
10
|
+
"""Generates the display strings using the fetched JSON data."""
|
|
11
|
+
return {
|
|
12
|
+
"header": f"{COLOR_HEADER}- Todays Wordle -{ANSI_RESET}",
|
|
13
|
+
"answer": f"{COLOR_INFO}Answer {ANSI_RESET}• {COLOR_CONTENT}{data['solution']}{ANSI_RESET}",
|
|
14
|
+
"date": f"{COLOR_INFO}Date {ANSI_RESET}• {COLOR_CONTENT}{data['print_date']}{ANSI_RESET}",
|
|
15
|
+
"editor": f"{COLOR_INFO}Editor {ANSI_RESET}• {COLOR_CONTENT}{data['editor']}{ANSI_RESET}",
|
|
16
|
+
"id": f"{COLOR_INFO}Id{ANSI_RESET} • {COLOR_CONTENT}{data['id']}{ANSI_RESET}",
|
|
17
|
+
"days_since_launch": f"{COLOR_INFO}Days since Wordle #0{ANSI_RESET} • {COLOR_CONTENT}{data['days_since_launch']}{ANSI_RESET}"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
def fetch_wordle_data(date=None, url=None):
|
|
21
|
+
if date is None:
|
|
22
|
+
date = datetime.date.today()
|
|
23
|
+
if url is None:
|
|
24
|
+
url = f"https://www.nytimes.com/svc/wordle/v2/{date:%Y-%m-%d}.json"
|
|
25
|
+
with urllib.request.urlopen(url) as request:
|
|
26
|
+
if request.status == 200:
|
|
27
|
+
JSON = json.loads(request.read().decode('utf-8'))
|
|
28
|
+
return get_wordle_display(JSON)
|
|
29
|
+
else:
|
|
30
|
+
logger.error(f"{COLOR_ERROR}Error, check your connection.{ANSI_RESET}")
|
|
31
|
+
raise Exception("RequestError")
|
WordleFetch/__init__.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: WordleFetch
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Fetch and display Wordle data from the NYT.
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/Ruizennis/WordleFetch
|
|
7
|
+
Project-URL: Issues, https://github.com/Ruizennis/TermuxC/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Topic :: Utilities
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# WordleFetch
|
|
19
|
+
## Get the answers you want
|
|
20
|
+
Output:
|
|
21
|
+
```text
|
|
22
|
+
- Todays Wordle -
|
|
23
|
+
Answer • pshaw
|
|
24
|
+
Date • 2026-07-15
|
|
25
|
+
Editor • Tracy Bennett
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Display Flags
|
|
30
|
+
These flags control which information is displayed in the output and can be used more than once.
|
|
31
|
+
|
|
32
|
+
| Flag | Long Form | Description |
|
|
33
|
+
| :--- | :--- | :--- |
|
|
34
|
+
| -H | --header | Adds showing the header. |
|
|
35
|
+
| -A | --answer | Adds showing the Wordle answer. |
|
|
36
|
+
| -D | --date-display | Adds showing the date. |
|
|
37
|
+
| -E | --editor | Adds showing the Wordle editor. |
|
|
38
|
+
| -I | --id | Adds showing the Wordle ID. |
|
|
39
|
+
| -L | --launch | Adds showing days since Wordle launch. |
|
|
40
|
+
|
|
41
|
+
### Advanced Configuration & Miscellaneous Flags
|
|
42
|
+
|
|
43
|
+
| Flag | Long Form | Description |
|
|
44
|
+
| :--- | :--- | :--- |
|
|
45
|
+
| -u | --url | Allows using a different URL instead of the default URL. |
|
|
46
|
+
| -d | --customdate | Allows using a different date instead of today's date. |
|
|
47
|
+
| -V | --version | Shows installed WordleFetch package version and exits. |
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
WordleFetch/Cli.py,sha256=R8i6wLhdRESO8bDCe_Q9uoXK-_DuUTxIH2Ib5IcqQgk,3675
|
|
2
|
+
WordleFetch/Theme.py,sha256=SYDs_Tko8-znuYpWccAEjZ6BoBG_sgW-utjB1HyeEOo,174
|
|
3
|
+
WordleFetch/Wordle.py,sha256=5BrjslfxBHUDZCnhIg4Rqzs8fOqhmpwrfxmkdaA18R4,1373
|
|
4
|
+
WordleFetch/__init__.py,sha256=IlNzhKSjJAh9an63UzcxWQhEoIg--aT2DtzUNBcwGWg,70
|
|
5
|
+
wordlefetch-1.0.0.dist-info/licenses/LICENSE,sha256=ECXjQ6V9w90jlEzryWrBI39iu7wjV2ea0da2laoo4Zg,1065
|
|
6
|
+
wordlefetch-1.0.0.dist-info/METADATA,sha256=l_Q4-uV7A59IK1hevvjUwKsGegI7S0DyDddWbbsLD5I,1526
|
|
7
|
+
wordlefetch-1.0.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
8
|
+
wordlefetch-1.0.0.dist-info/entry_points.txt,sha256=zmuscOgih4MJR6rLcRw5nGAMJpj7obKsHSQMMT6fsjE,53
|
|
9
|
+
wordlefetch-1.0.0.dist-info/top_level.txt,sha256=HDy4wGUZ-HSfmGRwAT20uYA6Y9Ks6enZHxn92NyRS9A,12
|
|
10
|
+
wordlefetch-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ruizennis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
WordleFetch
|