From a264d49af43c93d82c61b6b6181a992f8fd5ff65 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Wed, 17 Jun 2020 22:49:15 +0200
Subject: [PATCH] STY: autopep8'd

---
 setup.py                                         |  3 ++-
 src/caosdb/common/models.py                      |  5 +++--
 src/caosdb/utils/caosdb_admin.py                 |  4 ++--
 src/caosdb/utils/server_side_scripting.py        |  5 ++++-
 unittests/test_authentication_auth_token.py      |  5 ++++-
 unittests/test_authentication_unauthenticated.py |  8 +-------
 unittests/test_connection.py                     |  3 +--
 unittests/test_record.py                         |  3 +++
 unittests/test_server_side_scripting.py          | 15 +++++++++------
 9 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/setup.py b/setup.py
index 8893a126..0f85d6d1 100755
--- a/setup.py
+++ b/setup.py
@@ -163,7 +163,8 @@ def setup_package():
         tests_require=["pytest", "pytest-cov", "coverage>=4.4.2"],
         package_data={
             'caosdb': ['cert/indiscale.ca.crt'],
-        }
+        },
+        scripts=["src/caosdb/utils/caosdb_admin.py"]
     )
     try:
         setup(**metadata)
diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py
index 5472cf09..ebde674f 100644
--- a/src/caosdb/common/models.py
+++ b/src/caosdb/common/models.py
@@ -532,7 +532,7 @@ class Entity(object):
         else:
             for p in self.parents:
                 if (p.name is not None
-                    and str(p.name).lower() == str(key).lower()):
+                        and str(p.name).lower() == str(key).lower()):
                     return p
 
         return None
@@ -3512,10 +3512,11 @@ class DropOffBox(list):
 class UserInfo():
 
     def __init__(self, xml):
-        self.roles = [ role.text for role in xml.findall("Roles/Role")]
+        self.roles = [role.text for role in xml.findall("Roles/Role")]
         self.name = xml.get("username")
         self.realm = xml.get("realm")
 
+
 class Info():
 
     def __init__(self):
diff --git a/src/caosdb/utils/caosdb_admin.py b/src/caosdb/utils/caosdb_admin.py
index 6f004192..c7e3024f 100755
--- a/src/caosdb/utils/caosdb_admin.py
+++ b/src/caosdb/utils/caosdb_admin.py
@@ -610,8 +610,8 @@ USAGE
     args = parser.parse_args()
     auth_token = args.auth_token
     if auth_token is not None:
-        db.configure_connection(password_method = "auth_token",
-                                auth_token = auth_token)
+        db.configure_connection(password_method="auth_token",
+                                auth_token=auth_token)
     else:
         db.configure_connection()
 
diff --git a/src/caosdb/utils/server_side_scripting.py b/src/caosdb/utils/server_side_scripting.py
index ecfa9da6..861b5fb6 100644
--- a/src/caosdb/utils/server_side_scripting.py
+++ b/src/caosdb/utils/server_side_scripting.py
@@ -41,6 +41,7 @@ def _make_params(pos_args, opts):
         result["-p{i}".format(i=i)] = str(val)
     return result
 
+
 def _make_multipart_request(call, pos_args, opts, files):
     parts = list()
     params = _make_params(pos_args, opts)
@@ -56,6 +57,7 @@ def _make_multipart_request(call, pos_args, opts, files):
     body, headers = multipart_encode(parts)
     return body, headers
 
+
 def _make_form_request(call, pos_args, opts):
     form = dict()
     form["call"] = call
@@ -64,11 +66,11 @@ def _make_form_request(call, pos_args, opts):
     for key, val in params.items():
         form[key] = val
 
-
     headers = {}
     headers["Content-Type"] = "application/x-www-form-urlencoded"
     return urlencode(form), headers
 
+
 def _make_request(call, pos_args, opts, files=None):
     """
     Return
@@ -81,6 +83,7 @@ def _make_request(call, pos_args, opts, files=None):
 
     return _make_form_request(call, pos_args, opts)
 
+
 def run_server_side_script(call, *args, files=None, **kwargs):
     """
 
diff --git a/unittests/test_authentication_auth_token.py b/unittests/test_authentication_auth_token.py
index 5b91a7c7..bfaa1cab 100644
--- a/unittests/test_authentication_auth_token.py
+++ b/unittests/test_authentication_auth_token.py
@@ -35,16 +35,19 @@ from caosdb.connection.utils import parse_auth_token
 from caosdb.exceptions import LoginFailedException
 from caosdb import configure_connection
 
+
 def test_get_authentication_provider():
     ap = at.get_authentication_provider()
     assert isinstance(ap, at.AuthTokenAuthenticator)
 
+
 def response_with_auth_token():
     token = "SessionToken=[response token];"
     assert parse_auth_token(token) is not None, "cookie not ok"
 
     return MockUpResponse(200, {"Set-Cookie": token}, "ok")
 
