diff --git a/__init__.py b/__init__.py deleted file mode 100644 index 00c8ae3..0000000 --- a/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -import platform -import subprocess -import sys -import setuptools -import pathlib -import os - -name = "caffa" - -current_dir = os.path.abspath(os.curdir) -caffa_dir = os.path.dirname(__file__) -os.chdir(current_dir) - -from .restclient import RestClient, SessionType -from .object import Object, create_class, create_method_class -from .method import Method diff --git a/caffa/__init__.py b/caffa/__init__.py new file mode 100644 index 0000000..099f0be --- /dev/null +++ b/caffa/__init__.py @@ -0,0 +1,7 @@ +from .restclient import RestClient as RestClient, SessionType as SessionType +from .object import ( + Object as Object, + create_class as create_class, + create_method_class as create_method_class, +) +from .method import Method as Method diff --git a/method.py b/caffa/method.py similarity index 97% rename from method.py rename to caffa/method.py index 3c711f6..43d318c 100644 --- a/method.py +++ b/caffa/method.py @@ -16,7 +16,6 @@ # See the GNU Lesser General Public License at <> # for more details. # -import json import logging @@ -60,7 +59,7 @@ def name(self): def make_read_lambda(property_name): - return lambda self: self_self_object.get(property_name) + return lambda self: self._self_object.get(property_name) def make_write_lambda(property_name): diff --git a/object.py b/caffa/object.py similarity index 99% rename from object.py rename to caffa/object.py index 5e73c51..33b2255 100644 --- a/object.py +++ b/caffa/object.py @@ -19,7 +19,7 @@ import json import logging -from .method import Method, create_method_class +from .method import create_method_class class Object(object): diff --git a/restclient.py b/caffa/restclient.py similarity index 96% rename from restclient.py rename to caffa/restclient.py index a78c424..c00b60c 100644 --- a/restclient.py +++ b/caffa/restclient.py @@ -46,14 +46,14 @@ class RestClient: delay_between_attempts = 0.5 def __init__( - self, - hostname, - port=50000, - username="", - password="", - min_app_version=MIN_APP_VERSION, - max_app_version=MAX_APP_VERSION, - session_type=SessionType.REGULAR, + self, + hostname, + port=50000, + username="", + password="", + min_app_version=MIN_APP_VERSION, + max_app_version=MAX_APP_VERSION, + session_type=SessionType.REGULAR, ): self.hostname = hostname self.port = port @@ -315,9 +315,9 @@ def check_version(self, min_app_version, max_app_version): max_app_version[2], ) if ( - app_info.major_version, - app_info.minor_version, - app_info.patch_version, + app_info.major_version, + app_info.minor_version, + app_info.patch_version, ) < min_app_version: return ( False, @@ -331,9 +331,9 @@ def check_version(self, min_app_version, max_app_version): ), ) if ( - app_info.major_version, - app_info.minor_version, - app_info.patch_version, + app_info.major_version, + app_info.minor_version, + app_info.patch_version, ) > max_app_version: return ( False, diff --git a/conftest.py b/conftest.py deleted file mode 100644 index 1d23963..0000000 --- a/conftest.py +++ /dev/null @@ -1,6 +0,0 @@ -import os -import pytest -import sys - -current_dir = os.path.dirname(__file__) -os.chdir(current_dir) diff --git a/pyproject.toml b/pyproject.toml index 59eba4d..e587300 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,30 @@ [build-system] -requires = ["setuptool>=42"] +requires = ["setuptools>=62"] build-backend = "setuptools.build_meta" + +[project] +name = "caffa" +version = "1.6.0" +description = "Python bindings for caffa" +readme = "README.md" +requires-python = ">=3.6" +license = { file = "LICENSE" } +authors = [{ name = "Gaute Lindkvist", email = "lindkvis@gmail.com" }] +maintainers = [ + { name = "Gaute Lindkvist", email = "lindkvis@gmail.com" }, +] +classifiers = [ + "Intended Audience :: Developers", + "License :: OSI Approved :: LGPL License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", +] +dependencies = ["requests"] + +[project.optional-dependencies] +dev = ["pytest"] + +[project.urls] +"Homepage" = "https://github.com/lindkvis/caffa-python" +"Bug Reports" = "https://github.com/lindkvis/caffa-python/issues" +"Source" = "https://github.com/lindkvis/caffa-python" diff --git a/setup.py b/setup.py deleted file mode 100644 index 53acd03..0000000 --- a/setup.py +++ /dev/null @@ -1,30 +0,0 @@ -import os -import pathlib -import setuptools - -from subprocess import check_call - -with open("README.md", "r", encoding="utf-8") as fh: - long_description = fh.read() - -setuptools.setup( - name="caffa-python", - version="1.6.0", - author="Gaute Lindkvist", - author_email="lindkvis@gmail.com", - description="Python bindings for caffa", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/lindkvis/caffa-python", - project_urls={ - "Bug Tracker": "https://github.com/caffa/issues", - }, - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: LGPL License", - "Operating System :: OS Independent", - ], - package_dir={"": "."}, - packages=setuptools.find_packages(where="."), - python_requires=">=3.6", -) diff --git a/tests/test_client.py b/tests/test_client.py index bbb00de..044787a 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -24,13 +24,13 @@ def test_app_info(): assert app_info is not None assert app_info.name != "" app_string = ( - app_info.name - + " v" - + str(app_info.major_version) - + "." - + str(app_info.minor_version) - + "." - + str(app_info.patch_version) + app_info.name + + " v" + + str(app_info.major_version) + + "." + + str(app_info.minor_version) + + "." + + str(app_info.patch_version) ) log.info("App info: %s", app_string) diff --git a/tests/test_objects.py b/tests/test_objects.py index c5d74d7..41c0c68 100644 --- a/tests/test_objects.py +++ b/tests/test_objects.py @@ -36,7 +36,7 @@ def test_fields(self): try: doc.id = "AnotherName" pytest.fail("Should have failed to write to document id, but succeeded!") - except Exception as e: + except Exception: print("Got expected error") assert doc.id == "testDocument" @@ -44,7 +44,7 @@ def test_fields(self): try: doc.nonExistantField = "Test" pytest.fail("Should get an exception!") - except Exception as e: + except Exception: print("Got the expected exception for field not found") def test_children(self): @@ -96,7 +96,7 @@ def test_non_existing_field(self): doc = self.testApp.document("testDocument") assert doc is not None try: - value = doc.does_not_exist + doc.does_not_exist pytest.fail("Should have had exception, but got none!") except Exception as e: log.info( @@ -134,7 +134,7 @@ def test_app_enum(self): except Exception as e: log.info( - "Got expected exception when trying to assign an invalid enum value: '0'".format( + "Got expected exception when trying to assign an invalid enum value: '{0}'".format( e ) )