biblo 0.1.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.
biblo-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nick Nissen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
biblo-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.4
2
+ Name: biblo
3
+ Version: 0.1.0
4
+ Summary: Unofficial async client and CLI for Biblo, the Danish public libraries' app.
5
+ Keywords: biblo,library,bibliotek,ereolen,danish,api,async
6
+ Author: Nick Nissen
7
+ Author-email: Nick Nissen <nickknissen@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: End Users/Desktop
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
19
+ Classifier: Framework :: AsyncIO
20
+ Classifier: Typing :: Typed
21
+ Classifier: Natural Language :: Danish
22
+ Classifier: Topic :: Education
23
+ Requires-Dist: httpx>=0.28.1
24
+ Requires-Dist: pydantic>=2.9
25
+ Requires-Dist: typer>=0.29.2 ; extra == 'cli'
26
+ Requires-Dist: rich>=13.7 ; extra == 'cli'
27
+ Requires-Python: >=3.12
28
+ Project-URL: Homepage, https://github.com/nickknissen/biblo
29
+ Project-URL: Repository, https://github.com/nickknissen/biblo
30
+ Project-URL: Issues, https://github.com/nickknissen/biblo/issues
31
+ Provides-Extra: cli
32
+ Description-Content-Type: text/markdown
33
+
34
+ # biblo
35
+
36
+ An unofficial Python client and command line for **Biblo**, the Danish public libraries' app
37
+ for e-books, audiobooks and podcasts (by [Det Digitale Folkebibliotek](https://detdigitalefolkebibliotek.dk)).
38
+
39
+ Search the catalogue, borrow and renew, reserve, and keep track of your loans: from Python
40
+ (sync or async) or from the terminal.
41
+
42
+ ```console
43
+ $ biblo auth login --library vejle
44
+ Card number or CPR: 0102031234
45
+ Pincode:
46
+ ✓ Logged in to Vejle Bibliotekerne (763000) as Test Testesen
47
+
48
+ $ biblo search "tove ditlevsen" --audiobook
49
+ $ biblo work work-of:870970-basis:143298507
50
+ $ biblo borrow 870970-basis:143304299
51
+ $ biblo loans
52
+ Title By Format Due Loan id
53
+ Barndommens gade Tove Ditlevsen lydbog (online) 2026-12-20 (in 30 days) 123456
54
+ ```
55
+
56
+ > Not affiliated with Det Digitale Folkebibliotek or the libraries. It talks to the same API
57
+ > as the Android app, with your own library login. Reading and listening still happen in the
58
+ > Biblo app: books are DRM-protected and this project does not download them.
59
+
60
+ ## Install
61
+
62
+ ```console
63
+ pip install 'biblo[cli]' # library + the biblo command
64
+ pip install biblo # just the library
65
+ uvx --from 'biblo[cli]' biblo search "harry potter" -l vejle # try it without installing
66
+ ```
67
+
68
+ Python 3.12 or newer.
69
+
70
+ ## Command line
71
+
72
+ Everything a library belongs to takes `--library`/`-l` with an id or (part of) a name:
73
+ `-l vejle`, `-l 763000`, or set `BIBLO_LIBRARY`. Once you've logged in, your own library is the
74
+ default.
75
+
76
+ | Command | |
77
+ | --- | --- |
78
+ | `biblo libraries [town]` | find your library's id |
79
+ | `biblo auth login` / `status` / `logout` / `token` | your session |
80
+ | `biblo search QUERY` | `--ebook`, `--audiobook`, `--podcast`, `--language dan`, `--by title`, `-f subjects=krimi` |
81
+ | `biblo work WORK_ID` | description, availability and the records (editions) to borrow |
82
+ | `biblo borrow RECORD_ID` | borrow an e-book, audiobook or podcast |
83
+ | `biblo loans` / `biblo renew [--all]` | your loans |
84
+ | `biblo reservations` / `reserve` / `cancel` | reservations |
85
+ | `biblo favorites [add\|remove]` | your saved works |
86
+ | `biblo account` / `messages` | details, digital quota left, fees, messages |
87
+ | `biblo branches` / `hours` / `events` | the physical library |
88
+ | `biblo api PATH` | call any endpoint, like `gh api` |
89
+
90
+ Every listing takes `--json` for scripts, e.g. `biblo loans --json | jq '.[].due_date'`.
91
+
92
+ **Logging in.** `biblo auth login` asks for your card number or CPR and pincode and logs in
93
+ at login.bib.dk the way the app does. For scripts, pass `--user` (or `BIBLO_USER`) and the
94
+ pincode in `BIBLO_PIN` or on stdin with `--pin-stdin`. The pincode is never stored; the
95
+ session's tokens are, in `~/.config/biblo/session.json` (readable only by you; override the
96
+ folder with `BIBLO_CONFIG_DIR`). For MitID, use `biblo auth login --web`.
97
+
98
+ Exit codes: 0 ok, 1 error, 2 bad usage, 4 not logged in.
99
+
100
+ ## Python
101
+
102
+ ```python
103
+ from biblo import Biblo, FileTokenStorage
104
+
105
+ with Biblo("763000", storage=FileTokenStorage("session.json")) as biblo:
106
+ result = biblo.catalog.search("harry potter", material_types_specific="e-bog")
107
+ print(result.hitcount)
108
+ work = biblo.catalog.work(result.works[0].id)
109
+ ebook = next(r for r in work.variations if r.material_type.display == "e-bog")
110
+
111
+ biblo.login("0102031234", "1234") # once; the session is saved
112
+ loan = biblo.loans.borrow(ebook.record_id)
113
+ for loan in biblo.loans.list():
114
+ print(loan.record.title, loan.due_date)
115
+ ```
116
+
117
+ `AsyncBiblo` is the same client for asyncio:
118
+
119
+ ```python
120
+ from biblo import AsyncBiblo
121
+
122
+ async with AsyncBiblo("763000") as biblo:
123
+ async for work in biblo.catalog.iter_search("krimi", max_results=200):
124
+ print(work.title)
125
+ ```
126
+
127
+ The client groups the API:
128
+
129
+ | | |
130
+ | --- | --- |
131
+ | `catalog` | `search`, `iter_search`, `facets`, `suggest`, `work`, `availability`, `record`, `records_status`, `holdings`, `series`, `recommendations`, `reviews`, `sample` |
132
+ | `loans` | `list`, `borrow`, `renew`, `borrow_physical`, `return_physical` |
133
+ | `reservations` | `list`, `create`, `update`, `cancel`, `convert` |
134
+ | `account` | `get`, `update`, `quotas`, `fees`, `change_pincode` |
135
+ | `favorites`, `messages`, `devices` | the user's saved works, messages and push tokens |
136
+ | `libraries` | `list`, `find`, `get`, `configuration`, `branches`, `opening_hours`, `open_status`, `events` |
137
+ | `content` | the app's editorial front page |
138
+
139
+ `biblo.request(method, path)` reaches anything else.
140
+
141
+ **Results are typed** Pydantic models generated from the API's own OpenAPI spec, with
142
+ snake_case fields (`loan.due_date`, a timezone-aware `datetime`). Fields and enum values the
143
+ spec doesn't know yet are kept rather than rejected, and if the API sends something its spec
144
+ doesn't allow (it sometimes sends `null` for a promised string), that one value is passed
145
+ through as sent and logged at DEBUG on the `biblo` logger instead of failing the whole call.
146
+
147
+ **Libraries.** Calls default to the library given to the client; account calls default to
148
+ the library you logged in at. Every method also takes `library_id=`.
149
+
150
+ **Sessions.** Give the client a `storage` and it saves the tokens after login and every
151
+ refresh: `FileTokenStorage`, `MemoryTokenStorage`, or your own `TokenStorage`
152
+ (`AsyncTokenStorage` for `AsyncBiblo`) with `load()` and `save()`. Access tokens are
153
+ refreshed before they expire and once more if the API answers 401.
154
+
155
+ **Home Assistant and other frameworks.** Pass your own `httpx` client with `http_client=`
156
+ (the client then leaves closing it to you) and a `AsyncTokenStorage` backed by the
157
+ framework's storage.
158
+
159
+ **Errors** all derive from `biblo.BibloError`: `InvalidCredentialsError` for a refused
160
+ login, `NotLoggedInError` when a session is missing or can no longer be refreshed,
161
+ `BibloConnectionError`, and `APIError` subclasses by status (`NotFoundError`,
162
+ `ConflictError`, `RateLimitError`, ...) carrying the API's `code`, `type` and `message`.
163
+
164
+ ## How it works
165
+
166
+ The app's backend, `https://api.detdigitalefolkebibliotek.dk`, publishes its OpenAPI spec
167
+ (the root URL is a Swagger UI). It serves three apps: Biblo, Mit Biblo (the physical
168
+ library: branches, events, Scan & Loan) and Biblo Go, and some endpoints only answer one of
169
+ them; the client sends the right `x-app-type` for each. The API key, app version and
170
+ login.bib.dk OAuth client are the ones every copy of the Android app ships
171
+ (`src/biblo/_constants.py`).
172
+
173
+ Logging in goes through login.bib.dk (Adgangsplatformen): its library-card form is posted,
174
+ the `biblo://?code=...` redirect is caught, and the code is exchanged at `/v1/auth/login`.
175
+
176
+ ## Development
177
+
178
+ ```console
179
+ uv sync
180
+ uv run python scripts/check.py # everything CI runs
181
+ uv run pytest -m live # read-only checks against the real API
182
+ ```
183
+
184
+ The models (`src/biblo/models/_generated.py`), the app-type table and the whole sync client
185
+ (`src/biblo/_sync/`) are generated: edit `src/biblo/_async/` or `spec/`, then run
186
+ `uv run python scripts/generate.py`. See
187
+ [AGENTS.md](https://github.com/nickknissen/biblo/blob/main/AGENTS.md) for the details.
188
+
189
+ Releasing: `uv run python scripts/release.py X.Y.Z` bumps the version, commits, pushes and
190
+ creates the GitHub release; publishing the release uploads it to PyPI.
191
+
192
+ ## License
193
+
194
+ MIT
biblo-0.1.0/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # biblo
2
+
3
+ An unofficial Python client and command line for **Biblo**, the Danish public libraries' app
4
+ for e-books, audiobooks and podcasts (by [Det Digitale Folkebibliotek](https://detdigitalefolkebibliotek.dk)).
5
+
6
+ Search the catalogue, borrow and renew, reserve, and keep track of your loans: from Python
7
+ (sync or async) or from the terminal.
8
+
9
+ ```console
10
+ $ biblo auth login --library vejle
11
+ Card number or CPR: 0102031234
12
+ Pincode:
13
+ ✓ Logged in to Vejle Bibliotekerne (763000) as Test Testesen
14
+
15
+ $ biblo search "tove ditlevsen" --audiobook
16
+ $ biblo work work-of:870970-basis:143298507
17
+ $ biblo borrow 870970-basis:143304299
18
+ $ biblo loans
19
+ Title By Format Due Loan id
20
+ Barndommens gade Tove Ditlevsen lydbog (online) 2026-12-20 (in 30 days) 123456
21
+ ```
22
+
23
+ > Not affiliated with Det Digitale Folkebibliotek or the libraries. It talks to the same API
24
+ > as the Android app, with your own library login. Reading and listening still happen in the
25
+ > Biblo app: books are DRM-protected and this project does not download them.
26
+
27
+ ## Install
28
+
29
+ ```console
30
+ pip install 'biblo[cli]' # library + the biblo command
31
+ pip install biblo # just the library
32
+ uvx --from 'biblo[cli]' biblo search "harry potter" -l vejle # try it without installing
33
+ ```
34
+
35
+ Python 3.12 or newer.
36
+
37
+ ## Command line
38
+
39
+ Everything a library belongs to takes `--library`/`-l` with an id or (part of) a name:
40
+ `-l vejle`, `-l 763000`, or set `BIBLO_LIBRARY`. Once you've logged in, your own library is the
41
+ default.
42
+
43
+ | Command | |
44
+ | --- | --- |
45
+ | `biblo libraries [town]` | find your library's id |
46
+ | `biblo auth login` / `status` / `logout` / `token` | your session |
47
+ | `biblo search QUERY` | `--ebook`, `--audiobook`, `--podcast`, `--language dan`, `--by title`, `-f subjects=krimi` |
48
+ | `biblo work WORK_ID` | description, availability and the records (editions) to borrow |
49
+ | `biblo borrow RECORD_ID` | borrow an e-book, audiobook or podcast |
50
+ | `biblo loans` / `biblo renew [--all]` | your loans |
51
+ | `biblo reservations` / `reserve` / `cancel` | reservations |
52
+ | `biblo favorites [add\|remove]` | your saved works |
53
+ | `biblo account` / `messages` | details, digital quota left, fees, messages |
54
+ | `biblo branches` / `hours` / `events` | the physical library |
55
+ | `biblo api PATH` | call any endpoint, like `gh api` |
56
+
57
+ Every listing takes `--json` for scripts, e.g. `biblo loans --json | jq '.[].due_date'`.
58
+
59
+ **Logging in.** `biblo auth login` asks for your card number or CPR and pincode and logs in
60
+ at login.bib.dk the way the app does. For scripts, pass `--user` (or `BIBLO_USER`) and the
61
+ pincode in `BIBLO_PIN` or on stdin with `--pin-stdin`. The pincode is never stored; the
62
+ session's tokens are, in `~/.config/biblo/session.json` (readable only by you; override the
63
+ folder with `BIBLO_CONFIG_DIR`). For MitID, use `biblo auth login --web`.
64
+
65
+ Exit codes: 0 ok, 1 error, 2 bad usage, 4 not logged in.
66
+
67
+ ## Python
68
+
69
+ ```python
70
+ from biblo import Biblo, FileTokenStorage
71
+
72
+ with Biblo("763000", storage=FileTokenStorage("session.json")) as biblo:
73
+ result = biblo.catalog.search("harry potter", material_types_specific="e-bog")
74
+ print(result.hitcount)
75
+ work = biblo.catalog.work(result.works[0].id)
76
+ ebook = next(r for r in work.variations if r.material_type.display == "e-bog")
77
+
78
+ biblo.login("0102031234", "1234") # once; the session is saved
79
+ loan = biblo.loans.borrow(ebook.record_id)
80
+ for loan in biblo.loans.list():
81
+ print(loan.record.title, loan.due_date)
82
+ ```
83
+
84
+ `AsyncBiblo` is the same client for asyncio:
85
+
86
+ ```python
87
+ from biblo import AsyncBiblo
88
+
89
+ async with AsyncBiblo("763000") as biblo:
90
+ async for work in biblo.catalog.iter_search("krimi", max_results=200):
91
+ print(work.title)
92
+ ```
93
+
94
+ The client groups the API:
95
+
96
+ | | |
97
+ | --- | --- |
98
+ | `catalog` | `search`, `iter_search`, `facets`, `suggest`, `work`, `availability`, `record`, `records_status`, `holdings`, `series`, `recommendations`, `reviews`, `sample` |
99
+ | `loans` | `list`, `borrow`, `renew`, `borrow_physical`, `return_physical` |
100
+ | `reservations` | `list`, `create`, `update`, `cancel`, `convert` |
101
+ | `account` | `get`, `update`, `quotas`, `fees`, `change_pincode` |
102
+ | `favorites`, `messages`, `devices` | the user's saved works, messages and push tokens |
103
+ | `libraries` | `list`, `find`, `get`, `configuration`, `branches`, `opening_hours`, `open_status`, `events` |
104
+ | `content` | the app's editorial front page |
105
+
106
+ `biblo.request(method, path)` reaches anything else.
107
+
108
+ **Results are typed** Pydantic models generated from the API's own OpenAPI spec, with
109
+ snake_case fields (`loan.due_date`, a timezone-aware `datetime`). Fields and enum values the
110
+ spec doesn't know yet are kept rather than rejected, and if the API sends something its spec
111
+ doesn't allow (it sometimes sends `null` for a promised string), that one value is passed
112
+ through as sent and logged at DEBUG on the `biblo` logger instead of failing the whole call.
113
+
114
+ **Libraries.** Calls default to the library given to the client; account calls default to
115
+ the library you logged in at. Every method also takes `library_id=`.
116
+
117
+ **Sessions.** Give the client a `storage` and it saves the tokens after login and every
118
+ refresh: `FileTokenStorage`, `MemoryTokenStorage`, or your own `TokenStorage`
119
+ (`AsyncTokenStorage` for `AsyncBiblo`) with `load()` and `save()`. Access tokens are
120
+ refreshed before they expire and once more if the API answers 401.
121
+
122
+ **Home Assistant and other frameworks.** Pass your own `httpx` client with `http_client=`
123
+ (the client then leaves closing it to you) and a `AsyncTokenStorage` backed by the
124
+ framework's storage.
125
+
126
+ **Errors** all derive from `biblo.BibloError`: `InvalidCredentialsError` for a refused
127
+ login, `NotLoggedInError` when a session is missing or can no longer be refreshed,
128
+ `BibloConnectionError`, and `APIError` subclasses by status (`NotFoundError`,
129
+ `ConflictError`, `RateLimitError`, ...) carrying the API's `code`, `type` and `message`.
130
+
131
+ ## How it works
132
+
133
+ The app's backend, `https://api.detdigitalefolkebibliotek.dk`, publishes its OpenAPI spec
134
+ (the root URL is a Swagger UI). It serves three apps: Biblo, Mit Biblo (the physical
135
+ library: branches, events, Scan & Loan) and Biblo Go, and some endpoints only answer one of
136
+ them; the client sends the right `x-app-type` for each. The API key, app version and
137
+ login.bib.dk OAuth client are the ones every copy of the Android app ships
138
+ (`src/biblo/_constants.py`).
139
+
140
+ Logging in goes through login.bib.dk (Adgangsplatformen): its library-card form is posted,
141
+ the `biblo://?code=...` redirect is caught, and the code is exchanged at `/v1/auth/login`.
142
+
143
+ ## Development
144
+
145
+ ```console
146
+ uv sync
147
+ uv run python scripts/check.py # everything CI runs
148
+ uv run pytest -m live # read-only checks against the real API
149
+ ```
150
+
151
+ The models (`src/biblo/models/_generated.py`), the app-type table and the whole sync client
152
+ (`src/biblo/_sync/`) are generated: edit `src/biblo/_async/` or `spec/`, then run
153
+ `uv run python scripts/generate.py`. See
154
+ [AGENTS.md](https://github.com/nickknissen/biblo/blob/main/AGENTS.md) for the details.
155
+
156
+ Releasing: `uv run python scripts/release.py X.Y.Z` bumps the version, commits, pushes and
157
+ creates the GitHub release; publishing the release uploads it to PyPI.
158
+
159
+ ## License
160
+
161
+ MIT
@@ -0,0 +1,159 @@
1
+ [project]
2
+ name = "biblo"
3
+ version = "0.1.0"
4
+ description = "Unofficial async client and CLI for Biblo, the Danish public libraries' app."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ keywords = [
9
+ "biblo",
10
+ "library",
11
+ "bibliotek",
12
+ "ereolen",
13
+ "danish",
14
+ "api",
15
+ "async",
16
+ ]
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha",
19
+ "Environment :: Console",
20
+ "Intended Audience :: Developers",
21
+ "Intended Audience :: End Users/Desktop",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Programming Language :: Python :: 3.14",
26
+ "Programming Language :: Python :: 3.15",
27
+ "Framework :: AsyncIO",
28
+ "Typing :: Typed",
29
+ "Natural Language :: Danish",
30
+ "Topic :: Education",
31
+ ]
32
+ requires-python = ">=3.12"
33
+ dependencies = [
34
+ "httpx>=0.28.1",
35
+ "pydantic>=2.9",
36
+ ]
37
+
38
+ [[project.authors]]
39
+ name = "Nick Nissen"
40
+ email = "nickknissen@gmail.com"
41
+
42
+ [project.optional-dependencies]
43
+ cli = [
44
+ "typer>=0.29.2",
45
+ "rich>=13.7",
46
+ ]
47
+
48
+ [project.scripts]
49
+ biblo = "biblo.__main__:main"
50
+
51
+ [project.urls]
52
+ Homepage = "https://github.com/nickknissen/biblo"
53
+ Repository = "https://github.com/nickknissen/biblo"
54
+ Issues = "https://github.com/nickknissen/biblo/issues"
55
+
56
+ [build-system]
57
+ requires = ["uv_build>=0.13.5,<0.14"]
58
+ build-backend = "uv_build"
59
+
60
+ [tool.uv]
61
+ default-groups = ["dev"]
62
+ override-dependencies = ["isort>=9"]
63
+
64
+ [tool.ruff]
65
+ target-version = "py312"
66
+ line-length = 100
67
+ extend-exclude = [
68
+ ".worktrees",
69
+ "*.md",
70
+ "spec",
71
+ ]
72
+
73
+ [tool.ruff.lint]
74
+ select = [
75
+ "E",
76
+ "F",
77
+ "W",
78
+ "I",
79
+ "UP",
80
+ "B",
81
+ "SIM",
82
+ "LOG",
83
+ ]
84
+
85
+ [tool.ruff.lint.per-file-ignores]
86
+ "src/biblo/models/_generated.py" = ["E501"]
87
+ "src/biblo/_sync/*" = ["UP028"]
88
+
89
+ [tool.pytest.ini_options]
90
+ testpaths = ["tests"]
91
+ asyncio_mode = "auto"
92
+ asyncio_default_fixture_loop_scope = "function"
93
+ markers = ["live: calls the real Biblo API; run with -m live"]
94
+ addopts = "-m 'not live'"
95
+
96
+ [tool.datamodel-codegen]
97
+ input = "spec/ddf-openapi.json"
98
+ input-file-type = "openapi"
99
+ openapi-scopes = ["schemas"]
100
+ output = "src/biblo/models/_generated.py"
101
+ output-model-type = "pydantic_v2.BaseModel"
102
+ target-python-version = "3.12"
103
+ use-annotated = true
104
+ field-constraints = true
105
+ snake-case-field = true
106
+ allow-population-by-field-name = true
107
+ use-standard-collections = true
108
+ use-union-operator = true
109
+ use-schema-description = true
110
+ use-field-description = true
111
+ use-attribute-docstrings = true
112
+ naming-strategy = "parent-prefixed"
113
+ collapse-root-models = true
114
+ enum-field-as-literal = "all"
115
+ open-enums = "all"
116
+ extra-fields = "allow"
117
+ output-datetime-class = "datetime"
118
+ type-mappings = [
119
+ "string+uri=string",
120
+ "string+email=string",
121
+ "string+uuid=string",
122
+ ]
123
+ use-double-quotes = true
124
+ disable-timestamp = true
125
+
126
+ [tool.pyright]
127
+ pythonVersion = "3.12"
128
+ venvPath = "."
129
+ venv = ".venv"
130
+ include = [
131
+ "src",
132
+ "tests",
133
+ "scripts",
134
+ ]
135
+ exclude = [
136
+ ".venv",
137
+ "spec",
138
+ "apk",
139
+ ]
140
+
141
+ [tool.ty.environment]
142
+ python-version = "3.12"
143
+
144
+ [tool.ty.src]
145
+ include = [
146
+ "src/",
147
+ "tests/",
148
+ ]
149
+
150
+ [dependency-groups]
151
+ dev = [
152
+ "biblo[cli]",
153
+ "datamodel-code-generator>=0.99",
154
+ "unasync>=0.6.0",
155
+ "pytest>=9.0.0",
156
+ "pytest-asyncio>=1.3.0",
157
+ "ruff>=0.17.3",
158
+ "ty>=0.0.92",
159
+ ]
@@ -0,0 +1,127 @@
1
+ [project]
2
+ name = "biblo"
3
+ version = "0.1.0"
4
+ description = "Unofficial async client and CLI for Biblo, the Danish public libraries' app."
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Nick Nissen", email = "nickknissen@gmail.com" }
8
+ ]
9
+ license = "MIT"
10
+ license-files = ["LICENSE"]
11
+ keywords = ["biblo", "library", "bibliotek", "ereolen", "danish", "api", "async"]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Environment :: Console",
15
+ "Intended Audience :: Developers",
16
+ "Intended Audience :: End Users/Desktop",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Programming Language :: Python :: 3.14",
21
+ "Programming Language :: Python :: 3.15",
22
+ "Framework :: AsyncIO",
23
+ "Typing :: Typed",
24
+ "Natural Language :: Danish",
25
+ "Topic :: Education",
26
+ ]
27
+ requires-python = ">=3.12"
28
+ dependencies = [
29
+ "httpx>=0.28.1",
30
+ "pydantic>=2.9",
31
+ ]
32
+
33
+ [project.optional-dependencies]
34
+ cli = ["typer>=0.29.2", "rich>=13.7"]
35
+
36
+ [project.scripts]
37
+ biblo = "biblo.__main__:main"
38
+
39
+ [project.urls]
40
+ Homepage = "https://github.com/nickknissen/biblo"
41
+ Repository = "https://github.com/nickknissen/biblo"
42
+ Issues = "https://github.com/nickknissen/biblo/issues"
43
+
44
+ [build-system]
45
+ requires = ["uv_build>=0.13.5,<0.14"]
46
+ build-backend = "uv_build"
47
+
48
+ [tool.uv]
49
+ default-groups = ["dev"]
50
+ # datamodel-code-generator caps isort below 9, but scripts/generate.py runs it with
51
+ # --formatters builtin, so isort is never used; this lets the lock take current isort.
52
+ override-dependencies = ["isort>=9"]
53
+
54
+ [tool.ruff]
55
+ target-version = "py312"
56
+ line-length = 100
57
+ extend-exclude = [".worktrees", "*.md", "spec"]
58
+
59
+ [tool.ruff.lint]
60
+ select = ["E", "F", "W", "I", "UP", "B", "SIM", "LOG"]
61
+
62
+ [tool.ruff.lint.per-file-ignores]
63
+ # Generated: long lines are the spec's descriptions.
64
+ "src/biblo/models/_generated.py" = ["E501"]
65
+ # Generated from async code, where `yield from` doesn't exist.
66
+ "src/biblo/_sync/*" = ["UP028"]
67
+
68
+ [tool.pytest.ini_options]
69
+ testpaths = ["tests"]
70
+ asyncio_mode = "auto"
71
+ asyncio_default_fixture_loop_scope = "function"
72
+ markers = ["live: calls the real Biblo API; run with -m live"]
73
+ addopts = "-m 'not live'"
74
+
75
+ # Models are generated from the API's OpenAPI spec by scripts/generate.py; don't edit
76
+ # src/biblo/models/_generated.py by hand. Choices favour parsing over validating: unknown
77
+ # fields and enum values are kept, and the spec's string patterns and lengths are dropped
78
+ # afterwards, so a change on the server doesn't break existing releases.
79
+ [tool.datamodel-codegen]
80
+ input = "spec/ddf-openapi.json"
81
+ input-file-type = "openapi"
82
+ openapi-scopes = ["schemas"]
83
+ output = "src/biblo/models/_generated.py"
84
+ output-model-type = "pydantic_v2.BaseModel"
85
+ target-python-version = "3.12"
86
+ use-annotated = true
87
+ field-constraints = true
88
+ snake-case-field = true
89
+ allow-population-by-field-name = true
90
+ use-standard-collections = true
91
+ use-union-operator = true
92
+ use-schema-description = true
93
+ use-field-description = true
94
+ use-attribute-docstrings = true
95
+ naming-strategy = "parent-prefixed"
96
+ collapse-root-models = true
97
+ enum-field-as-literal = "all"
98
+ open-enums = "all"
99
+ extra-fields = "allow"
100
+ output-datetime-class = "datetime"
101
+ type-mappings = ["string+uri=string", "string+email=string", "string+uuid=string"]
102
+ use-double-quotes = true
103
+ disable-timestamp = true
104
+
105
+ [tool.pyright]
106
+ pythonVersion = "3.12"
107
+ venvPath = "."
108
+ venv = ".venv"
109
+ include = ["src", "tests", "scripts"]
110
+ exclude = [".venv", "spec", "apk"]
111
+
112
+ [tool.ty.environment]
113
+ python-version = "3.12"
114
+
115
+ [tool.ty.src]
116
+ include = ["src/", "tests/"]
117
+
118
+ [dependency-groups]
119
+ dev = [
120
+ "biblo[cli]",
121
+ "datamodel-code-generator>=0.99",
122
+ "unasync>=0.6.0",
123
+ "pytest>=9.0.0",
124
+ "pytest-asyncio>=1.3.0",
125
+ "ruff>=0.17.3",
126
+ "ty>=0.0.92",
127
+ ]