Beispiel #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))
Beispiel #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
Beispiel #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
Beispiel #4
0
class AK(AttributeStorage):
    x = Attribute()
    params = KwargsAttribute()
Beispiel #5
0
class AD(AttributeStorage):
    default = Attribute(default=100)
    required = Attribute()
Beispiel #6
0
class TModelChild(Model):
    id = Attribute(uid=True)
    some = Attribute()
Beispiel #7
0
class A1(AttributeStorage):
    a = Attribute(description="a1")
    b = Attribute(description="a1")
Beispiel #8
0
class A4(AttributeStorage):
    first_attr = Attribute()
    second_attr = Attribute()
Beispiel #9
0
class MethodTwo(AttributeStorage):
    a = Attribute()

    @Attribute.property
    def a2(self):
        return self.a * 2
Beispiel #10
0
class MDC(AttributeStorage):
    x = Attribute(default=lambda: dict())
Beispiel #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)
Beispiel #12
0
class LabelTwo(LabelName):
    x = Attribute()
Beispiel #13
0
class A2(A1):
    b = Attribute(description="a2")
    c = Attribute(description="a2")
Beispiel #14
0
class XXX(AttributeStorage):
    uid = Attribute(uid=True)
    value = Attribute()
Beispiel #15
0
class ZZZ(XXX):
    uid = Attribute(uid=True)
Beispiel #16
0
class TModel(Model):
    uid = Attribute(uid=True)
    name: str = Attribute()
    value: int = Attribute()
Beispiel #17
0
class TLink(Link):
    direction = Link.LTR
    param = Attribute(default=None)
Beispiel #18
0
 class XX(AttributeStorage):
     b = Attribute()
     xx_kwargs = KwargsAttribute()
     c = Attribute()
     yy_kwargs = KwargsAttribute()
Beispiel #19
0
class A3(A2):
    c = Attribute(description="a3")
    d = Attribute(description="a3")
Beispiel #20
0
class LabelName(Model):
    uid = Attribute(uid=True)
    param_one = Attribute()
Beispiel #21
0
 class XX(AK):
     c = Attribute()
     yy_kwargs = KwargsAttribute()
Beispiel #22
0
class MethodOne(AttributeStorage):
    def _calc(self):
        return self.a * 2

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