spells-mtg 0.11.0__py3-none-any.whl → 0.11.1__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.
Potentially problematic release.
This version of spells-mtg might be problematic. Click here for more details.
- spells/card_data_files.py +49 -37
- spells/draft_data.py +4 -4
- {spells_mtg-0.11.0.dist-info → spells_mtg-0.11.1.dist-info}/METADATA +1 -1
- {spells_mtg-0.11.0.dist-info → spells_mtg-0.11.1.dist-info}/RECORD +7 -7
- {spells_mtg-0.11.0.dist-info → spells_mtg-0.11.1.dist-info}/WHEEL +0 -0
- {spells_mtg-0.11.0.dist-info → spells_mtg-0.11.1.dist-info}/entry_points.txt +0 -0
- {spells_mtg-0.11.0.dist-info → spells_mtg-0.11.1.dist-info}/licenses/LICENSE +0 -0
spells/card_data_files.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
2
|
import os
|
|
3
3
|
import wget
|
|
4
|
+
from time import sleep
|
|
4
5
|
|
|
5
6
|
import polars as pl
|
|
6
7
|
|
|
@@ -19,6 +20,7 @@ DECK_COLOR_DATA_TEMPLATE = (
|
|
|
19
20
|
|
|
20
21
|
START_DATE_MAP = {
|
|
21
22
|
"DFT": dt.date(2025, 2, 11),
|
|
23
|
+
"TDM": dt.date(2025, 4, 8),
|
|
22
24
|
"FIN": dt.date(2025, 6, 10),
|
|
23
25
|
}
|
|
24
26
|
|
|
@@ -120,7 +122,7 @@ def base_ratings_df(
|
|
|
120
122
|
set_code: str,
|
|
121
123
|
format: str = "PremierDraft",
|
|
122
124
|
player_cohort: str = "all",
|
|
123
|
-
|
|
125
|
+
deck_colors: str | list[str] = "any",
|
|
124
126
|
start_date: dt.date | None = None,
|
|
125
127
|
end_date: dt.date | None = None,
|
|
126
128
|
) -> pl.DataFrame:
|
|
@@ -129,41 +131,53 @@ def base_ratings_df(
|
|
|
129
131
|
if end_date is None:
|
|
130
132
|
end_date = dt.date.today() - dt.timedelta(days=1)
|
|
131
133
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
ratings_file_path = os.path.join(ratings_dir, filename)
|
|
145
|
-
|
|
146
|
-
if not os.path.isfile(ratings_file_path):
|
|
147
|
-
user_group_param = (
|
|
148
|
-
"" if player_cohort == "all" else f"&user_group={player_cohort}"
|
|
134
|
+
if isinstance(deck_colors, str):
|
|
135
|
+
deck_colors = [deck_colors]
|
|
136
|
+
|
|
137
|
+
concat_list = []
|
|
138
|
+
for i, deck_color in enumerate(deck_colors):
|
|
139
|
+
ratings_dir, filename = cache.card_ratings_file_path(
|
|
140
|
+
set_code,
|
|
141
|
+
format,
|
|
142
|
+
player_cohort,
|
|
143
|
+
deck_color,
|
|
144
|
+
start_date,
|
|
145
|
+
end_date,
|
|
149
146
|
)
|
|
150
|
-
deck_color_param = "" if deck_color == "any" else f"&deck_colors={deck_color}"
|
|
151
147
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
148
|
+
if not os.path.isdir(ratings_dir):
|
|
149
|
+
os.makedirs(ratings_dir)
|
|
150
|
+
|
|
151
|
+
ratings_file_path = os.path.join(ratings_dir, filename)
|
|
152
|
+
|
|
153
|
+
if not os.path.isfile(ratings_file_path):
|
|
154
|
+
if i > 0:
|
|
155
|
+
sleep(5)
|
|
156
|
+
user_group_param = (
|
|
157
|
+
"" if player_cohort == "all" else f"&user_group={player_cohort}"
|
|
158
|
+
)
|
|
159
|
+
deck_color_param = "" if deck_color == "any" else f"&deck_colors={deck_color}"
|
|
160
|
+
|
|
161
|
+
url = RATINGS_TEMPLATE.format(
|
|
162
|
+
set_code=set_code,
|
|
163
|
+
format=format,
|
|
164
|
+
user_group_param=user_group_param,
|
|
165
|
+
deck_color_param=deck_color_param,
|
|
166
|
+
start_date_str=start_date.strftime("%Y-%m-%d"),
|
|
167
|
+
end_date_str=end_date.strftime("%Y-%m-%d"),
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
wget.download(
|
|
171
|
+
url,
|
|
172
|
+
out=ratings_file_path,
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
concat_list.append(pl.read_json(ratings_file_path).with_columns(
|
|
176
|
+
(pl.lit(deck_color) if deck_color != "any" else pl.lit(None)).alias(
|
|
177
|
+
ColName.MAIN_COLORS
|
|
178
|
+
)
|
|
179
|
+
))
|
|
180
|
+
df = pl.concat(concat_list)
|
|
167
181
|
|
|
168
182
|
return df.select(
|
|
169
183
|
[
|
|
@@ -172,9 +186,7 @@ def base_ratings_df(
|
|
|
172
186
|
(pl.lit("Top") if player_cohort == "top" else pl.lit(None)).alias(
|
|
173
187
|
ColName.PLAYER_COHORT
|
|
174
188
|
),
|
|
175
|
-
|
|
176
|
-
ColName.MAIN_COLORS
|
|
177
|
-
),
|
|
189
|
+
ColName.MAIN_COLORS,
|
|
178
190
|
*[val.alias(key) for key, val in ratings_col_defs.items()],
|
|
179
191
|
]
|
|
180
192
|
)
|
spells/draft_data.py
CHANGED
|
@@ -34,9 +34,9 @@ class CardDataFileSpec():
|
|
|
34
34
|
set_code: str
|
|
35
35
|
format: str = "PremierDraft"
|
|
36
36
|
player_cohort: str = "all"
|
|
37
|
-
|
|
38
|
-
start_date: datetime.
|
|
39
|
-
end_date: datetime.
|
|
37
|
+
deck_colors: str = "any"
|
|
38
|
+
start_date: datetime.date | None = None
|
|
39
|
+
end_date: datetime.date | None = None
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
def _cache_key(args) -> str:
|
|
@@ -563,7 +563,7 @@ def summon(
|
|
|
563
563
|
set_code=cdfs.set_code,
|
|
564
564
|
format=cdfs.format,
|
|
565
565
|
player_cohort=cdfs.player_cohort,
|
|
566
|
-
|
|
566
|
+
deck_colors=cdfs.deck_colors,
|
|
567
567
|
start_date=cdfs.start_date,
|
|
568
568
|
end_date=cdfs.end_date,
|
|
569
569
|
)
|
|
@@ -3,11 +3,11 @@ spells/.ruff_cache/0.8.6/17785301476771359756,sha256=gPYLG8psuOSo37IefLzTu5wgRrb
|
|
|
3
3
|
spells/.ruff_cache/CACHEDIR.TAG,sha256=WVMVbX4MVkpCclExbq8m-IcOZIOuIZf5FrYw5Pk-Ma4,43
|
|
4
4
|
spells/__init__.py,sha256=0pnh2NLn9FrNKncE9-tBsighp3e8YAsN--_ovUpgWGs,333
|
|
5
5
|
spells/cache.py,sha256=6cl0q62erR3LCANPSfxG5-J7JQfLwNdWjzlBpfiL4IE,7174
|
|
6
|
-
spells/card_data_files.py,sha256=
|
|
6
|
+
spells/card_data_files.py,sha256=dMLbzNCO82xk9Z6qumYBypy9MmpaEYusa5r9uCchSJM,6023
|
|
7
7
|
spells/cards.py,sha256=6stFPhJOzHqvQnkSv9cDeylRa_7L9Y8sOaowiZhzz6I,4174
|
|
8
8
|
spells/columns.py,sha256=s_PYyg2QaRL6kLWFNKCBEfbMF0x7O7-Yd9SeG1ttYL4,18206
|
|
9
9
|
spells/config.py,sha256=zpRUZ-6JKALE149L0yfeD1AgqKPaVBGHfD_TdHi-jqE,235
|
|
10
|
-
spells/draft_data.py,sha256=
|
|
10
|
+
spells/draft_data.py,sha256=H-Betq204FcN43491Ya2A3KOO5zzSQY1tp7wQqPvGSs,21000
|
|
11
11
|
spells/enums.py,sha256=gbwfon6tQCoKDb-m4hSaHWi9slj82yqaH3qhYMVrsck,4991
|
|
12
12
|
spells/extension.py,sha256=LBqGbJbe7iSRQkxJK7npkADCfzhdnIwwVvlmTn8xvjQ,8454
|
|
13
13
|
spells/external.py,sha256=I-f_vMx-h2kvunUlZthsauaeDn42vcRk0wvTURfImzs,11848
|
|
@@ -16,8 +16,8 @@ spells/log.py,sha256=3avmg65hru8K9npKLvPp1wWWxq-hoEYDUCbxqhPkKUw,2175
|
|
|
16
16
|
spells/manifest.py,sha256=ExWVk17BRw615UmvrV817xwz457yfTNdNMNE_M00aEg,8338
|
|
17
17
|
spells/schema.py,sha256=DbMvV8PIThJTp0Xzp_XIorlW6JhE1ud1kWRGf5SQ4_c,6406
|
|
18
18
|
spells/utils.py,sha256=IO3brrXVvZla0LRTEB5v6NgGqZb_rYA46XtKBURGMNk,1944
|
|
19
|
-
spells_mtg-0.11.
|
|
20
|
-
spells_mtg-0.11.
|
|
21
|
-
spells_mtg-0.11.
|
|
22
|
-
spells_mtg-0.11.
|
|
23
|
-
spells_mtg-0.11.
|
|
19
|
+
spells_mtg-0.11.1.dist-info/METADATA,sha256=rzLlasItKx3lGRpl5m0j2gLj_EY5kViwfXArOnatKvk,47369
|
|
20
|
+
spells_mtg-0.11.1.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
|
|
21
|
+
spells_mtg-0.11.1.dist-info/entry_points.txt,sha256=a9Y1omdl9MdnKuIj3aOodgrp-zZII6OCdvqwgP6BFvI,63
|
|
22
|
+
spells_mtg-0.11.1.dist-info/licenses/LICENSE,sha256=tS54XYbJSgmq5zuHhbsQGbNQLJPVgXqhF5nu2CSRMig,1068
|
|
23
|
+
spells_mtg-0.11.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|