diff --git a/scilog/authclient.py b/scilog/authclient.py index 6270c37..6c39762 100644 --- a/scilog/authclient.py +++ b/scilog/authclient.py @@ -44,3 +44,8 @@ class AuthClient: +class AuthError(Exception): + pass + + + diff --git a/scilog/autherror.py b/scilog/autherror.py deleted file mode 100644 index 7268efe..0000000 --- a/scilog/autherror.py +++ /dev/null @@ -1,5 +0,0 @@ - -class AuthError(Exception): - pass - - diff --git a/scilog/scicat.py b/scilog/scicat.py index 642b97c..91f21db 100644 --- a/scilog/scicat.py +++ b/scilog/scicat.py @@ -1,16 +1,9 @@ -from .authclient import AuthClient, AUTH_HEADERS -from .autherror import AuthError +from .authclient import AuthClient, AuthError, AUTH_HEADERS from .utils import post_request, get_request class SciCat(AuthClient): - @property - def proposals(self): - url = self.address + "/proposals" - headers = self.auth_headers - return get_request(url, headers=headers) - def authenticate(self, username, password): url = self.address + "/users/login" auth_payload = { @@ -26,6 +19,13 @@ class SciCat(AuthClient): return token + @property + def proposals(self): + url = self.address + "/proposals" + headers = self.auth_headers + return get_request(url, headers=headers) + + class SciCatAuthError(AuthError): pass diff --git a/scilog/scilog.py b/scilog/scilog.py index aed1ac7..d9109a3 100644 --- a/scilog/scilog.py +++ b/scilog/scilog.py @@ -1,24 +1,10 @@ -from .authclient import AuthClient, AUTH_HEADERS -from .autherror import AuthError +from .authclient import AuthClient, AuthError, AUTH_HEADERS from .utils import post_request, get_request from .mkfilt import make_filter class SciLog(AuthClient): - def get_snippets(self, **kwargs): - url = self.address + "/basesnippets" - params = make_filter(**kwargs) - headers = self.auth_headers - return get_request(url, params=params, headers=headers) - - def post_snippet(self, **kwargs): - url = self.address + "/basesnippets" - payload = kwargs - headers = self.auth_headers - return post_request(url, payload=payload, headers=headers) - - def authenticate(self, username, password): url = self.address + "/users/login" auth_payload = { @@ -34,6 +20,19 @@ class SciLog(AuthClient): return token + def get_snippets(self, **kwargs): + url = self.address + "/basesnippets" + params = make_filter(**kwargs) + headers = self.auth_headers + return get_request(url, params=params, headers=headers) + + def post_snippet(self, **kwargs): + url = self.address + "/basesnippets" + payload = kwargs + headers = self.auth_headers + return post_request(url, payload=payload, headers=headers) + + class SciLogAuthError(AuthError): pass