kuopac 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.
Files changed (86) hide show
  1. kuopac-0.1.0/.github/workflows/live.yml +109 -0
  2. kuopac-0.1.0/.github/workflows/tests.yml +45 -0
  3. kuopac-0.1.0/.gitignore +224 -0
  4. kuopac-0.1.0/.python-version +1 -0
  5. kuopac-0.1.0/LICENSE +21 -0
  6. kuopac-0.1.0/PKG-INFO +439 -0
  7. kuopac-0.1.0/README.md +379 -0
  8. kuopac-0.1.0/docs/audit-report.md +169 -0
  9. kuopac-0.1.0/docs/cli-design.md +893 -0
  10. kuopac-0.1.0/docs/opac-spec.md +1077 -0
  11. kuopac-0.1.0/examples/01_simple_search.py +22 -0
  12. kuopac-0.1.0/examples/02_advanced_query.py +24 -0
  13. kuopac-0.1.0/examples/03_pagination.py +29 -0
  14. kuopac-0.1.0/examples/04_facets_and_refine.py +29 -0
  15. kuopac-0.1.0/examples/05_detail_and_holdings.py +47 -0
  16. kuopac-0.1.0/examples/06_cinii_other_universities.py +27 -0
  17. kuopac-0.1.0/examples/07_suggest_and_spell.py +21 -0
  18. kuopac-0.1.0/examples/08_search_with_holdings.py +50 -0
  19. kuopac-0.1.0/examples/09_synopsis_and_toc.py +39 -0
  20. kuopac-0.1.0/pyproject.toml +66 -0
  21. kuopac-0.1.0/scripts/analyze.py +202 -0
  22. kuopac-0.1.0/scripts/audit.py +298 -0
  23. kuopac-0.1.0/scripts/probe.py +175 -0
  24. kuopac-0.1.0/scripts/probes.py +519 -0
  25. kuopac-0.1.0/src/kuopac/__init__.py +89 -0
  26. kuopac-0.1.0/src/kuopac/_http.py +127 -0
  27. kuopac-0.1.0/src/kuopac/_parse.py +747 -0
  28. kuopac-0.1.0/src/kuopac/cli/__init__.py +7 -0
  29. kuopac-0.1.0/src/kuopac/cli/__main__.py +5 -0
  30. kuopac-0.1.0/src/kuopac/cli/commands/__init__.py +5 -0
  31. kuopac-0.1.0/src/kuopac/cli/commands/detail.py +120 -0
  32. kuopac-0.1.0/src/kuopac/cli/commands/did_you_mean.py +34 -0
  33. kuopac-0.1.0/src/kuopac/cli/commands/facets.py +90 -0
  34. kuopac-0.1.0/src/kuopac/cli/commands/holdings.py +95 -0
  35. kuopac-0.1.0/src/kuopac/cli/commands/manifest.py +225 -0
  36. kuopac-0.1.0/src/kuopac/cli/commands/schema_cmd.py +29 -0
  37. kuopac-0.1.0/src/kuopac/cli/commands/search.py +432 -0
  38. kuopac-0.1.0/src/kuopac/cli/commands/status.py +44 -0
  39. kuopac-0.1.0/src/kuopac/cli/commands/suggest.py +25 -0
  40. kuopac-0.1.0/src/kuopac/cli/commands/synopsis.py +61 -0
  41. kuopac-0.1.0/src/kuopac/cli/commands/version.py +12 -0
  42. kuopac-0.1.0/src/kuopac/cli/config.py +47 -0
  43. kuopac-0.1.0/src/kuopac/cli/errors.py +100 -0
  44. kuopac-0.1.0/src/kuopac/cli/explain.py +55 -0
  45. kuopac-0.1.0/src/kuopac/cli/formatters/__init__.py +104 -0
  46. kuopac-0.1.0/src/kuopac/cli/formatters/_envelope.py +63 -0
  47. kuopac-0.1.0/src/kuopac/cli/formatters/_serialize.py +61 -0
  48. kuopac-0.1.0/src/kuopac/cli/formatters/json_fmt.py +13 -0
  49. kuopac-0.1.0/src/kuopac/cli/formatters/ndjson_fmt.py +35 -0
  50. kuopac-0.1.0/src/kuopac/cli/formatters/table.py +342 -0
  51. kuopac-0.1.0/src/kuopac/cli/formatters/tsv.py +32 -0
  52. kuopac-0.1.0/src/kuopac/cli/formatters/yaml_fmt.py +18 -0
  53. kuopac-0.1.0/src/kuopac/cli/main.py +177 -0
  54. kuopac-0.1.0/src/kuopac/cli/projection.py +80 -0
  55. kuopac-0.1.0/src/kuopac/cli/runtime.py +44 -0
  56. kuopac-0.1.0/src/kuopac/cli/schema_gen.py +155 -0
  57. kuopac-0.1.0/src/kuopac/client.py +444 -0
  58. kuopac-0.1.0/src/kuopac/enums.py +142 -0
  59. kuopac-0.1.0/src/kuopac/errors.py +22 -0
  60. kuopac-0.1.0/src/kuopac/models.py +459 -0
  61. kuopac-0.1.0/src/kuopac/py.typed +0 -0
  62. kuopac-0.1.0/src/kuopac/query.py +145 -0
  63. kuopac-0.1.0/tests/__init__.py +0 -0
  64. kuopac-0.1.0/tests/cli/__init__.py +0 -0
  65. kuopac-0.1.0/tests/cli/test_cli_integration.py +202 -0
  66. kuopac-0.1.0/tests/cli/test_envelope.py +29 -0
  67. kuopac-0.1.0/tests/cli/test_projection.py +51 -0
  68. kuopac-0.1.0/tests/cli/test_schema.py +43 -0
  69. kuopac-0.1.0/tests/cli/test_serialize.py +80 -0
  70. kuopac-0.1.0/tests/client/__init__.py +0 -0
  71. kuopac-0.1.0/tests/client/conftest.py +120 -0
  72. kuopac-0.1.0/tests/client/test_other_wire_format.py +350 -0
  73. kuopac-0.1.0/tests/client/test_search_wire_format.py +249 -0
  74. kuopac-0.1.0/tests/live/__init__.py +0 -0
  75. kuopac-0.1.0/tests/live/conftest.py +93 -0
  76. kuopac-0.1.0/tests/live/test_endpoints.py +184 -0
  77. kuopac-0.1.0/tests/parse/__init__.py +0 -0
  78. kuopac-0.1.0/tests/parse/test_detail.py +370 -0
  79. kuopac-0.1.0/tests/parse/test_misc_endpoints.py +195 -0
  80. kuopac-0.1.0/tests/parse/test_search_results.py +172 -0
  81. kuopac-0.1.0/tests/test_enums.py +26 -0
  82. kuopac-0.1.0/tests/test_examples.py +229 -0
  83. kuopac-0.1.0/tests/test_http.py +154 -0
  84. kuopac-0.1.0/tests/test_models.py +87 -0
  85. kuopac-0.1.0/tests/test_query.py +94 -0
  86. kuopac-0.1.0/uv.lock +385 -0