+
 def test_configure_connection():
     def request_has_auth_token(**kwargs):
         """test resources"""
@@ -65,6 +68,7 @@ def test_configure_connection():
     assert response.read() == "ok"
     assert c._authenticator.auth_token == "[response token]"
 
+
 def test_login_raises():
     c = configure_connection(password_method="auth_token",
                              auth_token="[auth_token]")
@@ -94,4 +98,3 @@ def test_logout_calls_delete():
     c._delegate_connection.resources.append(logout_resource)
     c._logout()
     mock.method.assert_called_once()
-
diff --git a/unittests/test_authentication_unauthenticated.py b/unittests/test_authentication_unauthenticated.py
index 54f091b1..cdb16903 100644
--- a/unittests/test_authentication_unauthenticated.py
+++ b/unittests/test_authentication_unauthenticated.py
@@ -41,6 +41,7 @@ def test_get_authentication_provider():
     ap = unauthenticated.get_authentication_provider()
     assert isinstance(ap, unauthenticated.Unauthenticated)
 
+
 def test_configure_connection():
     mock = Mock()
 
@@ -67,10 +68,3 @@ def test_login_raises():
     c = configure_connection(password_method="unauthenticated")
     with raises(LoginFailedException):
         c._login()
-
-
-
-
-
-
-
diff --git a/unittests/test_connection.py b/unittests/test_connection.py
index 2323ff97..5c1518c6 100644
--- a/unittests/test_connection.py
+++ b/unittests/test_connection.py
@@ -262,7 +262,7 @@ def test_missing_password():
     connection = configure_connection()
     connection.configure(implementation=setup_two_resources,
                          password_method="plain")
-    connection._authenticator.auth_token="[test-auth-token]"
+    connection._authenticator.auth_token = "[test-auth-token]"
     assert connection.retrieve(["some"]).headers["Cookie"] == "SessionToken=%5Btest-auth-token%5D;"
 
     connection.configure(implementation=setup_two_resources,
@@ -285,4 +285,3 @@ def test_auth_token_connection():
                                 "auth_token authenticator cannot log in "
                                 "again. You must provide a new authentication "
                                 "token.")
-
diff --git a/unittests/test_record.py b/unittests/test_record.py
index 850e9c69..2738d792 100644
--- a/unittests/test_record.py
+++ b/unittests/test_record.py
@@ -45,6 +45,7 @@ def test_property_access():
     assert rec.get_property("prop") is not None
     assert rec.get_property("prOp") is not None
 
+
 def test_get_parent_by_name():
     rec = Record(id="123")
     rec.add_parent(name="Test")
@@ -54,12 +55,14 @@ def test_get_parent_by_name():
     assert rec.get_parent("test") is not None
     assert rec.get_parent("tEsT") is not None
 
+
 def test_get_parent_by_id():
     rec = Record(id="123")
     rec.add_parent(234)
     assert rec.get_parent(None) is None
     assert rec.get_parent(234) is not None
 
+
 def test_get_parent_by_entity():
     rec = Record(id="123")
     rt = RecordType("Test", id=234)
diff --git a/unittests/test_server_side_scripting.py b/unittests/test_server_side_scripting.py
index f60a0b72..952b4e08 100644
--- a/unittests/test_server_side_scripting.py
+++ b/unittests/test_server_side_scripting.py
@@ -7,14 +7,16 @@ from caosdb import configure_connection
 
 _REMOVE_FILES_AFTERWARDS = []
 
+
 def setup_module():
     c = configure_connection(password_method="unauthenticated",
-                            implementation=MockUpServerConnection)
+                             implementation=MockUpServerConnection)
     xml = ('<Response><script code="{code}">'
            ' <call>{call}</call>'
            ' <stdout>{stdout}</stdout>'
            ' <stderr>{stderr}</stderr>'
            '</script></Response>')
+
     def scripting_resource(**kwargs):
         assert kwargs["path"] == "scripting"
         content_type = kwargs["headers"]["Content-Type"]
@@ -31,14 +33,15 @@ def setup_module():
         else:
             assert content_type == "application/x-www-form-urlencoded"
             stdout = json.dumps(parse_qs(kwargs["body"].decode("utf-8"),
-                                       encoding="utf-8"))
-        scripting_response = xml.format(code = "123",
-                                        call = "call string",
-                                        stdout = stdout,
-                                        stderr = "stderr string")
+                                         encoding="utf-8"))
+        scripting_response = xml.format(code="123",
+                                        call="call string",
+                                        stdout=stdout,
+                                        stderr="stderr string")
         return MockUpResponse(200, {}, scripting_response)
     c._delegate_connection.resources.append(scripting_resource)
 
+
 def teardown_module():
     from os import remove
     from os.path import exists, isdir
-- 
GitLab