Skip to content

Commit

Permalink
Cards already keep track of printings.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwax committed Feb 28, 2016
1 parent 67074b0 commit 36647a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
11 changes: 5 additions & 6 deletions mtg_ssm/serialization/mtgxlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def dump_workbook(collection):
create_sets_sheet(sets_sheet, card_sets)
for card_set in card_sets:
cards_sheet = workbook.create_sheet()
create_cards_sheet(
cards_sheet, card_set, collection.card_name_to_printings)
create_cards_sheet(cards_sheet, card_set)
return workbook


Expand Down Expand Up @@ -110,12 +109,12 @@ def create_haveref_sum(setcode, rownums):
return '+'.join(haverefs)


def get_other_print_references(printing, name_to_prints):
def get_other_print_references(printing):
"""Get an xlsx formula to list counts of a card from other sets."""
if printing.card.strict_basic:
return None # Basics are so prolific, they tend to bog things down
other_prints = (
p for p in name_to_prints[printing.card_name]
p for p in printing.card.printings
if p.set_code != printing.set_code)
setcode_and_release = set()
setcode_to_rownums = collections.defaultdict(list)
Expand Down Expand Up @@ -147,7 +146,7 @@ def get_other_print_references(printing, name_to_prints):
ROW_OFFSET = 2


def create_cards_sheet(sheet, card_set, name_to_prints):
def create_cards_sheet(sheet, card_set):
"""Populate sheet with card information from a given set."""
sheet.title = card_set.code
sheet.append(CARDS_SHEET_HEADER)
Expand All @@ -163,7 +162,7 @@ def create_cards_sheet(sheet, card_set, name_to_prints):
]
for counttype in models.CountTypes:
row.append(printing.counts.get(counttype))
row.append(get_other_print_references(printing, name_to_prints))
row.append(get_other_print_references(printing))
sheet.append(row)

# Styling
Expand Down
12 changes: 4 additions & 8 deletions tests/serialization/mtgxlsx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def test_get_refs_multiple_sets(self):
'fff0b8e8fea06ee1ac5c35f048a0a459b1222673']

# Execute
print_refs = mtgxlsx.get_other_print_references(
lea_dark_rit, self.collection.card_name_to_printings)
print_refs = mtgxlsx.get_other_print_references(lea_dark_rit)

# Verify
expected = (
Expand All @@ -109,8 +108,7 @@ def test_get_refs_multiple_variants(self):
'fc46a4b72d216117a352f59217a84d0baeaaacb7']

# Execute
print_refs = mtgxlsx.get_other_print_references(
mma_thallid, self.collection.card_name_to_printings)
print_refs = mtgxlsx.get_other_print_references(mma_thallid)

# Verify
expected = (
Expand All @@ -123,8 +121,7 @@ def test_get_refs_basic_land(self):
'5ede9781b0c5d157c28a15c3153a455d7d6180fa']

# Execute
print_refs = mtgxlsx.get_other_print_references(
lea_forest, self.collection.card_name_to_printings)
print_refs = mtgxlsx.get_other_print_references(lea_forest)

# Verify
self.assertIsNone(print_refs)
Expand All @@ -147,8 +144,7 @@ def test_create_cards_sheet(self):
sheet = book.create_sheet()

# Execute
mtgxlsx.create_cards_sheet(
sheet, ice_age, self.collection.card_name_to_printings)
mtgxlsx.create_cards_sheet(sheet, ice_age)

# Verify
rows = [[cell.value for cell in row] for row in sheet.rows]
Expand Down

0 comments on commit 36647a7

Please sign in to comment.