shortbox 0.4.0__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 (43) hide show
  1. shortbox-0.4.0/.gitattributes +119 -0
  2. shortbox-0.4.0/.gitignore +21 -0
  3. shortbox-0.4.0/.pre-commit-config.yaml +94 -0
  4. shortbox-0.4.0/PKG-INFO +141 -0
  5. shortbox-0.4.0/README.md +105 -0
  6. shortbox-0.4.0/pdm.toml +2 -0
  7. shortbox-0.4.0/pylock.toml +1643 -0
  8. shortbox-0.4.0/pyproject.toml +162 -0
  9. shortbox-0.4.0/renovate.json +6 -0
  10. shortbox-0.4.0/schemas/v2.0/ComicInfo.xsd +123 -0
  11. shortbox-0.4.0/shortbox/__init__.py +4 -0
  12. shortbox-0.4.0/shortbox/archives/__init__.py +27 -0
  13. shortbox-0.4.0/shortbox/archives/base.py +39 -0
  14. shortbox-0.4.0/shortbox/archives/pdf.py +82 -0
  15. shortbox-0.4.0/shortbox/archives/rar.py +55 -0
  16. shortbox-0.4.0/shortbox/archives/sevenzip.py +70 -0
  17. shortbox-0.4.0/shortbox/archives/tar.py +60 -0
  18. shortbox-0.4.0/shortbox/archives/zip.py +97 -0
  19. shortbox-0.4.0/shortbox/comic.py +216 -0
  20. shortbox-0.4.0/shortbox/errors.py +34 -0
  21. shortbox-0.4.0/shortbox/metadata/__init__.py +9 -0
  22. shortbox-0.4.0/shortbox/metadata/base.py +105 -0
  23. shortbox-0.4.0/shortbox/metadata/comic_info.py +252 -0
  24. shortbox-0.4.0/shortbox/metadata/metron_info.py +337 -0
  25. shortbox-0.4.0/shortbox/registries.py +48 -0
  26. shortbox-0.4.0/shortbox/utils.py +18 -0
  27. shortbox-0.4.0/tests/__init__.py +0 -0
  28. shortbox-0.4.0/tests/conftest.py +8 -0
  29. shortbox-0.4.0/tests/metadata/__init__.py +0 -0
  30. shortbox-0.4.0/tests/metadata/test_comic_info.py +25 -0
  31. shortbox-0.4.0/tests/metadata/test_metron_info.py +25 -0
  32. shortbox-0.4.0/tests/resources/001.jxl +0 -0
  33. shortbox-0.4.0/tests/resources/002.jpg +0 -0
  34. shortbox-0.4.0/tests/resources/ComicInfo.xml +376 -0
  35. shortbox-0.4.0/tests/resources/MetronInfo.xml +27 -0
  36. shortbox-0.4.0/tests/resources/archive-01.7z +0 -0
  37. shortbox-0.4.0/tests/resources/archive-01.cb7 +0 -0
  38. shortbox-0.4.0/tests/resources/archive-01.cbt +0 -0
  39. shortbox-0.4.0/tests/resources/archive-01.cbz +0 -0
  40. shortbox-0.4.0/tests/resources/archive-01.tar +0 -0
  41. shortbox-0.4.0/tests/resources/archive-01.zip +0 -0
  42. shortbox-0.4.0/tests/test_comic.py +120 -0
  43. shortbox-0.4.0/uv.lock +1486 -0
@@ -0,0 +1,119 @@
1
+ # Common settings that generally should always be used with your language specific settings
2
+
3
+ # Auto detect text files and perform LF normalization
4
+ * text=auto
5
+
6
+ #
7
+ # The above will handle all files NOT found below
8
+ #
9
+
10
+ # Documents
11
+ *.bibtex text diff=bibtex
12
+ *.doc diff=astextplain
13
+ *.DOC diff=astextplain
14
+ *.docx diff=astextplain
15
+ *.DOCX diff=astextplain
16
+ *.dot diff=astextplain
17
+ *.DOT diff=astextplain
18
+ *.pdf diff=astextplain
19
+ *.PDF diff=astextplain
20
+ *.rtf diff=astextplain
21
+ *.RTF diff=astextplain
22
+ *.md text diff=markdown
23
+ *.mdx text diff=markdown
24
+ *.tex text diff=tex
25
+ *.adoc text
26
+ *.textile text
27
+ *.mustache text
28
+ *.csv text eol=crlf
29
+ *.tab text
30
+ *.tsv text
31
+ *.txt text
32
+ *.sql text
33
+ *.epub diff=astextplain
34
+
35
+ # Graphics
36
+ *.png binary
37
+ *.jpg binary
38
+ *.jpeg binary
39
+ *.gif binary
40
+ *.tif binary
41
+ *.tiff binary
42
+ *.ico binary
43
+ # SVG treated as text by default.
44
+ *.svg text
45
+ # If you want to treat it as binary,
46
+ # use the following line instead.
47
+ # *.svg binary
48
+ *.eps binary
49
+
50
+ # Scripts
51
+ *.bash text eol=lf
52
+ *.fish text eol=lf
53
+ *.sh text eol=lf
54
+ *.zsh text eol=lf
55
+ # These are explicitly windows files and should use crlf
56
+ *.bat text eol=crlf
57
+ *.cmd text eol=crlf
58
+ *.ps1 text eol=crlf
59
+
60
+ # Serialisation
61
+ *.json text
62
+ *.toml text
63
+ *.xml text
64
+ *.yaml text
65
+ *.yml text
66
+
67
+ # Archives
68
+ *.7z binary
69
+ *.cb7 binary
70
+ *.gz binary
71
+ *.tar binary
72
+ *.cbt binary
73
+ *.tgz binary
74
+ *.zip binary
75
+ *.cbz binary
76
+
77
+ # Text files where line endings should be preserved
78
+ *.patch -text
79
+
80
+ #
81
+ # Exclude files from exporting
82
+ #
83
+
84
+ .gitattributes export-ignore
85
+ .gitignore export-ignore
86
+ .gitkeep export-ignore
87
+ # Apply override to all files in the directory
88
+ *.md linguist-detectable
89
+ # Basic .gitattributes for a python repo.
90
+
91
+ # Source files
92
+ # ============
93
+ *.pxd text diff=python
94
+ *.py text diff=python
95
+ *.py3 text diff=python
96
+ *.pyw text diff=python
97
+ *.pyx text diff=python
98
+ *.pyz text diff=python
99
+ *.pyi text diff=python
100
+
101
+ # Binary files
102
+ # ============
103
+ *.db binary
104
+ *.p binary
105
+ *.pkl binary
106
+ *.pickle binary
107
+ *.pyc binary export-ignore
108
+ *.pyo binary export-ignore
109
+ *.pyd binary
110
+
111
+ # Jupyter notebook
112
+ *.ipynb text eol=lf
113
+
114
+ # Note: .db, .p, and .pkl files are associated
115
+ # with the python modules ``pickle``, ``dbm.*``,
116
+ # ``shelve``, ``marshal``, ``anydbm``, & ``bsddb``
117
+ # (among others).
118
+ # Fix syntax highlighting on GitHub to allow comments
119
+ .vscode/*.json linguist-language=JSON-with-Comments
@@ -0,0 +1,21 @@
1
+ # =====Folders=====
2
+ __pycache__/
3
+ __pypackages__/
4
+ .idea/
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ .tox/
8
+ .venv/
9
+ build/
10
+ dist/
11
+ logs/
12
+ site/
13
+
14
+ # =====Files=====
15
+ *.iml
16
+ *.log
17
+ *.txt
18
+ .coverage
19
+ .envrc
20
+ .pdm-python
21
+ .python-version
@@ -0,0 +1,94 @@
1
+ repos:
2
+ - repo: local
3
+ hooks:
4
+ - id: toml-sort
5
+ args:
6
+ - "--in-place"
7
+ entry: toml-sort
8
+ exclude: "uv.lock|pylock.toml"
9
+ language: system
10
+ name: toml sort
11
+ types:
12
+ - toml
13
+ - id: mdformat
14
+ args:
15
+ - "--number"
16
+ - "--wrap=keep"
17
+ entry: mdformat
18
+ language: system
19
+ name: mdformat
20
+ types:
21
+ - markdown
22
+ - id: ruff-check
23
+ entry: ruff check .
24
+ language: system
25
+ name: ruff check
26
+ pass_filenames: false
27
+ types:
28
+ - python
29
+ - id: ruff-format
30
+ entry: ruff format .
31
+ language: system
32
+ name: ruff format
33
+ pass_filenames: false
34
+ types:
35
+ - python
36
+ - id: ty
37
+ entry: ty check .
38
+ language: system
39
+ name: ruff check
40
+ pass_filenames: false
41
+ types:
42
+ - python
43
+ - repo: "https://github.com/pre-commit/pre-commit-hooks"
44
+ rev: v6.0.0
45
+ hooks:
46
+ - id: check-ast
47
+ - id: check-builtin-literals
48
+ - id: check-docstring-first
49
+ - id: debug-statements
50
+ - id: forbid-submodules
51
+ - repo: builtin
52
+ hooks:
53
+ - id: check-added-large-files
54
+ args:
55
+ - "--enforce-all"
56
+ - id: check-case-conflict
57
+ # - id: check-executables-have-shebangs
58
+ # - id: check-illegal-windows-names
59
+ # - id: check-json
60
+ # - id: check-json5
61
+ - id: check-merge-conflict
62
+ args:
63
+ - "--assume-in-merge"
64
+ - id: check-shebang-scripts-are-executable
65
+ # - id: check-symlinks
66
+ - id: check-toml
67
+ - id: check-vcs-permalinks
68
+ - id: check-xml
69
+ - id: check-yaml
70
+ args:
71
+ - "--allow-multiple-documents"
72
+ - id: destroyed-symlinks
73
+ - id: detect-private-key
74
+ - id: end-of-file-fixer
75
+ exclude_types:
76
+ - json
77
+ - svg
78
+ - xml
79
+ - id: fix-byte-order-marker
80
+ - id: mixed-line-ending
81
+ args:
82
+ - "--fix=auto"
83
+ # - id: pretty-format-json
84
+ # args:
85
+ # - "--autofix"
86
+ # - "--indent=2"
87
+ # - "--no-ensure-ascii"
88
+ - id: trailing-whitespace
89
+ args:
90
+ - "--markdown-linebreak-ext=md"
91
+ - repo: meta
92
+ hooks:
93
+ - id: check-hooks-apply
94
+ - id: check-useless-excludes
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.5
2
+ Name: shortbox
3
+ Version: 0.4.0
4
+ Summary: An extensible library to manage comic archives and their embedded files and metadata.
5
+ Project-URL: Homepage, https://pypi.org/project/shortbox
6
+ Project-URL: Issues, https://codeberg.org/buriedincode/shortbox/issues
7
+ Project-URL: Source, https://codeberg.org/buriedincode/shortbox
8
+ Author-email: BuriedInCode <buriedincode@duckpond.nz>
9
+ Maintainer-email: BuriedInCode <buriedincode@duckpond.nz>
10
+ License-Expression: MIT
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Natural Language :: English
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: msgspec-extras>=0.2.0
25
+ Requires-Dist: msgspec-xml>=0.3.0
26
+ Requires-Dist: natsort>=8.4.0
27
+ Requires-Dist: xmlschema>=4.3.0
28
+ Requires-Dist: zipremove>=0.10.0
29
+ Provides-Extra: cb7
30
+ Requires-Dist: py7zr>=1.1.0; extra == 'cb7'
31
+ Provides-Extra: cbr
32
+ Requires-Dist: rarfile>=4.5; extra == 'cbr'
33
+ Provides-Extra: pdf
34
+ Requires-Dist: comicbox-pdffile>=0.6.0; extra == 'pdf'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # Shortbox
38
+
39
+ [![PyPI - Python](https://img.shields.io/pypi/pyversions/shortbox.svg?logo=Python&label=Python&style=flat-square)](https://pypi.org/p/shortbox/)
40
+ [![PyPI - Status](https://img.shields.io/pypi/status/shortbox.svg?logo=Python&label=Status&style=flat-square)](https://pypi.org/p/shortbox/)
41
+ [![PyPI - Version](https://img.shields.io/pypi/v/shortbox.svg?logo=Python&label=Version&style=flat-square)](https://pypi.org/p/shortbox/)
42
+ [![PyPI - License](https://img.shields.io/pypi/l/shortbox.svg?logo=Python&label=License&style=flat-square)](https://opensource.org/licenses/MIT)
43
+
44
+ [![prek](https://img.shields.io/badge/prek-enabled-informational?logo=prek&style=flat-square)](https://github.com/j178/prek)
45
+ [![Ruff](https://img.shields.io/badge/Ruff-enabled-informational?logo=ruff&style=flat-square)](https://github.com/astral-sh/ruff)
46
+ [![ty](https://img.shields.io/badge/ty-enabled-informational?logo=ruff&style=flat-square)](https://github.com/astral-sh/ty)
47
+
48
+ [![status-badge](https://ci.codeberg.org/api/badges/17625/status.svg)](https://ci.codeberg.org/repos/17625)
49
+
50
+ An extensible library to manage comic archives and their embedded files and metadata.
51
+
52
+ ## Supported Formats
53
+
54
+ More can be added by extending the respective base class and adding to the registry.
55
+
56
+ ### Archives
57
+
58
+ | Archive | Extra Required |
59
+ | ---------- | -------------- |
60
+ | .cbz, .zip | _builtin_ |
61
+ | .cbt, .tar | _builtin_ |
62
+ | .cbr, .rar | cbr |
63
+ | .cb7, .7z | cb7 |
64
+ | .pdf | pdf |
65
+
66
+ **Compability Table**
67
+
68
+ | Format | Read | Update | Create |
69
+ | ------ | :--: | :----: | :----: |
70
+ | cbz | ✅ | ✅ | ✅ |
71
+ | cbt | ❌ | ❌ | ✅ |
72
+ | cbr | ✅ | ❌ | ❌ |
73
+ | cb7 | ✅ | ❌ | ✅ |
74
+ | pdf | ✅ | ✅ | ❌ |
75
+
76
+ If something is marked as in-compatible the library will try extracting and making the change via the local system and re-archive (if it has the create capability).
77
+
78
+ ### Metadata
79
+
80
+ - [ComicInfo.xml v2.0](schemas/v2.0/ComicInfo.xsd)
81
+ - [MetronInfo.xml v1.1](https://raw.githubusercontent.com/Metron-Project/metroninfo/master/schema/v1.1/MetronInfo.xsd)
82
+
83
+ ## Installation
84
+
85
+ ```sh
86
+ pdm add shortbox
87
+ ```
88
+
89
+ Optional extras can be added as needed:
90
+
91
+ ```sh
92
+ pdm add shortbox[cbr,cb7,pdf]
93
+ ```
94
+
95
+ ## Usage
96
+
97
+ ```python
98
+ from pathlib import Path
99
+
100
+ from shortbox import Comic
101
+ from shortbox.metadata import MetronInfo
102
+
103
+ my_comic = Path("MyComic.cbz")
104
+ with Comic.open(my_comic) as comic:
105
+ print(comic.list_filenames())
106
+ print(comic.read_file(filename="page-1.jpg").decode("UTF-8"))
107
+ print(comic.metadata) # Dict of registered metadata in archive
108
+
109
+ metron_info = comic.get_metadata(metadata_type=MetronInfo)
110
+ print(metron_info.series)
111
+ ```
112
+
113
+ Writing files and metadata (support depends on the archive format, see table above):
114
+
115
+ ```python
116
+ with Comic.open(my_comic) as comic:
117
+ comic.write_file(filename="page-99.jpg", data=b"...", override=True)
118
+ comic.remove_file(filename="page-01.jpg")
119
+
120
+ metron_info = comic.get_metadata(metadata_type=MetronInfo)
121
+ metron_info.series.name = "Updated Title"
122
+ comic.set_metadata(metron_info)
123
+ ```
124
+
125
+ You can also convert between different archives (as long as the destination archive has `create` capability)
126
+
127
+ ```python
128
+ from shortbox.archives import ZipArchive
129
+
130
+ rar_comic = Path("MyComic.cbr")
131
+ with Comic.open(rar_comic) as comic:
132
+ print(comic.file) # MyComic.cbr
133
+ comic.convert(
134
+ ZipArchive, delete_original=True
135
+ ) # All future comic interactions will be on the new archive
136
+ print(comic.file) # MyComic.cbz
137
+ ```
138
+
139
+ ## Socials
140
+
141
+ [![Social - Matrix](https://img.shields.io/matrix/The-Dev-Environment:matrix.org?label=The-Dev-Environment&logo=matrix&style=for-the-badge)](https://matrix.to/#/#The-Dev-Environment:matrix.org)
@@ -0,0 +1,105 @@
1
+ # Shortbox
2
+
3
+ [![PyPI - Python](https://img.shields.io/pypi/pyversions/shortbox.svg?logo=Python&label=Python&style=flat-square)](https://pypi.org/p/shortbox/)
4
+ [![PyPI - Status](https://img.shields.io/pypi/status/shortbox.svg?logo=Python&label=Status&style=flat-square)](https://pypi.org/p/shortbox/)
5
+ [![PyPI - Version](https://img.shields.io/pypi/v/shortbox.svg?logo=Python&label=Version&style=flat-square)](https://pypi.org/p/shortbox/)
6
+ [![PyPI - License](https://img.shields.io/pypi/l/shortbox.svg?logo=Python&label=License&style=flat-square)](https://opensource.org/licenses/MIT)
7
+
8
+ [![prek](https://img.shields.io/badge/prek-enabled-informational?logo=prek&style=flat-square)](https://github.com/j178/prek)
9
+ [![Ruff](https://img.shields.io/badge/Ruff-enabled-informational?logo=ruff&style=flat-square)](https://github.com/astral-sh/ruff)
10
+ [![ty](https://img.shields.io/badge/ty-enabled-informational?logo=ruff&style=flat-square)](https://github.com/astral-sh/ty)
11
+
12
+ [![status-badge](https://ci.codeberg.org/api/badges/17625/status.svg)](https://ci.codeberg.org/repos/17625)
13
+
14
+ An extensible library to manage comic archives and their embedded files and metadata.
15
+
16
+ ## Supported Formats
17
+
18
+ More can be added by extending the respective base class and adding to the registry.
19
+
20
+ ### Archives
21
+
22
+ | Archive | Extra Required |
23
+ | ---------- | -------------- |
24
+ | .cbz, .zip | _builtin_ |
25
+ | .cbt, .tar | _builtin_ |
26
+ | .cbr, .rar | cbr |
27
+ | .cb7, .7z | cb7 |
28
+ | .pdf | pdf |
29
+
30
+ **Compability Table**
31
+
32
+ | Format | Read | Update | Create |
33
+ | ------ | :--: | :----: | :----: |
34
+ | cbz | ✅ | ✅ | ✅ |
35
+ | cbt | ❌ | ❌ | ✅ |
36
+ | cbr | ✅ | ❌ | ❌ |
37
+ | cb7 | ✅ | ❌ | ✅ |
38
+ | pdf | ✅ | ✅ | ❌ |
39
+
40
+ If something is marked as in-compatible the library will try extracting and making the change via the local system and re-archive (if it has the create capability).
41
+
42
+ ### Metadata
43
+
44
+ - [ComicInfo.xml v2.0](schemas/v2.0/ComicInfo.xsd)
45
+ - [MetronInfo.xml v1.1](https://raw.githubusercontent.com/Metron-Project/metroninfo/master/schema/v1.1/MetronInfo.xsd)
46
+
47
+ ## Installation
48
+
49
+ ```sh
50
+ pdm add shortbox
51
+ ```
52
+
53
+ Optional extras can be added as needed:
54
+
55
+ ```sh
56
+ pdm add shortbox[cbr,cb7,pdf]
57
+ ```
58
+
59
+ ## Usage
60
+
61
+ ```python
62
+ from pathlib import Path
63
+
64
+ from shortbox import Comic
65
+ from shortbox.metadata import MetronInfo
66
+
67
+ my_comic = Path("MyComic.cbz")
68
+ with Comic.open(my_comic) as comic:
69
+ print(comic.list_filenames())
70
+ print(comic.read_file(filename="page-1.jpg").decode("UTF-8"))
71
+ print(comic.metadata) # Dict of registered metadata in archive
72
+
73
+ metron_info = comic.get_metadata(metadata_type=MetronInfo)
74
+ print(metron_info.series)
75
+ ```
76
+
77
+ Writing files and metadata (support depends on the archive format, see table above):
78
+
79
+ ```python
80
+ with Comic.open(my_comic) as comic:
81
+ comic.write_file(filename="page-99.jpg", data=b"...", override=True)
82
+ comic.remove_file(filename="page-01.jpg")
83
+
84
+ metron_info = comic.get_metadata(metadata_type=MetronInfo)
85
+ metron_info.series.name = "Updated Title"
86
+ comic.set_metadata(metron_info)
87
+ ```
88
+
89
+ You can also convert between different archives (as long as the destination archive has `create` capability)
90
+
91
+ ```python
92
+ from shortbox.archives import ZipArchive
93
+
94
+ rar_comic = Path("MyComic.cbr")
95
+ with Comic.open(rar_comic) as comic:
96
+ print(comic.file) # MyComic.cbr
97
+ comic.convert(
98
+ ZipArchive, delete_original=True
99
+ ) # All future comic interactions will be on the new archive
100
+ print(comic.file) # MyComic.cbz
101
+ ```
102
+
103
+ ## Socials
104
+
105
+ [![Social - Matrix](https://img.shields.io/matrix/The-Dev-Environment:matrix.org?label=The-Dev-Environment&logo=matrix&style=for-the-badge)](https://matrix.to/#/#The-Dev-Environment:matrix.org)
@@ -0,0 +1,2 @@
1
+ [lock]
2
+ format = "pylock"