Skip to content

Commit

Permalink
Be very verbose and explicit about printing searches
Browse files Browse the repository at this point in the history
  • Loading branch information
gwax committed Jan 29, 2017
1 parent 73a08d7 commit eaae6c3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions mtg_ssm/mtg/counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def new_print_counts() -> Mapping[str, Mapping[CountTypes, int]]:

def find_printing(cdb, set_code, name, set_number, multiverseid, strict=True):
"""Attempt to find a CardPrinting from given parameters."""
print('Searching => Set: %s; Name: %s; Number: %s, Multiverse ID: %s' % (
set_code, name, set_number, multiverseid))
name = name or ''
names = [name]
for sub_from, sub_to in NAME_SUBSTITUTIONS:
Expand All @@ -66,19 +68,21 @@ def find_printing(cdb, set_code, name, set_number, multiverseid, strict=True):
(set_code, name_var, set_number, None),
(set_code, name_var, None, None),
])
printing = None
for snnm_key in snnm_keys:
found_printings = cdb.set_name_num_mv_to_printings.get(snnm_key, [])
if len(found_printings) == 1:
printing = found_printings[0]
print('found: ' + printing.id_)
return printing
break
elif found_printings and not strict:
found_printings = sorted(found_printings, key=lambda p: p.id_)
printing = found_printings[0]
print('fuzzy found: ' + printing.id_)
return printing

return None
break
if printing is not None:
print('Found => Set: %s; Name: %s; Number: %s; Multiverse ID: %s' % (
printing.set_code, printing.card_name, printing.set_number,
printing.multiverseid))
return printing


def coerce_card_row(card_count):
Expand Down

0 comments on commit eaae6c3

Please sign in to comment.