fixed import_dict(); fixed Snippet constr. arguments
This commit is contained in:
@ -34,10 +34,10 @@ def property_maker(name, dtype):
|
||||
|
||||
class Snippet:
|
||||
|
||||
def __init__(self, snippetType="snippet", **kwargs):
|
||||
def __init__(self, snippetType="snippet"):
|
||||
self._properties = []
|
||||
self.set_properties(snippetType=str)
|
||||
self.snippetType = snippetType
|
||||
self.set_properties(**kwargs)
|
||||
|
||||
def set_properties(self, **kwargs):
|
||||
for name, dtype in kwargs.items():
|
||||
@ -53,7 +53,8 @@ class Snippet:
|
||||
return {key: getattr(self, key) for key in self._properties if getattr(self, key) is not None}
|
||||
|
||||
def import_dict(self, properties):
|
||||
self.__dict__.update(properties)
|
||||
for name, value in properties.items():
|
||||
setattr(self, name, value)
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, properties):
|
||||
@ -75,13 +76,13 @@ class Snippet:
|
||||
|
||||
class Basesnippet(Snippet):
|
||||
|
||||
def __init__(self):
|
||||
props = dict(
|
||||
def __init__(self, snippetType="basesnippet"):
|
||||
super().__init__(snippetType=snippetType)
|
||||
self.set_properties(
|
||||
id=str,
|
||||
parentId=str,
|
||||
ownerGroup=str,
|
||||
accessGroups=list,
|
||||
snippetType=str,
|
||||
isPrivate=bool,
|
||||
createdAt=str,
|
||||
createdBy=str,
|
||||
@ -97,18 +98,17 @@ class Basesnippet(Snippet):
|
||||
versionable=bool,
|
||||
deleted=bool
|
||||
)
|
||||
super().__init__(snippetType="basesnippet", **props)
|
||||
|
||||
|
||||
|
||||
class Paragraph(Basesnippet):
|
||||
|
||||
def __init__(self):
|
||||
props = dict(
|
||||
def __init__(self, snippetType="paragraph"):
|
||||
super().__init__(snippetType=snippetType)
|
||||
self.set_properties(
|
||||
textcontent=str,
|
||||
isMessage=str
|
||||
)
|
||||
super().__init__(snippetType="paragraph", **props)
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user