spells-mtg 0.9.6__tar.gz → 0.9.7__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.

Potentially problematic release.


This version of spells-mtg might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spells-mtg
3
- Version: 0.9.6
3
+ Version: 0.9.7
4
4
  Summary: analaysis of 17Lands.com public datasets
5
5
  Author-Email: Joel Barnes <oelarnes@gmail.com>
6
6
  License: MIT
@@ -11,7 +11,7 @@ dependencies = [
11
11
  ]
12
12
  requires-python = ">=3.11"
13
13
  readme = "README.md"
14
- version = "0.9.6"
14
+ version = "0.9.7"
15
15
 
16
16
  [project.license]
17
17
  text = "MIT"
@@ -31,9 +31,6 @@ distribution = true
31
31
  [tool.pdm.scripts]
32
32
  post_install = "scripts/post_install.py"
33
33
 
34
- [tool.pdm.publish.upload]
35
- env_file = "$HOME/.pypienv"
36
-
37
34
  [tool.pdm.version]
38
35
  source = "scm"
39
36
 
@@ -7,4 +7,12 @@ from spells.log import setup_logging
7
7
 
8
8
  setup_logging()
9
9
 
10
- __all__ = ["summon", "view_select", "get_names", "ColSpec", "ColType", "ColName", "logging"]
10
+ __all__ = [
11
+ "summon",
12
+ "view_select",
13
+ "get_names",
14
+ "ColSpec",
15
+ "ColType",
16
+ "ColName",
17
+ "logging",
18
+ ]
@@ -78,7 +78,13 @@ def card_df(draft_set_code: str, names: list[str]) -> pl.DataFrame:
78
78
  draft_set_json = _fetch_mtg_json(draft_set_code)
79
79
  booster_info = draft_set_json["data"]["booster"]
80
80
 
81
- booster_type = "play" if "play" in booster_info else "draft" if "draft" in booster_info else list(booster_info.keys())[0]
81
+ booster_type = (
82
+ "play"
83
+ if "play" in booster_info
84
+ else "draft"
85
+ if "draft" in booster_info
86
+ else list(booster_info.keys())[0]
87
+ )
82
88
  set_codes = booster_info[booster_type]["sourceSetCodes"]
83
89
  set_codes.reverse()
84
90
 
@@ -148,6 +148,10 @@ def _determine_expression(
148
148
  )
149
149
  )
150
150
  except KeyError:
151
+ logging.warning(
152
+ f"KeyError raised in calculation of {col}, probably caused by "
153
+ + "missing context. Column will have value `None`"
154
+ )
151
155
  expr = tuple(pl.lit(None).alias(f"{col}_{name}") for name in names)
152
156
  else:
153
157
  expr = tuple(map(lambda name: pl.col(f"{col}_{name}"), names))
@@ -233,7 +237,11 @@ def _infer_dependencies(
233
237
  ):
234
238
  dependencies.add(split[0])
235
239
  found = True
236
- # fail silently here, so that columns can be passed in harmlessly
240
+ if not found:
241
+ logging.warning(
242
+ f"No column definition found matching dependency {item}! "
243
+ + "`summon` will fail if called with this column"
244
+ )
237
245
 
238
246
  return dependencies
239
247
 
@@ -100,7 +100,7 @@ def cli() -> int:
100
100
 
101
101
 
102
102
  def _add(set_code: str, force_download=False):
103
- if set_code == 'all':
103
+ if set_code == "all":
104
104
  for code in all_sets:
105
105
  _add(code, force_download=force_download)
106
106
 
@@ -42,8 +42,7 @@ def rotate_logs():
42
42
  logging.debug("Log file manually rotated")
43
43
 
44
44
 
45
- @contextmanager
46
- def console_logging(log_level):
45
+ def add_console_handler(log_level):
47
46
  console_handler = logging.StreamHandler(sys.stdout)
48
47
  console_handler.setLevel(log_level)
49
48
  formatter = logging.Formatter(
@@ -52,19 +51,25 @@ def console_logging(log_level):
52
51
  console_handler.setFormatter(formatter)
53
52
  logger = logging.getLogger()
54
53
  logger.addHandler(console_handler)
54
+ return logger, console_handler
55
55
 
56
+
57
+ @contextmanager
58
+ def console_logging(log_level):
59
+ logger, console_handler = add_console_handler(log_level)
56
60
  try:
57
61
  yield
58
62
  finally:
59
63
  logger.removeHandler(console_handler)
60
64
 
61
65
 
62
- def make_verbose(level: int=logging.ERROR) -> Callable:
66
+ def make_verbose(level: int = logging.ERROR) -> Callable:
63
67
  def decorator(func: Callable) -> Callable:
64
68
  @wraps(func)
65
- def wrapped(*args, log_to_console: int=level, **kwargs):
69
+ def wrapped(*args, log_to_console: int = level, **kwargs):
66
70
  with console_logging(log_to_console):
67
71
  return func(*args, **kwargs)
72
+
68
73
  return wrapped
69
- return decorator
70
74
 
75
+ return decorator
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes