pypaperless-cli2 0.1.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/PKG-INFO +15 -7
  2. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/README.md +14 -6
  3. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/pyproject.toml +1 -1
  4. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/commands/document/edit.py +5 -5
  5. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/utils/converters/__init__.py +1 -0
  6. pypaperless_cli2-0.2.1/src/pypaperless_cli/utils/converters/date.py +29 -0
  7. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/utils/types.py +5 -0
  8. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/LICENSE +0 -0
  9. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/__init__.py +0 -0
  10. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/api.py +0 -0
  11. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/app.py +0 -0
  12. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/commands/__init__.py +0 -0
  13. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/commands/auth.py +0 -0
  14. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/commands/document/__init__.py +0 -0
  15. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/commands/document/show.py +0 -0
  16. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/config/__init__.py +0 -0
  17. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/config/account.py +0 -0
  18. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/config/config.py +0 -0
  19. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/const.py +0 -0
  20. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/py.typed +0 -0
  21. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/utils/__init__.py +0 -0
  22. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/utils/converters/custom_field.py +0 -0
  23. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/utils/converters/helpers/__init__.py +0 -0
  24. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/utils/converters/helpers/strtobool.py +0 -0
  25. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/utils/converters/tag.py +0 -0
  26. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/utils/groups.py +0 -0
  27. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/utils/highlighter.py +0 -0
  28. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/utils/validators/__init__.py +0 -0
  29. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/utils/validators/custom_field.py +0 -0
  30. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/utils/validators/document.py +0 -0
  31. {pypaperless_cli2-0.1.0 → pypaperless_cli2-0.2.1}/src/pypaperless_cli/utils/validators/tag.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pypaperless-cli2
3
- Version: 0.1.0
3
+ Version: 0.2.1
4
4
  Summary: Command-line interface for Paperless-ngx (fork of pypaperless-cli, updated for pypaperless 5.x / Paperless-ngx 3.x)
5
5
  License-File: LICENSE
6
6
  Author: Marcel Brückner
@@ -24,16 +24,14 @@ Description-Content-Type: text/markdown
24
24
 
25
25
  Paperless-ngx Command-Line Interface
26
26
 
