示例#1
0
文件: deckbox.py 项目: gwax/mtg_ssm
 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)
示例#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)
示例#3
0
文件: xlsx.py 项目: 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
示例#4
0
文件: xlsx.py 项目: TonyRoomZ/mtg_ssm
 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
示例#5
0
文件: csv.py 项目: 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)
示例#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)
示例#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
示例#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