2021-08-23 14:00:17 +00:00
|
|
|
import re
|
|
|
|
|
2021-08-09 05:01:25 +00:00
|
|
|
from .card import Card
|
2021-08-03 21:41:25 +00:00
|
|
|
|
|
|
|
|
2021-08-09 03:32:05 +00:00
|
|
|
class Cards(list[Card]):
|
2021-08-20 22:16:38 +00:00
|
|
|
def __init__(self, name, cards: list[Card] = None):
|
|
|
|
if cards is None:
|
|
|
|
cards = []
|
2021-08-18 11:49:34 +00:00
|
|
|
|
2021-08-20 22:16:38 +00:00
|
|
|
super().__init__(cards)
|
2021-08-18 11:49:34 +00:00
|
|
|
self.__name = name
|
|
|
|
|
2021-09-03 09:51:43 +00:00
|
|
|
def __repr__(self) -> str:
|
2021-08-18 11:49:34 +00:00
|
|
|
return f"[{', '.join(str(card) for card in self)}]"
|
|
|
|
|
2021-09-03 09:51:43 +00:00
|
|
|
def __str__(self) -> str:
|
|
|
|
return repr(self)
|
|
|
|
|
2021-08-18 14:52:32 +00:00
|
|
|
@property
|
|
|
|
def name(self) -> str:
|
|
|
|
return self.__name
|
|
|
|
|
|
|
|
@property
|
|
|
|
def file_name(self) -> str:
|
2021-08-23 14:00:17 +00:00
|
|
|
val = self.name.lower().replace(" ", "_")
|
|
|
|
return re.sub(r"[^\w]", "", val, flags=re.UNICODE)
|