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))
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
class AD(AttributeStorage): default = Attribute(default=100) required = Attribute()
class A4(AttributeStorage): first_attr = Attribute() second_attr = Attribute()
class A1(AttributeStorage): a = Attribute(description="a1") b = Attribute(description="a1")
class XX(AK): c = Attribute() yy_kwargs = KwargsAttribute()
class MDC(AttributeStorage): x = Attribute(default=lambda: dict())
class MethodTwo(AttributeStorage): a = Attribute() @Attribute.property def a2(self): return self.a * 2
class LabelTwo(LabelName): x = Attribute()
class A2(A1): b = Attribute(description="a2") c = Attribute(description="a2")
class XXX(AttributeStorage): uid = Attribute(uid=True) value = Attribute()
class ZZZ(XXX): uid = Attribute(uid=True)
class TModel(Model): uid = Attribute(uid=True) name: str = Attribute() value: int = Attribute()
class TLink(Link): direction = Link.LTR param = Attribute(default=None)
class TModelChild(Model): id = Attribute(uid=True) some = Attribute()
class AK(AttributeStorage): x = Attribute() params = KwargsAttribute()
class XX(AttributeStorage): b = Attribute() xx_kwargs = KwargsAttribute() c = Attribute() yy_kwargs = KwargsAttribute()
class LabelName(Model): uid = Attribute(uid=True) param_one = Attribute()
class A3(A2): c = Attribute(description="a3") d = Attribute(description="a3")
class MethodOne(AttributeStorage): def _calc(self): return self.a * 2 a = Attribute() a2 = Attribute(method=_calc)
class TWrong(Model): x = ModelAttribute() y = Attribute()