attach properties to type(self) instead of Snippet; renamed set_properties -> init_properties
This commit is contained in:
@ -36,14 +36,15 @@ class Snippet:
|
||||
|
||||
def __init__(self, snippetType="snippet"):
|
||||
self._properties = []
|
||||
self.set_properties(snippetType=str)
|
||||
self.init_properties(snippetType=str)
|
||||
self.snippetType = snippetType
|
||||
|
||||
def set_properties(self, **kwargs):
|
||||
def init_properties(self, **kwargs):
|
||||
for name, dtype in kwargs.items():
|
||||
storage_name = '_' + name
|
||||
setattr(Snippet, storage_name, None)
|
||||
setattr(Snippet, name, property_maker(name, dtype))
|
||||
cls = type(self)
|
||||
setattr(cls, storage_name, None)
|
||||
setattr(cls, name, property_maker(name, dtype))
|
||||
self._properties.append(name)
|
||||
|
||||
def to_dict(self, include_none=True):
|
||||
@ -78,7 +79,7 @@ class Basesnippet(Snippet):
|
||||
|
||||
def __init__(self, snippetType="basesnippet"):
|
||||
super().__init__(snippetType=snippetType)
|
||||
self.set_properties(
|
||||
self.init_properties(
|
||||
id=str,
|
||||
parentId=str,
|
||||
ownerGroup=str,
|
||||
@ -105,7 +106,7 @@ class Paragraph(Basesnippet):
|
||||
|
||||
def __init__(self, snippetType="paragraph"):
|
||||
super().__init__(snippetType=snippetType)
|
||||
self.set_properties(
|
||||
self.init_properties(
|
||||
textcontent=str,
|
||||
isMessage=str
|
||||
)
|
||||
|
Reference in New Issue
Block a user