Merge branch 'authMixin' of gitlab.psi.ch:augustin_s/py_scilog into authMixin
This commit is contained in:
@ -2,11 +2,13 @@
|
||||
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
parser.add_argument("pgroup", help="Expected form: p12345")
|
||||
parser.add_argument("-u", "--url", default="https://lnode2.psi.ch/api/v1", help="Server address")
|
||||
|
||||
clargs = parser.parse_args()
|
||||
pgroup = clargs.pgroup
|
||||
url = clargs.url
|
||||
|
||||
|
||||
import urllib3
|
||||
@ -20,11 +22,10 @@ from scilog import Basesnippet, Paragraph
|
||||
tmp = Basesnippet()
|
||||
tmp.id = "2"
|
||||
|
||||
# url = "https://lnode2.psi.ch/api/v1"
|
||||
url = "http://[::1]:3000/"
|
||||
log = SciLog(url)
|
||||
#print(log.token)
|
||||
logbooks = log.get_logbooks(ownerGroup=pgroup)
|
||||
print(logbooks)
|
||||
|
||||
assert len(logbooks) == 1
|
||||
logbook = logbooks[0]
|
||||
|
@ -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