@@ -0,0 +1,109 @@
1
+ name: Live integration tests
2
+
3
+ # Runs the live KULINE integration suite once a day. Never runs on PRs
4
+ # (external contributors shouldn't hit the real server). Opt-in manual
5
+ # triggers via the "Run workflow" button.
6
+ #
7
+ # On failure: an issue is auto-filed with the failing tests' output so the
8
+ # maintainer can decide whether KULINE changed something, or the library
9
+ # broke, without watching the schedule.
10
+ on:
11
+ schedule:
12
+ # Daily at 03:00 JST (18:00 UTC the previous day) — quiet hours for the
13
+ # library's servers.
14
+ - cron: "0 18 * * *"
15
+ workflow_dispatch:
16
+
17
+ # Don't pile up concurrent runs; live tests are inherently slow + polite.
18
+ concurrency:
19
+ group: kuopac-live
20
+ cancel-in-progress: false
21
+
22
+ permissions:
23
+ contents: read
24
+ issues: write # required for the auto-issue step
25
+
26
+ jobs:
27
+ live:
28
+ name: Live tests against KULINE
29
+ runs-on: ubuntu-latest
30
+ timeout-minutes: 15
31
+
32
+ steps:
33
+ - name: Checkout
34
+ uses: actions/checkout@v4
35
+
36
+ - name: Install uv
37
+ uses: astral-sh/setup-uv@v3
38
+ with:
39
+ enable-cache: true
40
+
41
+ - name: Set up Python
42
+ run: uv python install 3.12
43
+
44
+ - name: Install kuopac + dev deps
45
+ run: |
46
+ uv venv
47
+ uv pip install -e ".[dev]"
48
+
49
+ - name: Run live tests
50
+ id: livetests
51
+ env:
52
+ KUOPAC_LIVE: "1"
53
+ PYTHONIOENCODING: "utf-8"
54
+ continue-on-error: true
55
+ run: |
56
+ set -o pipefail
57
+ uv run pytest tests/live -v --tb=short --color=no 2>&1 \
58
+ | tee live-output.txt
59
+ echo "exit_code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
60
+
61
+ - name: Upload test log
62
+ if: always()
63
+ uses: actions/upload-artifact@v4
64
+ with:
65
+ name: live-output
66
+ path: live-output.txt
67
+ retention-days: 30
68
+
69
+ - name: File issue on failure
70
+ if: steps.livetests.outputs.exit_code != '0'
71
+ uses: actions/github-script@v7
72
+ with:
73
+ script: |
74
+ const fs = require('fs');
75
+ const output = fs.readFileSync('live-output.txt', 'utf8');
76
+ // Trim — keep the tail (the failing summary lives there).
77
+ const tail = output.length > 8000 ? output.slice(-8000) : output;
78
+ const today = new Date().toISOString().slice(0, 10);
79
+ await github.rest.issues.create({
80
+ owner: context.repo.owner,
81
+ repo: context.repo.repo,
82
+ title: `Live integration test failure — ${today}`,
83
+ body: [
84
+ `The nightly live integration run failed.`,
85
+ ``,
86
+ `Possible causes (debug in this order):`,
87
+ `1. **KULINE template change** — a parser test will be the failure; cross-check against \`docs/opac-spec.md\`.`,
88
+ `2. **KULINE downtime / rate limiting** — reachability fixture would have skipped, but a partial outage might let some calls through.`,
89
+ `3. **kuopac regression** — the most recent commit on \`main\` introduced something.`,
90
+ `4. **Catalog drift** — an evergreen assumption (e.g. SICP ISBN \`9784274068478\`) no longer holds; update the test fixture, not the library.`,
91
+ ``,
92
+ `Run: https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
93
+ ``,
94
+ `<details><summary>pytest output (tail)</summary>`,
95
+ ``,
96
+ '```',
97
+ tail,
98
+ '```',
99
+ ``,
100
+ `</details>`,
101
+ ].join('\n'),
102
+ labels: ['live-test-failure'],
103
+ });
104
+
105
+ - name: Fail the job
106
+ if: steps.livetests.outputs.exit_code != '0'
107
+ run: |
108
+ echo "live tests failed (exit ${{ steps.livetests.outputs.exit_code }})"
109
+ exit 1
@@ -0,0 +1,45 @@
1
+ name: Tests
2
+
3
+ # Fast offline test suite — runs on every push and PR.
4
+ # (For the live KULINE integration suite see live.yml; that's nightly cron only.)
5
+ on:
6
+ push:
7
+ branches: [main]
8
+ pull_request:
9
+ branches: [main]
10
+ workflow_dispatch:
11
+
12
+ concurrency:
13
+ group: kuopac-tests-${{ github.ref }}
14
+ cancel-in-progress: true
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ test:
21
+ name: pytest (offline)
22
+ runs-on: ubuntu-latest
23
+ timeout-minutes: 10
24
+
25
+ steps:
26
+ - name: Checkout
27
+ uses: actions/checkout@v4
28
+
29
+ - name: Install uv
30
+ uses: astral-sh/setup-uv@v3
31
+ with:
32
+ enable-cache: true
33
+
34
+ - name: Set up Python
35
+ run: uv python install 3.12
36
+
37
+ - name: Install kuopac + dev deps
38
+ run: |
39
+ uv venv
40
+ uv pip install -e ".[dev]"
41
+
42
+ - name: Run pytest
43
+ env:
44
+ PYTHONIOENCODING: "utf-8"
45
+ run: uv run pytest -v --tb=short --color=no
@@ -0,0 +1,224 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
219
+
220
+ # kuopac-specific
221
+ audit_data/
222
+ probe_data/
223
+ har/
224
+ *.har
@@ -0,0 +1 @@
1
+ 3.12
kuopac-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 YoseiUshida
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.