Пример #1
0
    def match(self, **properties):
        instance_properties = get_instance_properties(self)

        for property in properties.keys():
            if (property in instance_properties and getattr(self, property) != properties[property]):
                return False
        
        return True
Пример #2
0
    def to_array(self):
        array = []
        properties = get_instance_properties(self)

        for property in properties:
            attr = getattr(self, property)

            if (isinstance(attr, arrow.Arrow)):
                attr = attr.humanize()

            array.append(str(attr))

        return array
Пример #3
0
    def update(self, **properties):
        instance_properties = get_instance_properties(self)

        modified = False
        for property in properties.keys():
            if (property in instance_properties):
                setattr(self, property, properties[property])
                modified = True
            else:
                click.secho('Property \'' + property + '\' doesn\'t match', fg='red')
                raise ValueError('Property ' + property + ' doesn\'t match')

        if (modified):
            self._updated = arrow.now()