Skip to content

Commit

Permalink
Merge branch 'master' into chore/update_project_files
Browse files Browse the repository at this point in the history
  • Loading branch information
tb1337 authored Dec 19, 2023
2 parents dfaac3d + 8b9135a commit a7dc991
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Python: Aktuelle Datei",
"type": "python",
"request": "launch",
"program": "++mytest.py",
"program": "example/usage.py",
"console": "integratedTerminal",
"justMyCode": true
}
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include *.txt
include *.md
include *.txt
include LICENSE
recursive-include *.txt
graft pypaperless
22 changes: 16 additions & 6 deletions example/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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__":
Expand Down
4 changes: 1 addition & 3 deletions pypaperless/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""PyPaperless."""

from __future__ import annotations

import logging
from typing import Any

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pypaperless/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down
2 changes: 1 addition & 1 deletion pypaperless/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Schemas for paperless objects."""
"""Models for Paperless resources."""

from .consumption_templates import ConsumptionTemplate
from .correspondents import Correspondent, CorrespondentPost
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
dependencies = [
"aiohttp"
Expand Down

0 comments on commit a7dc991

Please sign in to comment.