Example #1
0
class MainPage(DictPage):
    """Главная страница с основными характеристиками приложения"""
    info = PageAttribute()
    start_time = Attribute()
    queries = PageAttribute(default=0)

    @PageAttribute.property
    def work_time(self):
        return str(Time(self.start_time, ago=True))
Example #2
0
    def add_attr(self, name, value=None, **kwargs):
        """
        Add an attribute.

         .. todo::: 
             - add attribute type mapper.
        """
        attr_type = kwargs.get('attr_type', None)
        #print('\t"%s.%s" type: %s' %(self.name, name, attr_type)
        attr = Attribute(name, value, dagnode=self, **kwargs)
        self._attributes.update({attr.name: attr})
        return attr
Example #3
0
    def verificate(self):
        for k, attr in self.__attributes__.items():
            if not isinstance(self._storage.get(k, Attribute._DefaultNone()), Attribute._DefaultNone):
                continue

            if not isinstance(attr.default, Attribute._DefaultNone):
                continue

            if isinstance(attr, ModelAttribute) and attr.is_id_alias:
                continue

            raise ValueError(f"Set {self.__class__.__name__}.{k}")
        return True
Example #4
0
class AK(AttributeStorage):
    x = Attribute()
    params = KwargsAttribute()
Example #5
0
class AD(AttributeStorage):
    default = Attribute(default=100)
    required = Attribute()
Example #6
0
class TModelChild(Model):
    id = Attribute(uid=True)
    some = Attribute()
Example #7
0
class A1(AttributeStorage):
    a = Attribute(description="a1")
    b = Attribute(description="a1")
Example #8
0
class A4(AttributeStorage):
    first_attr = Attribute()
    second_attr = Attribute()
Example #9
0
class MethodTwo(AttributeStorage):
    a = Attribute()

    @Attribute.property
    def a2(self):
        return self.a * 2
Example #10
0
class MDC(AttributeStorage):
    x = Attribute(default=lambda: dict())
Example #11
0
 def __init__(self, description: Optional[str] = None,
              default: Any = Attribute._DefaultNone(),
              uid: bool = False,
              method=None):
     self.name = None
     super().__init__(description, default, uid, method=method)
Example #12
0
class LabelTwo(LabelName):
    x = Attribute()
Example #13
0
class A2(A1):
    b = Attribute(description="a2")
    c = Attribute(description="a2")
Example #14
0
class XXX(AttributeStorage):
    uid = Attribute(uid=True)
    value = Attribute()
Example #15
0
class ZZZ(XXX):
    uid = Attribute(uid=True)
Example #16
0
class TModel(Model):
    uid = Attribute(uid=True)
    name: str = Attribute()
    value: int = Attribute()
Example #17
0
class TLink(Link):
    direction = Link.LTR
    param = Attribute(default=None)
Example #18
0
 class XX(AttributeStorage):
     b = Attribute()
     xx_kwargs = KwargsAttribute()
     c = Attribute()
     yy_kwargs = KwargsAttribute()
Example #19
0
class A3(A2):
    c = Attribute(description="a3")
    d = Attribute(description="a3")
Example #20
0
class LabelName(Model):
    uid = Attribute(uid=True)
    param_one = Attribute()
Example #21
0
 class XX(AK):
     c = Attribute()
     yy_kwargs = KwargsAttribute()
Example #22
0
class MethodOne(AttributeStorage):
    def _calc(self):
        return self.a * 2

    a = Attribute()
    a2 = Attribute(method=_calc)
Example #23
0
 class TWrong(Model):
     x = ModelAttribute()
     y = Attribute()