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"):
|
def __init__(self, snippetType="snippet"):
|
||||||
self._properties = []
|
self._properties = []
|
||||||
self.set_properties(snippetType=str)
|
self.init_properties(snippetType=str)
|
||||||
self.snippetType = snippetType
|
self.snippetType = snippetType
|
||||||
|
|
||||||
def set_properties(self, **kwargs):
|
def init_properties(self, **kwargs):
|
||||||
for name, dtype in kwargs.items():
|
for name, dtype in kwargs.items():
|
||||||
storage_name = '_' + name
|
storage_name = '_' + name
|
||||||
setattr(Snippet, storage_name, None)
|
cls = type(self)
|
||||||
setattr(Snippet, name, property_maker(name, dtype))
|
setattr(cls, storage_name, None)
|
||||||
|
setattr(cls, name, property_maker(name, dtype))
|
||||||
self._properties.append(name)
|
self._properties.append(name)
|
||||||
|
|
||||||
def to_dict(self, include_none=True):
|
def to_dict(self, include_none=True):
|
||||||
@ -78,7 +79,7 @@ class Basesnippet(Snippet):
|
|||||||
|
|
||||||
def __init__(self, snippetType="basesnippet"):
|
def __init__(self, snippetType="basesnippet"):
|
||||||
super().__init__(snippetType=snippetType)
|
super().__init__(snippetType=snippetType)
|
||||||
self.set_properties(
|
self.init_properties(
|
||||||
id=str,
|
id=str,
|
||||||
parentId=str,
|
parentId=str,
|
||||||
ownerGroup=str,
|
ownerGroup=str,
|
||||||
@ -105,7 +106,7 @@ class Paragraph(Basesnippet):
|
|||||||
|
|
||||||
def __init__(self, snippetType="paragraph"):
|
def __init__(self, snippetType="paragraph"):
|
||||||
super().__init__(snippetType=snippetType)
|
super().__init__(snippetType=snippetType)
|
||||||
self.set_properties(
|
self.init_properties(
|
||||||
textcontent=str,
|
textcontent=str,
|
||||||
isMessage=str
|
isMessage=str
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user