oc-facho/facho/model/fields/attribute.py
bit4bit 3eacb29afa se separa responsabilidad de fields.Function
FossilOrigin-Name: 4d5daa47a75a0e283e86bf992126bf60f3a8a14287e9acc437d5f2f3eca43150
2021-06-24 23:38:28 +00:00

19 lines
454 B
Python

from .field import Field
class Attribute(Field):
def __init__(self, tag, default=None):
self.tag = tag
self.value = default
def __get__(self, inst, cls):
if inst is None:
return self
assert self.name is not None
return self.value
def __set__(self, inst, value):
assert self.name is not None
self.value = value
inst._xml_attributes[self.name] = (self.tag, value)