Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ __pycache__/
htmlcov/
dist/
mfiles.egg-info/
.env/
.venv/

# Generated documents
doc/*/
5 changes: 4 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 8 additions & 6 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

7 changes: 4 additions & 3 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 8 additions & 8 deletions mfiles/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand All @@ -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" % \
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
requests~=2.5
requests
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
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,
author='Emil Hjelm',
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',
],
Expand Down
2 changes: 1 addition & 1 deletion tbump.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down