示例#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))
示例#2
0
文件: nodes.py 项目: yazici/damgteam
    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
示例#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
示例#4
0
class AK(AttributeStorage):
    x = Attribute()
    params = KwargsAttribute()
示例#5
0
class AD(AttributeStorage):
    default = Attribute(default=100)
    required = Attribute()
示例#6
0
class TModelChild(Model):
    id = Attribute(uid=True)
    some = Attribute()
示例#7
0
class A1(AttributeStorage):
    a = Attribute(description="a1")
    b = Attribute(description="a1")
示例#8
0
class A4(AttributeStorage):
    first_attr = Attribute()
    second_attr = Attribute()
示例#9
0
class MethodTwo(AttributeStorage):
    a = Attribute()

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

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