mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-09-22 04:50:46 +02:00
Merge pull request #12 from mwisnowski/bugfix/fix-cli-build
chore:fixing cli build due to missing variable in build phase 5 and t…
This commit is contained in:
commit
7ef45252f7
2 changed files with 41 additions and 3 deletions
|
@ -45,12 +45,13 @@ class ColorBalanceMixin:
|
||||||
Uses the color source matrix to aggregate counts for each color.
|
Uses the color source matrix to aggregate counts for each color.
|
||||||
"""
|
"""
|
||||||
matrix = self._compute_color_source_matrix()
|
matrix = self._compute_color_source_matrix()
|
||||||
counts = {c:0 for c in ['W','U','B','R','G']}
|
# Track only WUBRG here; ignore colorless 'C' and any other markers for this computation.
|
||||||
|
counts = {c: 0 for c in ['W', 'U', 'B', 'R', 'G']}
|
||||||
for name, colors in matrix.items():
|
for name, colors in matrix.items():
|
||||||
entry = self.card_library.get(name, {})
|
entry = self.card_library.get(name, {})
|
||||||
copies = entry.get('Count',1)
|
copies = entry.get('Count', 1)
|
||||||
for c, v in colors.items():
|
for c, v in colors.items():
|
||||||
if v:
|
if v and c in counts:
|
||||||
counts[c] += copies
|
counts[c] += copies
|
||||||
return counts
|
return counts
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,45 @@ import argparse
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
from deck_builder.builder import DeckBuilder
|
from deck_builder.builder import DeckBuilder
|
||||||
from deck_builder import builder_constants as bc
|
from deck_builder import builder_constants as bc
|
||||||
|
from file_setup.setup import initial_setup
|
||||||
|
from tagging import tagger
|
||||||
|
|
||||||
|
def _is_stale(file1: str, file2: str) -> bool:
|
||||||
|
"""Return True if file2 is missing or older than file1."""
|
||||||
|
if not os.path.isfile(file2):
|
||||||
|
return True
|
||||||
|
if not os.path.isfile(file1):
|
||||||
|
return True
|
||||||
|
return os.path.getmtime(file2) < os.path.getmtime(file1)
|
||||||
|
|
||||||
|
def _ensure_data_ready():
|
||||||
|
cards_csv = os.path.join("csv_files", "cards.csv")
|
||||||
|
tagging_json = os.path.join("csv_files", ".tagging_complete.json")
|
||||||
|
# If cards.csv is missing, run full setup+tagging
|
||||||
|
if not os.path.isfile(cards_csv):
|
||||||
|
print("cards.csv not found, running full setup and tagging...")
|
||||||
|
initial_setup()
|
||||||
|
tagger.run_tagging()
|
||||||
|
_write_tagging_flag(tagging_json)
|
||||||
|
# If tagging_complete is missing or stale, run tagging
|
||||||
|
elif not os.path.isfile(tagging_json) or _is_stale(cards_csv, tagging_json):
|
||||||
|
print(".tagging_complete.json missing or stale, running tagging...")
|
||||||
|
tagger.run_tagging()
|
||||||
|
_write_tagging_flag(tagging_json)
|
||||||
|
|
||||||
|
def _write_tagging_flag(tagging_json):
|
||||||
|
import json
|
||||||
|
from datetime import datetime
|
||||||
|
os.makedirs(os.path.dirname(tagging_json), exist_ok=True)
|
||||||
|
with open(tagging_json, 'w', encoding='utf-8') as f:
|
||||||
|
json.dump({'tagged_at': datetime.now().isoformat(timespec='seconds')}, f)
|
||||||
|
|
||||||
def run(
|
def run(
|
||||||
command_name: str = "",
|
command_name: str = "",
|
||||||
|
@ -273,6 +309,7 @@ def _resolve_value(
|
||||||
|
|
||||||
|
|
||||||
def _main() -> int:
|
def _main() -> int:
|
||||||
|
_ensure_data_ready()
|
||||||
parser = _build_arg_parser()
|
parser = _build_arg_parser()
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
# Optional config discovery (no prompts)
|
# Optional config discovery (no prompts)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue