Example #1
0
 def read(self, filename: str):
     """Read print counts from deckbox csv file."""
     with open(filename, 'r') as deckbox_file:
         reader = csv.DictReader(deckbox_file)
         card_counts = (create_card_row(self.cdb, row) for row in reader)
         return counts.aggregate_print_counts(
             self.cdb, card_counts, strict=False)
Example #2
0
 def read(self, filename: str):
     """Read print counts from deckbox csv file."""
     with open(filename, "r") as deckbox_file:
         reader = csv.DictReader(deckbox_file)
         card_counts = (create_card_row(self.cdb, row) for row in reader)
         return counts.aggregate_print_counts(self.cdb,
                                              card_counts,
                                              strict=False)
Example #3
0
File: xlsx.py Project: gwax/mtg_ssm
 def read(self, filename: str):
     """Read print counts from an xlsx file."""
     workbook = openpyxl.load_workbook(filename=filename, read_only=True)
     # pylint: disable=redefined-variable-type
     print_counts = {}
     for sheet in workbook.worksheets:
         if sheet.title not in self.cdb.code_to_card_set:
             if sheet.title in {'Sets', 'All Sets', 'All Cards'}:
                 continue
             raise interface.DeserializationError(
                 'No known set with code {}'.format(sheet.title))
         print_counts = counts.merge_print_counts(
             print_counts, counts.aggregate_print_counts(
                 self.cdb, counts_from_sheet(sheet), strict=True))
     return print_counts
Example #4
0
 def read(self, filename: str):
     """Read print counts from an xlsx file."""
     workbook = openpyxl.load_workbook(filename=filename, read_only=True)
     print_counts = {}
     for sheet in workbook.worksheets:
         if sheet.title not in self.cdb.code_to_card_set:
             if sheet.title in {"Sets", "All Sets", "All Cards"}:
                 continue
             raise interface.DeserializationError(
                 "No known set with code {}".format(sheet.title))
         print_counts = counts.merge_print_counts(
             print_counts,
             counts.aggregate_print_counts(self.cdb,
                                           counts_from_sheet(sheet),
                                           strict=True),
         )
     return print_counts
Example #5
0
File: csv.py Project: gwax/mtg_ssm
 def read(self, filename: str):
     """Read print counts from file."""
     with open(filename, 'r') as csv_file:
         return counts.aggregate_print_counts(
             self.cdb, csv.DictReader(csv_file), strict=True)
Example #6
0
 def read(self, filename: str):
     """Read print counts from file."""
     with open(filename, "r") as csv_file:
         return counts.aggregate_print_counts(self.cdb,
                                              csv.DictReader(csv_file),
                                              strict=True)
Example #7
0
def test_aggregate_print_counts(cdb, card_rows, strict, expected):
    print_counts = counts.aggregate_print_counts(cdb, card_rows, strict)
    assert print_counts == expected
Example #8
0
def test_aggregate_print_counts(cdb, card_rows, strict, expected):
    print_counts = counts.aggregate_print_counts(cdb, card_rows, strict)
    assert print_counts == expected