コード例 #1
0
ファイル: commodities.py プロジェクト: matheusssilva/PyLoca
class Product(object, metaclass=DescAbcMetaClass):
    """
    Class of others products and base class of all product types
    """

    price = OnlyPositiveValue()  # Descriptor, class attribute
    cost = OnlyPositiveValue()  # Descriptor, class attribute

    @abstractmethod
    def __init__(self, bar_code, name, price, cost, stock):
        self.bar_code = bar_code
        self.name = name
        self.price = price
        self.cost = cost
        self.stock = stock
コード例 #2
0
ファイル: movements.py プロジェクト: matheusssilva/PyLoca
class Rent(Transaction):
    """
    Rents class

    It should receive a namedtuple as the first parameter.
    This first parameter should to contain the parameters of the base class (Transaction).
    """

    Status = Enum('Status', 'Active, Finalized, Cancelled')
    value_paid = OnlyPositiveValue()  # Descriptor, class attribute

    def __init__(self, transaction, value_paid, status=Status.Active):
        super().__init__(transaction.products, transaction.client,
                         transaction.functionary, transaction.date_time,
                         transaction.value, transaction.observations)

        self.value_paid = value_paid  # Acessando via descriptors
        self.status = status

    @property
    def status(self):
        return self.__status.value

    @status.setter
    def status(self, value):
        self.__status = value
コード例 #3
0
ファイル: commodities.py プロジェクト: matheusssilva/PyLoca
class Media(Product):
    """
    Abstract media class

    It should receive a namedtuple as the first parameter.
    This first parameter should to contain the parameters of the base class (Product).
    """

    Status = Enum('Status', 'Available, Rented, Reserved')
    score = OnlyPositiveValue()  # Descriptor, class attribute

    @abstractmethod  # Inherited his father's metaclass
    def __init__(self, product, score, local_trailer, web_trailer, cover, info_media, status=Status.Available):
        super().__init__(product.name, product.price,
                         product.cost, product.bar_code, product.stock)
        self.score = score
        self.local_trailer = local_trailer
        self.web_trailer = web_trailer
        self.cover = cover
        self.info_media = info_media
        self.status = status

    @property
    def status(self):
        return self.__status.value

    @status.setter
    def status(self, valor):
        self.__status = valor
コード例 #4
0
ファイル: movements.py プロジェクト: matheusssilva/PyLoca
class CashDesk(object, metaclass=DescMetaClass):

    # Custom enumeration
    Status = Enum('Status', {'Opened': True, 'Closed': False})

    expected_value = OnlyPositiveValue()  # Descriptor, class attribute
    cash_fund = OnlyPositiveValue()  # Descriptor, class attribute
    value_in_cash = OnlyPositiveOrNoneValue()  # Descriptor, class

    def __init__(self,
                 date_time_opened,
                 functionary,
                 cash_fund,
                 expected_value,
                 value_in_cash,
                 date_time_closed,
                 observations,
                 status=Status.Opened):
        self.date_time_opened = date_time_opened
        self.functionary = functionary
        self.cash_fund = cash_fund  # Acessando via descriptor
        self.expected_value = expected_value  # Acessando via descriptor
        self.value_in_cash = value_in_cash  # Acessando via descriptor
        self.date_time_closed = date_time_closed  # Acessando via property
        self.observations = observations
        self.status = status

    @property
    def date_time_closed(self):
        return self.__date_time_closed

    @date_time_closed.setter
    def date_time_closed(self, usr_date_time):
        if usr_date_time is not None and usr_date_time < self.date_time_opened:
            raise InvalidDate(usr_date_time)
        else:
            self.__date_time_closed = usr_date_time

    @property
    def status(self):
        return self.__status

    @status.setter
    def status(self, value):
        self.__status = value
コード例 #5
0
ファイル: movements.py プロジェクト: matheusssilva/PyLoca
class CashDeskMovs(object, metaclass=DescMetaClass):

    value = OnlyPositiveValue()  # Descriptor, class attribute

    def __init__(self, cash_desk, functionary, value, type_move, date_time,
                 observations):
        self.cash_desk = cash_desk
        self.functionary = functionary
        self.value = value  # Acessando via descriptor
        self.type_move = type_move
        self.date_time = date_time
        self.observations = observations
コード例 #6
0
ファイル: commodities.py プロジェクト: matheusssilva/PyLoca
class Movie(Media):
    """
    Movies class

    It should receive a namedtuple as the first parameter.
    This first parameter should to contain the parameters of the base class (Media).
    """

    duration = OnlyPositiveValue()  # Descriptor, class attribute

    def __init__(self, media, cast, duraction, screen_format):
        super().__init__(media.product, media.score, media.local_trailer,
                         media.web_trailer, media.cover, media.info_media)
        self.cast = cast
        self.duraction = duraction
        self.screen_format = screen_format
コード例 #7
0
ファイル: commodities.py プロジェクト: matheusssilva/PyLoca
class Game(Media):
    """
    Games class

    It should receive a namedtuple as the first parameter.
    This first parameter should to contain the parameters of the base class (Media).
    """

    players = OnlyPositiveValue()  # Descritor, class attribute

    def __init__(self, media, players, is_online, console):
        super().__init__(media.product, media.score, media.local_trailer,
                         media.web_trailer, media.cover, media.info_media)
        self.players = players
        self.is_online = is_online
        self.console = console
コード例 #8
0
ファイル: movements.py プロジェクト: matheusssilva/PyLoca
class Transaction(object, metaclass=DescAbcMetaClass):
    """
    Transaction is a abstract base class for all transaction types
    """

    products = NotEmptyContainer()  # Descriptor, class attribute
    value = OnlyPositiveValue()  # Descriptor, class attribute

    @abstractmethod
    def __init__(self, products, client, functionary, date_time, value,
                 observations):
        self.products = products
        self.client = client
        self.functionary = functionary
        self.date_time = date_time
        self.value = value
        self.observations = observations
コード例 #9
0
ファイル: commodities.py プロジェクト: matheusssilva/PyLoca
class InfoMedia(object, metaclass=DescMetaClass):
    """
    InfoMedia is complement class of Media class
    """

    minimum_age = OnlyPositiveValue()  # Descriptor, class attribute

    def __init__(self, genre, minimum_age, producer, distributor, subtitles,
                 audios, synopsis, fisic_type):
        self.genre = genre
        self.minimum_age = minimum_age
        self.producer = producer
        self.distributor = distributor
        self.subtitles = subtitles
        self.audios = audios
        self.synopsis = synopsis
        self.fisic_type = fisic_type