diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5670ca4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,33 @@ +name: Test + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + test: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: "3.14" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r dev_requirements.txt + - name: Lint + run: | + pylint . --recursive=y + - name: Test + run: | + python -m coverage run -m pytest + python -m coverage report diff --git a/.gitignore b/.gitignore index 343ba19..fc1ad26 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ __pycache__/ htmlcov/ dist/ mfiles.egg-info/ -.env/ +.venv/ # Generated documents doc/*/ diff --git a/.pylintrc b/.pylintrc index 567ed3a..bf91946 100644 --- a/.pylintrc +++ b/.pylintrc @@ -2,7 +2,10 @@ # Add files or directories to the blacklist. They should be base names, not # paths. -ignore=examples,.env +ignore=examples,.venv # Use multiple processes to speed up Pylint. jobs=4 + +# Disabled errors +disable=consider-using-f-string diff --git a/.readthedocs.yml b/.readthedocs.yml index 07fa686..187faf4 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,14 +1,16 @@ # Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details -# Required version: 2 -# Build documentation in the docs/ directory with Sphinx -sphinx: - configuration: doc/conf.py +build: + os: "ubuntu-24.04" + tools: + python: "3.12" python: - version: 3.7 install: - - requirements: dev_requirements.txt + - requirements: docs/requirements.txt + +sphinx: + configuration: doc/conf.py diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 11b18c1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: python - -python: - - "3.5" - - "3.6" - - "3.7" - - "3.8" - -install: - - pip install -r dev_requirements.txt - -script: - - pylint_runner - - python -m coverage run -m pytest - - python -m coverage report diff --git a/dev_requirements.txt b/dev_requirements.txt index c0b1096..adbede0 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -2,9 +2,10 @@ coverage pylint pylint_runner pytest -sphinx==1.8.5 -sphinx_rtd_theme==0.4.3 -sphinxcontrib-napoleon==0.7 +setuptools +sphinx +sphinx_rtd_theme +sphinxcontrib-napoleon tbump wheel -r requirements.txt diff --git a/mfiles/client.py b/mfiles/client.py index b104027..081e857 100644 --- a/mfiles/client.py +++ b/mfiles/client.py @@ -140,8 +140,8 @@ def put(self, endpoint, data=None): """ if endpoint[0] == "/": endpoint = endpoint[1:] - request_url = self.server + endpoint - response = self.session.put(request_url, headers=self.headers, data=data) + request_url = self.server + endpoint + "?_method=PUT" + response = self.session.post(request_url, headers=self.headers, data=data) if response.status_code != 200: raise MFilesException(response.text) return response.json() @@ -381,7 +381,7 @@ def create_object(self, name, object_type=0, object_class=0, Returns: dict: Dictionary with object information. """ - # pylint: disable=too-many-arguments + # pylint: disable=too-many-arguments,too-many-positional-arguments extra_info = extra_info or {} file_info = file_info or [] if isinstance(object_type, str): @@ -404,14 +404,14 @@ def create_object(self, name, object_type=0, object_class=0, endpoint = "objects/%s" % object_type return self.post(endpoint, data) - def check_out(self, object_id, object_type=0): + def check_out(self, object_id, object_version="latest", object_type=0): """Check out an object from M-Files.""" data = json.dumps({"Value": "2"}) # Checked out by me - endpoint = "objects/%s/%s/latest/checkedout" % \ - (object_type, object_id) + endpoint = "objects/%s/%s/%s/checkedout" % \ + (object_type, object_id, object_version) return self.put(endpoint, data) - def check_in(self, object_id, object_version, object_type=0): + def check_in(self, object_id, object_version="latest", object_type=0): """Check in an object to M-Files.""" data = json.dumps({"Value": "0"}) # Checked in endpoint = "objects/%s/%s/%s/checkedout" % \ @@ -476,7 +476,7 @@ def download_file(self, local_path, object_type, object_id, file_id, Returns: bool: True if file is found and downloaded successfully. """ - # pylint: disable=too-many-arguments + # pylint: disable=too-many-arguments,too-many-positional-arguments request_url = "%sobjects/%s/%s/%s/files/%s/content" % \ (self.server, object_type, object_id, object_version, file_id) response = self.session.get(request_url, headers=self.headers) diff --git a/requirements.txt b/requirements.txt index 2d5d47b..f229360 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -requests~=2.5 +requests diff --git a/setup.py b/setup.py index ba27c2a..95eaa2c 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup( name='mfiles', packages=find_packages(), - version='0.5.3', + version='0.5.4', license='MIT', description='M-Files API wrapper', long_description=PYPI_DESCRIPTION, @@ -19,7 +19,6 @@ author_email='emil.hjelm@climeon.com', url='https://github.com/afcmrp/python-mfiles', keywords=['M-Files', 'mfiles', 'REST', 'API'], - python_requires='!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', install_requires=[ 'requests', ], diff --git a/tbump.toml b/tbump.toml index eab1840..a7346a3 100644 --- a/tbump.toml +++ b/tbump.toml @@ -1,5 +1,5 @@ [version] -current = "0.5.3" +current = "0.5.4" # Example of a semver regexp. # Make sure this matches current_version before