Skip to content

Commit

Permalink
Solve issues in first implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
pablerass committed Nov 19, 2023
1 parent 4669e9a commit 04abc1d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cartuli/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ def _create_deck(self, definition: dict, name: str) -> Deck:
name=Path(path).stem
) for path in front_image_files if self.__cards_filter(path))
)
# TODO: Add warning if no images are found
# TODO: Add warning if no images are found and manage it properly and do not create
# deck
if len(front_image_files) != len(front_images):
logger.debug(f"Front images filterd from {len(front_image_files)} to "
f" {len(front_images)} for '{name}' deck")

back_image = None
if 'back' in definition:
if 'image' in definition['back']:
Expand Down Expand Up @@ -127,15 +129,16 @@ def _create_deck(self, definition: dict, name: str) -> Deck:
) for path in back_image_files if self.__cards_filter(path))
)
# TODO: Add warning if no images are found
# TODO: Add error if front and back sizes do not match
return Deck(
(Card(front_image, back_image) for front_image, back_image in zip(front_images, back_images)),
size=size, name=name
)
if len(back_image_files) != len(back_images):
logger.debug(f"Back images filterd from {len(back_image_files)} to "
f" {len(back_images)} for '{name}' deck")
else:
return Deck((Card(image) for image in front_images), size=size, name=name)

return Deck((Card(image) for image in front_images), size=size, name=name)

@property
def sheets(self) -> dict[tuple[str], Sheet]:
Expand Down

0 comments on commit 04abc1d

Please sign in to comment.