27
- This is a fork of [Marcel Brückner's `pypaperless-cli`](https://github.com/marcelbrueckner/paperless-ngx-cli), republished as `pypaperless-cli2` with the `pypaperless` dependency updated to `^5.1.0` for compatibility with Paperless-ngx ≥3.0 (which rejects the older API versions requested by `pypaperless` 4.x with `406 Not Acceptable`). The `pngx` command and all usage below are unchanged from upstream.
27
+ This is a fork of [Marcel Brückner's `pypaperless-cli`](https://github.com/marcelbrueckner/paperless-ngx-cli).
28
28
 
29
- I've recently started a project to collect scripts around Paperless-ngx ([paperless.sh](https://paperless.sh)). It turned out - surprise - to be very tedious to write a separate [script](https://github.com/marcelbrueckner/paperless.sh/blob/6cc85b20482e0281d9e26ab82fcaccf34e27a276/scripts/post-consumption/content-matching/pngx-update-document.py) [each](https://github.com/marcelbrueckner/paperless.sh/blob/6cc85b20482e0281d9e26ab82fcaccf34e27a276/scripts/api/custom-field-sum/custom-field-sum.py) [time](https://github.com/marcelbrueckner/paperless.sh/blob/6cc85b20482e0281d9e26ab82fcaccf34e27a276/scripts/api/custom-field-sum/custom-field-sum-of-differences.py) I need to work with Paperless-ngx's API.
30
- I was looking for a way to easily update certain fields of my documents but without the overhead of "manually" calling API endpoints each time.
31
- I wrapped things in simple python scripts which eventually became this tool which essentially ~~is~~ will become Paperless-ngx at your command-line.
29
+ After updating my Paperless-ngx instances to version 3.x the current pypaperless-cli package has thrown some errors when editing documents.
30
+ I republished the current pypaperless-cli as `pypaperless-cli2` with the `pypaperless` dependency updated to `^5.1.0` for compatibility with Paperless-ngx ≥3.0 (which rejects the older API versions requested by `pypaperless` 4.x with `406 Not Acceptable`).
31
+ The `pngx` command and all usage below are unchanged from upstream.
32
32
 
33
33
  ## Usage
34
34
 
35
- This very first public release currently only allows you to retrieve information or update certain fields of your existing documents (with more to come in the future).
36
-
37
35
  ```bash
38
36
  # Run pngx -h for help
39
37
  $ pngx [ command ] [ subcommand ] [ arguments and parameters ]
@@ -67,6 +65,16 @@ Update a document's title and correspondent.
67
65
  $ pngx document edit <ID> --title "My new document title" --correspondent <CORRESPONDENT_ID>
68
66
  ```
69
67
 
68
+ Update a document's creation date.
69
+
70
+ The Paperless-ngx API expects the date in ISO 8601 format. With Version 0.2.0 of this package comes a dateparser which auto-detects the used date format and converts it to ISO 8601 format.
71
+
72
+ ```bash
73
+ # Set document creation date to "14.09.2026"
74
+ $ pngx document edit <ID> --created-date 14.09.2026
75
+ # The date parser automatically converts the date to 2026-09-14 and uses it in the communication with the API
76
+ ```
77
+
70
78
  Assign or unassign a document's tags.
71
79
 
72
80
  Tags can be specified by ID or the *exact* name. If your tag name contains spaces, wrap it in quotes.
@@ -2,16 +2,14 @@
2
2
 
3
3
  Paperless-ngx Command-Line Interface
4
4
 
5
- This is a fork of [Marcel Brückner's `pypaperless-cli`](https://github.com/marcelbrueckner/paperless-ngx-cli), republished as `pypaperless-cli2` with the `pypaperless` dependency updated to `^5.1.0` for compatibility with Paperless-ngx ≥3.0 (which rejects the older API versions requested by `pypaperless` 4.x with `406 Not Acceptable`). The `pngx` command and all usage below are unchanged from upstream.
5
+ This is a fork of [Marcel Brückner's `pypaperless-cli`](https://github.com/marcelbrueckner/paperless-ngx-cli).
6
6
 
7
- I've recently started a project to collect scripts around Paperless-ngx ([paperless.sh](https://paperless.sh)). It turned out - surprise - to be very tedious to write a separate [script](https://github.com/marcelbrueckner/paperless.sh/blob/6cc85b20482e0281d9e26ab82fcaccf34e27a276/scripts/post-consumption/content-matching/pngx-update-document.py) [each](https://github.com/marcelbrueckner/paperless.sh/blob/6cc85b20482e0281d9e26ab82fcaccf34e27a276/scripts/api/custom-field-sum/custom-field-sum.py) [time](https://github.com/marcelbrueckner/paperless.sh/blob/6cc85b20482e0281d9e26ab82fcaccf34e27a276/scripts/api/custom-field-sum/custom-field-sum-of-differences.py) I need to work with Paperless-ngx's API.
8
- I was looking for a way to easily update certain fields of my documents but without the overhead of "manually" calling API endpoints each time.
9
- I wrapped things in simple python scripts which eventually became this tool which essentially ~~is~~ will become Paperless-ngx at your command-line.
7
+ After updating my Paperless-ngx instances to version 3.x the current pypaperless-cli package has thrown some errors when editing documents.
8
+ I republished the current pypaperless-cli as `pypaperless-cli2` with the `pypaperless` dependency updated to `^5.1.0` for compatibility with Paperless-ngx ≥3.0 (which rejects the older API versions requested by `pypaperless` 4.x with `406 Not Acceptable`).
9
+ The `pngx` command and all usage below are unchanged from upstream.
10
10
 
11
11
  ## Usage
12
12
 
13
- This very first public release currently only allows you to retrieve information or update certain fields of your existing documents (with more to come in the future).
14
-
15
13
  ```bash
16
14
  # Run pngx -h for help
17
15
  $ pngx [ command ] [ subcommand ] [ arguments and parameters ]
@@ -45,6 +43,16 @@ Update a document's title and correspondent.
45
43
  $ pngx document edit <ID> --title "My new document title" --correspondent <CORRESPONDENT_ID>
46
44
  ```
47
45
 
46
+ Update a document's creation date.
47
+
48
+ The Paperless-ngx API expects the date in ISO 8601 format. With Version 0.2.0 of this package comes a dateparser which auto-detects the used date format and converts it to ISO 8601 format.
49
+
50
+ ```bash
51
+ # Set document creation date to "14.09.2026"
52
+ $ pngx document edit <ID> --created-date 14.09.2026
53
+ # The date parser automatically converts the date to 2026-09-14 and uses it in the communication with the API
54
+ ```
55
+
48
56
  Assign or unassign a document's tags.
49
57
 
50
58
  Tags can be specified by ID or the *exact* name. If your tag name contains spaces, wrap it in quotes.
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pypaperless-cli2"
3
- version = "0.1.0"
3
+ version = "0.2.1"
4
4
  description = "Command-line interface for Paperless-ngx (fork of pypaperless-cli, updated for pypaperless 5.x / Paperless-ngx 3.x)"
5
5
  authors = ["Marcel Brückner <marcelbrueckner@users.noreply.github.com>"]
6
6
  readme = "README.md"
@@ -8,7 +8,7 @@ from pypaperless.models.common import CustomFieldValue
8
8
 
9
9
  from pypaperless_cli.api import PaperlessAsyncAPI
10
10
  from pypaperless_cli.utils import converters, groups, validators
11
- from pypaperless_cli.utils.types import CustomFieldKeyValue, Document
11
+ from pypaperless_cli.utils.types import CustomFieldKeyValue, Date, Document
12
12
 
13
13
  group_tags = Group(name = "Tags parameters", sort_key=groups.standard_fields.sort_key+1)
14
14
  group_custom_fields = Group(name = "Custom fields parameters", sort_key=group_tags.sort_key+1)
@@ -21,7 +21,7 @@ async def edit(
21
21
  document_type: Optional[int] = None,
22
22
  storage_path: Optional[int] = None,
23
23
  title: Optional[str] = None,
24
- created_date: Optional[str] = None,
24
+ created_date: Optional[Date] = None,
25
25
 
26
26
  # Handle tags
27
27
  add_tags: Annotated[
@@ -86,7 +86,8 @@ async def edit(
86
86
  title: str
87
87
  Document title
88
88
  created_date: str
89
- The ISO 8601 date (YYYY-MM-DD) the document was initially issued.
89
+ The date the document was initially issued. Accepts several formats, e.g. YYYY-MM-DD
90
+ (ISO 8601) or DD.MM.YYYY (German), and normalizes them automatically.
90
91
 
91
92
  add_tags: List[str|int]
92
93
  Assign tags. Requires the ID or the exact name of the tags.
@@ -121,8 +122,7 @@ async def edit(
121
122
  document.title = title
122
123
 
123
124
  if created_date:
124
- from datetime import datetime
125
- document.created = datetime.strptime(created_date, "%Y-%m-%d").date()
125
+ document.created = created_date
126
126
 
127
127
  if remove_tags:
128
128
  # Only keep tags not in `remove_tags``
@@ -4,6 +4,7 @@ from typing import Any
4
4
 
5
5
 
6
6
  from pypaperless_cli.utils.converters.custom_field import custom_field_name_to_id
7
+ from pypaperless_cli.utils.converters.date import parse_date
7
8
  from pypaperless_cli.utils.converters.tag import tag_name_to_id
8
9
 
9
10
  import pypaperless_cli.utils.converters.helpers
@@ -0,0 +1,29 @@
1
+ """Date related converter"""
2
+
3
+ from typing import Any
4
+
5
+ import arrow
6
+
7
+ # Formats are tried in order until one matches; the first match wins.
8
+ # Day-first is assumed for dot/slash-separated dates (e.g. German invoices use DD.MM.YYYY),
9
+ # so MM/DD/YYYY-style US dates are deliberately not included to avoid ambiguity.
10
+ SUPPORTED_DATE_FORMATS = [
11
+ "YYYY-MM-DD",
12
+ "DD.MM.YYYY",
13
+ "DD.MM.YY",
14
+ "DD/MM/YYYY",
15
+ "YYYY/MM/DD",
16
+ ]
17
+
18
+ def parse_date(type_, *args) -> Any:
19
+ """Parses a date given in any of `SUPPORTED_DATE_FORMATS` into a `date` object."""
20
+
21
+ value = args[0]
22
+
23
+ try:
24
+ return arrow.get(value, SUPPORTED_DATE_FORMATS).date()
25
+ except arrow.parser.ParserError:
26
+ raise ValueError(
27
+ f"\"{value}\" is not a recognized date. Supported formats: "
28
+ + ", ".join(SUPPORTED_DATE_FORMATS)
29
+ )
@@ -1,5 +1,6 @@
1
1
  """Custom variable types."""
2
2
 
3
+ from datetime import date
3
4
  from typing import Annotated
4
5
 
5
6
  from cyclopts import Parameter
@@ -21,6 +22,10 @@ Document = Annotated[int, Parameter(
21
22
  validator = validators.document_exists
22
23
  )]
23
24
 
25
+ Date = Annotated[date, Parameter(
26
+ converter = converters.parse_date
27
+ )]
28
+
24
29
  CustomFieldKeyValue = Annotated[str|int, Parameter(
25
30
  converter = converters.custom_field_name_to_id,
26
31
  validator = validators.custom_field_exists