From 1b65bd5c10443f81826e5fb67ab38c4395720d21 Mon Sep 17 00:00:00 2001 From: tb1337 Date: Mon, 18 Dec 2023 06:53:52 +0100 Subject: [PATCH 1/2] Remove unnecessary asterisk --- pypaperless/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pypaperless/api.py b/pypaperless/api.py index d1f936d..f0b9cc2 100644 --- a/pypaperless/api.py +++ b/pypaperless/api.py @@ -58,7 +58,7 @@ async def list(self) -> list[int] | None: """Return a list of all entity ids, if applicable.""" res = await self._paperless.request("get", self._endpoint) if "all" in res: - return [*res["all"]] + return res["all"] self._logger.debug("List result is empty.") From 42d6071de924c318ea091b1e8ecb1d841af9766f Mon Sep 17 00:00:00 2001 From: tb1337 Date: Mon, 18 Dec 2023 10:13:36 +0100 Subject: [PATCH 2/2] Fix wrong package dist due to manifest --- .vscode/launch.json | 2 +- MANIFEST.in | 4 ++-- example/usage.py | 22 ++++++++++++++++------ pypaperless/__init__.py | 4 +--- pypaperless/models/__init__.py | 2 +- pyproject.toml | 4 ++-- 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index fbd0c4f..42d0922 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "name": "Python: Aktuelle Datei", "type": "python", "request": "launch", - "program": "++mytest.py", + "program": "example/usage.py", "console": "integratedTerminal", "justMyCode": true } diff --git a/MANIFEST.in b/MANIFEST.in index 7aa6f69..f9203b9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -include *.txt include *.md +include *.txt include LICENSE -recursive-include *.txt +graft pypaperless diff --git a/example/usage.py b/example/usage.py index 531dcbd..f6aaf2b 100644 --- a/example/usage.py +++ b/example/usage.py @@ -2,16 +2,24 @@ import asyncio import logging +import os.path +import sys -from pypaperless import Paperless +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))) + +logging.basicConfig( + level=logging.DEBUG, + format="%(levelname)-8s %(name)s - %(message)s", +) + +from pypaperless import Paperless # noqa paperless = Paperless( "localhost:8000", - "ultra-secret-api-token", + # replace with your own token + "17d85e03b83c4bfd9aa0e9a4e71dc3b79265d51e", request_opts={"ssl": False}, ) -paperless.logger.setLevel(logging.DEBUG) -paperless.logger.addHandler(logging.StreamHandler()) async def main(): @@ -23,8 +31,10 @@ async def main(): documents = await p.documents.get(page=1) for item in documents.items: - print(f"Correspondent of document {item.id} is: {correspondents[item.correspondent]}!") - await asyncio.sleep(0.05) + print( + f"Correspondent of document {item.id} is: {correspondents[item.correspondent].name}!" # noqa + ) + await asyncio.sleep(0.25) if __name__ == "__main__": diff --git a/pypaperless/__init__.py b/pypaperless/__init__.py index 12ae205..ae174aa 100644 --- a/pypaperless/__init__.py +++ b/pypaperless/__init__.py @@ -1,7 +1,5 @@ """PyPaperless.""" -from __future__ import annotations - import logging from typing import Any @@ -205,7 +203,7 @@ async def request(self, method: str, endpoint: str, **kwargs): return await res.json() return await res.read() - async def __aenter__(self) -> Paperless: + async def __aenter__(self) -> "Paperless": """Return context manager.""" await self.initialize() return self diff --git a/pypaperless/models/__init__.py b/pypaperless/models/__init__.py index b551229..1f4ec48 100644 --- a/pypaperless/models/__init__.py +++ b/pypaperless/models/__init__.py @@ -1,4 +1,4 @@ -"""Schemas for paperless objects.""" +"""Models for Paperless resources.""" from .consumption_templates import ConsumptionTemplate from .correspondents import Correspondent, CorrespondentPost diff --git a/pyproject.toml b/pyproject.toml index 6d64490..639e692 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,9 +17,9 @@ classifiers = [ "Environment :: Console", "Framework :: AsyncIO", "Intended Audience :: Developers", - "Intended Audience :: End Users/Desktop", "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3.11", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", "Software Development :: Libraries :: Python Modules" ] dependencies = [