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