slubfind 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.
@@ -0,0 +1,33 @@
1
+ # This workflow will upload a Python Package using Twine when a release is created
2
+ # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3
+
4
+ name: Upload Python Package
5
+
6
+ on:
7
+ release:
8
+ types: [created]
9
+ workflow_dispatch:
10
+
11
+ jobs:
12
+ deploy:
13
+
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v2
20
+ with:
21
+ python-version: '3.8'
22
+ - name: Install dependencies
23
+ run: |
24
+ python -m pip install --upgrade pip
25
+ pip install setuptools wheel build twine
26
+ pip install -r requirements.txt
27
+ - name: Build and publish
28
+ env:
29
+ TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
30
+ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
31
+ run: |
32
+ python -m build .
33
+ twine upload dist/*
@@ -0,0 +1,38 @@
1
+ # This workflow will install Python dependencies, run tests and lint with a single version of Python
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3
+
4
+ name: Tests
5
+
6
+ on: [push, pull_request]
7
+
8
+ jobs:
9
+ build:
10
+
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
15
+
16
+ steps:
17
+ - uses: actions/checkout@v3
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v3
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+ - name: Lint with flake8
23
+ run: |
24
+ pip install flake8
25
+ # stop the build if there are Python syntax errors or undefined names
26
+ flake8 slubfind --count --select=E9,F63,F7,F82 --show-source --statistics
27
+ # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
28
+ flake8 slubfind --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
29
+ - name: Install package
30
+ run: pip install .
31
+ - name: Install dependencies for test
32
+ run: pip install pytest coverage
33
+ - name: Run test and coverage
34
+ run: |
35
+ coverage erase
36
+ coverage run -m pytest test
37
+ coverage report
38
+ coverage html
@@ -0,0 +1,151 @@
1
+ # generated by setuptools-scm
2
+ slubfind/_version.py
3
+
4
+ # Development files / directories
5
+ _/
6
+ dev/
7
+ *-dev
8
+ *-dev.*
9
+ dev-*
10
+ dev.*
11
+
12
+ # Editor
13
+ *.swp
14
+ *.swo
15
+ *~
16
+ .vscode
17
+
18
+ # Data
19
+ *.json
20
+
21
+ # <https://github.com/github/gitignore/blob/master/Python.gitignore>
22
+
23
+ # Byte-compiled / optimized / DLL files
24
+ __pycache__/
25
+ *.py[cod]
26
+ *$py.class
27
+
28
+ # C extensions
29
+ *.so
30
+
31
+ # Distribution / packaging
32
+ .Python
33
+ build/
34
+ develop-eggs/
35
+ dist/
36
+ downloads/
37
+ eggs/
38
+ .eggs/
39
+ lib/
40
+ lib64/
41
+ parts/
42
+ sdist/
43
+ var/
44
+ wheels/
45
+ pip-wheel-metadata/
46
+ share/python-wheels/
47
+ *.egg-info/
48
+ .installed.cfg
49
+ *.egg
50
+ MANIFEST
51
+
52
+ # PyInstaller
53
+ # Usually these files are written by a python script from a template
54
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
55
+ *.manifest
56
+ *.spec
57
+
58
+ # Installer logs
59
+ pip-log.txt
60
+ pip-delete-this-directory.txt
61
+
62
+ # Unit test / coverage reports
63
+ htmlcov/
64
+ .tox/
65
+ .nox/
66
+ .coverage
67
+ .coverage.*
68
+ .cache
69
+ nosetests.xml
70
+ coverage.xml
71
+ *.cover
72
+ *.py,cover
73
+ .hypothesis/
74
+ .pytest_cache/
75
+
76
+ # Translations
77
+ *.mo
78
+ *.pot
79
+
80
+ # Django stuff:
81
+ *.log
82
+ local_settings.py
83
+ db.sqlite3
84
+ db.sqlite3-journal
85
+
86
+ # Flask stuff:
87
+ instance/
88
+ .webassets-cache
89
+
90
+ # Scrapy stuff:
91
+ .scrapy
92
+
93
+ # Sphinx documentation
94
+ docs/_build/
95
+
96
+ # PyBuilder
97
+ target/
98
+
99
+ # Jupyter Notebook
100
+ .ipynb_checkpoints
101
+
102
+ # IPython
103
+ profile_default/
104
+ ipython_config.py
105
+
106
+ # pyenv
107
+ .python-version
108
+
109
+ # pipenv
110
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
111
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
112
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
113
+ # install all needed dependencies.
114
+ #Pipfile.lock
115
+
116
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
117
+ __pypackages__/
118
+
119
+ # Celery stuff
120
+ celerybeat-schedule
121
+ celerybeat.pid
122
+
123
+ # SageMath parsed files
124
+ *.sage.py
125
+
126
+ # Environments
127
+ .env
128
+ .venv
129
+ env/
130
+ venv/
131
+ ENV/
132
+ env.bak/
133
+ venv.bak/
134
+
135
+ # Spyder project settings
136
+ .spyderproject
137
+ .spyproject
138
+
139
+ # Rope project settings
140
+ .ropeproject
141
+
142
+ # mkdocs documentation
143
+ /site
144
+
145
+ # mypy
146
+ .mypy_cache/
147
+ .dmypy.json
148
+ dmypy.json
149
+
150
+ # Pyre type checker
151
+ .pyre/
@@ -0,0 +1,5 @@
1
+ 0.1.0 [2025-06-01]
2
+ - first published release
3
+
4
+ 0.0.0 [2023-08-01]
5
+ - initial commit
slubfind-0.1.0/LICENSE ADDED
File without changes
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.1
2
+ Name: slubfind
3
+ Version: 0.1.0
4
+ Summary: query data exports from the SLUB catalogue
5
+ Author: Donatus Herre
6
+ Author-email: donatus.herre@slub-dresden.de
7
+ License: GPLv3
8
+ Project-URL: homepage, https://github.com/slub/slubfind
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Education
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.7
18
+ Description-Content-Type: text/x-rst
19
+ License-File: LICENSE
20
+ Requires-Dist: txpyfind
21
+
22
+ ========
23
+ slubfind
24
+ ========
25
+
26
+ With ``slubfind`` you can query data exports from the `SLUB catalogue <https://katalog.slub-dresden.de>`_
27
+ in Python.
28
+
29
+ This package is based on `txpyfind <https://github.com/slub/txpyfind>`_,
30
+ which enables access to data exports from `TYPO3-find <https://github.com/subugoe/typo3-find>`_.
31
+
32
+ Installation
33
+ ============
34
+
35
+ ... via PyPI
36
+ ~~~~~~~~~~~~
37
+
38
+ .. code-block:: bash
39
+
40
+ pip install slubfind
41
+
42
+ ... or from Github source
43
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
44
+
45
+ .. code-block:: bash
46
+
47
+ pip install git+https://github.com/slub/slubfind.git
48
+
49
+
50
+ Usage Example
51
+ =============
52
+
53
+ .. code-block:: python
54
+
55
+ from slubfind.client import SlubFind
56
+ # create SlubFind instance
57
+ slub_find = SlubFind()
58
+ # retrieve JSON data (query view, app format)
59
+ slub_q = slub_find.app_search("manfred bonitz")
60
+ # retrieve JSON data (detail view, app format)
61
+ slub_doc = slub_find.app_document("0-1132486122")
@@ -0,0 +1,40 @@
1
+ ========
2
+ slubfind
3
+ ========
4
+
5
+ With ``slubfind`` you can query data exports from the `SLUB catalogue <https://katalog.slub-dresden.de>`_
6
+ in Python.
7
+
8
+ This package is based on `txpyfind <https://github.com/slub/txpyfind>`_,
9
+ which enables access to data exports from `TYPO3-find <https://github.com/subugoe/typo3-find>`_.
10
+
11
+ Installation
12
+ ============
13
+
14
+ ... via PyPI
15
+ ~~~~~~~~~~~~
16
+
17
+ .. code-block:: bash
18
+
19
+ pip install slubfind
20
+
21
+ ... or from Github source
22
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
23
+
24
+ .. code-block:: bash
25
+
26
+ pip install git+https://github.com/slub/slubfind.git
27
+
28
+
29
+ Usage Example
30
+ =============
31
+
32
+ .. code-block:: python
33
+
34
+ from slubfind.client import SlubFind
35
+ # create SlubFind instance
36
+ slub_find = SlubFind()
37
+ # retrieve JSON data (query view, app format)
38
+ slub_q = slub_find.app_search("manfred bonitz")
39
+ # retrieve JSON data (detail view, app format)
40
+ slub_doc = slub_find.app_document("0-1132486122")
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = [
3
+ "setuptools>=42",
4
+ "setuptools_scm[toml]",
5
+ "wheel",
6
+ ] # PEP 508 specifications.
7
+ build-backend = "setuptools.build_meta"
8
+
9
+ [project]
10
+ name = "slubfind"
11
+ description = "query data exports from the SLUB catalogue"
12
+ readme = "README.rst"
13
+ authors = [
14
+ {name = "Donatus Herre"},
15
+ {email = "donatus.herre@slub-dresden.de"}
16
+ ]
17
+ license = {text = "GPLv3"}
18
+ keywords = []
19
+ classifiers = [
20
+ "Programming Language :: Python :: 3",
21
+ "Operating System :: OS Independent",
22
+ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
23
+ "Development Status :: 3 - Alpha",
24
+ "Intended Audience :: Developers",
25
+ "Intended Audience :: Education",
26
+ "Intended Audience :: Science/Research",
27
+ "Topic :: Software Development :: Libraries :: Python Modules",
28
+ ]
29
+ dynamic = ["version", "dependencies"]
30
+ requires-python = ">=3.7"
31
+
32
+ [project.urls]
33
+ homepage = "https://github.com/slub/slubfind"
34
+
35
+ [project.scripts]
36
+ #slubfind = "slubfind.cli:cli"
37
+
38
+ [tool.setuptools.dynamic]
39
+ dependencies = {file = ["requirements.txt"]}
40
+
41
+ [tool.setuptools_scm]
42
+ write_to = "slubfind/_version.py"
@@ -0,0 +1 @@
1
+ txpyfind
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,7 @@
1
+ """
2
+ With ``slubfind`` you can query data exports from the SLUB catalogue.
3
+ """
4
+ from . import client, parser
5
+ from ._version import __version__, version, version_tuple
6
+
7
+ __all__ = ["client", "parser", "__version__", "version", "version_tuple"]
@@ -0,0 +1,21 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5
+
6
+ TYPE_CHECKING = False
7
+ if TYPE_CHECKING:
8
+ from typing import Tuple
9
+ from typing import Union
10
+
11
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
12
+ else:
13
+ VERSION_TUPLE = object
14
+
15
+ version: str
16
+ __version__: str
17
+ __version_tuple__: VERSION_TUPLE
18
+ version_tuple: VERSION_TUPLE
19
+
20
+ __version__ = version = '0.1.0'
21
+ __version_tuple__ = version_tuple = (0, 1, 0)
@@ -0,0 +1,188 @@
1
+ """
2
+ client module of ``slubfind`` package
3
+ """
4
+ import re
5
+ from txpyfind import utils
6
+ from txpyfind.client import Find
7
+ from txpyfind.parser import JSONResponse
8
+
9
+ from .parser import AppDetails
10
+
11
+
12
+ class SlubFind(Find):
13
+ """
14
+ ``SlubFind`` class from ``slubfind.client`` module
15
+ """
16
+
17
+ def __init__(
18
+ self,
19
+ base_url="https://katalog.slub-dresden.de",
20
+ export_format="app",
21
+ export_page=1369315142,
22
+ parser_class=JSONResponse):
23
+ super().__init__(
24
+ base_url,
25
+ document_path="id",
26
+ query_types=[
27
+ "default",
28
+ "author",
29
+ "title",
30
+ "topic",
31
+ "barcode",
32
+ "ident",
33
+ "rvk_facet",
34
+ "signatur",
35
+ "imprint",
36
+ "series2",
37
+ "provenance"
38
+ ],
39
+ facets=[
40
+ "facet_avail",
41
+ "format_de14",
42
+ "publishDateSort",
43
+ "branch_collcode",
44
+ "branch",
45
+ "license",
46
+ "access_state",
47
+ "language",
48
+ "thema",
49
+ "author",
50
+ "facet_music_notation_de14",
51
+ "music_heading_browse",
52
+ "provenance",
53
+ "mega_collection"
54
+ ],
55
+ count_limit=1000,
56
+ sort_pattern=re.compile(
57
+ r"^(score|publishDateSort|title_sort|id)[+ ](asc|desc)$"),
58
+ export_format=export_format,
59
+ export_page=export_page,
60
+ parser_class=parser_class)
61
+
62
+ def app_document(
63
+ self,
64
+ document_id,
65
+ type_num=None):
66
+ """
67
+ fetch detail view in app format
68
+ """
69
+ return self.get_document(
70
+ document_id,
71
+ data_format="app",
72
+ type_num=type_num,
73
+ parser_class=AppDetails)
74
+
75
+ def app_search(
76
+ self,
77
+ query,
78
+ qtype="default",
79
+ facet=None,
80
+ page=0,
81
+ count=0,
82
+ sort="",
83
+ type_num=None,
84
+ parser_class=None):
85
+ """
86
+ fetch query view in app format
87
+ """
88
+ return self.get_query(
89
+ query,
90
+ qtype=qtype,
91
+ facet=facet,
92
+ page=page,
93
+ count=count,
94
+ sort=sort,
95
+ data_format="app",
96
+ type_num=type_num,
97
+ parser_class=parser_class)
98
+
99
+ def settings(self):
100
+ """
101
+ get the settings used for TYPO3-find
102
+ """
103
+ url = self.url_query(
104
+ "qqqqq",
105
+ qtype="default",
106
+ facet=None,
107
+ page=0,
108
+ count=0,
109
+ sort="",
110
+ data_format="json-all",
111
+ type_num=None)
112
+ response = utils.json_request(url)
113
+ if isinstance(response, dict) and "settings" in response:
114
+ return response["settings"]
115
+ return None
116
+
117
+ def solr_params(
118
+ self,
119
+ query,
120
+ qtype="default",
121
+ facet=None,
122
+ page=0,
123
+ count=0,
124
+ sort="",
125
+ type_num=None):
126
+ """
127
+ get the parameters used for the Solr request
128
+ """
129
+ url = self.url_query(
130
+ query=query,
131
+ qtype=qtype,
132
+ facet=facet,
133
+ page=page,
134
+ count=count,
135
+ sort=sort,
136
+ data_format="json-solr-params",
137
+ type_num=type_num)
138
+ url = utils.add_tx_param(url, "omitHeader", "false")
139
+ response = utils.json_request(url)
140
+ if isinstance(response, dict):
141
+ return response
142
+ return None
143
+
144
+ def solr_params_via_url(
145
+ self,
146
+ url,
147
+ type_num=None):
148
+ """
149
+ get the parameters used for the Solr request via given TYPO3-find URL
150
+ """
151
+ url = self.url_parser(url)
152
+ if url.is_ok:
153
+ return self.solr_params(
154
+ url.query,
155
+ qtype=url.qtype,
156
+ facet=url.facets,
157
+ page=url.page,
158
+ count=url.count,
159
+ sort=url.sort,
160
+ type_num=type_num)
161
+ return None
162
+
163
+ def solr_request(
164
+ self,
165
+ query,
166
+ qtype="default",
167
+ facet=None,
168
+ page=0,
169
+ count=0,
170
+ sort="",
171
+ type_num=None):
172
+ """
173
+ get the URL of the Solr request
174
+ """
175
+ url = self.url_query(
176
+ query=query,
177
+ qtype=qtype,
178
+ facet=facet,
179
+ page=page,
180
+ count=count,
181
+ sort=sort,
182
+ data_format="json-solr-request",
183
+ type_num=type_num)
184
+ url = utils.add_tx_param(url, "debug", "1")
185
+ response = utils.json_request(url)
186
+ if isinstance(response, dict) and "url" in response:
187
+ return response["url"]
188
+ return None
@@ -0,0 +1,16 @@
1
+ """
2
+ parser module of ``slubfind``
3
+ """
4
+ from txpyfind.parser import JSONResponse
5
+
6
+
7
+ class AppDetails(JSONResponse):
8
+ """
9
+ ``AppDetails`` class from ``slubfind.parser`` module
10
+ """
11
+
12
+ def __init__(self, plain):
13
+ super().__init__(plain)
14
+ self.ok = isinstance(self.raw, dict) and "id" in self.raw
15
+ self.found = self.ok and isinstance(
16
+ self.raw["id"], str) and len(self.raw["id"].strip()) > 0
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.1
2
+ Name: slubfind
3
+ Version: 0.1.0
4
+ Summary: query data exports from the SLUB catalogue
5
+ Author: Donatus Herre
6
+ Author-email: donatus.herre@slub-dresden.de
7
+ License: GPLv3
8
+ Project-URL: homepage, https://github.com/slub/slubfind
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Education
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.7
18
+ Description-Content-Type: text/x-rst
19
+ License-File: LICENSE
20
+ Requires-Dist: txpyfind
21
+
22
+ ========
23
+ slubfind
24
+ ========
25
+
26
+ With ``slubfind`` you can query data exports from the `SLUB catalogue <https://katalog.slub-dresden.de>`_
27
+ in Python.
28
+
29
+ This package is based on `txpyfind <https://github.com/slub/txpyfind>`_,
30
+ which enables access to data exports from `TYPO3-find <https://github.com/subugoe/typo3-find>`_.
31
+
32
+ Installation
33
+ ============
34
+
35
+ ... via PyPI
36
+ ~~~~~~~~~~~~
37
+
38
+ .. code-block:: bash
39
+
40
+ pip install slubfind
41
+
42
+ ... or from Github source
43
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
44
+
45
+ .. code-block:: bash
46
+
47
+ pip install git+https://github.com/slub/slubfind.git
48
+
49
+
50
+ Usage Example
51
+ =============
52
+
53
+ .. code-block:: python
54
+
55
+ from slubfind.client import SlubFind
56
+ # create SlubFind instance
57
+ slub_find = SlubFind()
58
+ # retrieve JSON data (query view, app format)
59
+ slub_q = slub_find.app_search("manfred bonitz")
60
+ # retrieve JSON data (detail view, app format)
61
+ slub_doc = slub_find.app_document("0-1132486122")
@@ -0,0 +1,19 @@
1
+ .gitignore
2
+ CHANGELOG
3
+ LICENSE
4
+ README.rst
5
+ pyproject.toml
6
+ requirements.txt
7
+ .github/workflows/pypi.yml
8
+ .github/workflows/test.yml
9
+ slubfind/__init__.py
10
+ slubfind/_version.py
11
+ slubfind/client.py
12
+ slubfind/parser.py
13
+ slubfind.egg-info/PKG-INFO
14
+ slubfind.egg-info/SOURCES.txt
15
+ slubfind.egg-info/dependency_links.txt
16
+ slubfind.egg-info/requires.txt
17
+ slubfind.egg-info/top_level.txt
18
+ test/__init__.py
19
+ test/test_client.py
@@ -0,0 +1 @@
1
+ txpyfind
@@ -0,0 +1 @@
1
+ slubfind
File without changes
@@ -0,0 +1,43 @@
1
+ from slubfind.client import SlubFind
2
+
3
+ def test_get_document():
4
+ # create SlubFind instance
5
+ slub_find = SlubFind()
6
+ # retrieve JSON data (detail view, app format)
7
+ slub_app_doc = slub_find.app_document("0-1132486122")
8
+ assert slub_app_doc is not None
9
+
10
+ def test_get_query():
11
+ # create SlubFind instance
12
+ slub_find = SlubFind()
13
+ # retrieve JSON data (query view, app format)
14
+ slub_app_query = slub_find.app_search("manfred bonitz")
15
+ assert slub_app_query is not None
16
+
17
+ def test_settings():
18
+ # create SlubFind instance
19
+ slub_find = SlubFind()
20
+ # retrieve TYPO3-find settings (query view)
21
+ slub_find_settings = slub_find.settings()
22
+ assert slub_find_settings is not None
23
+
24
+ #def test_solr_params():
25
+ # # create SlubFind instance
26
+ # slub_find = SlubFind()
27
+ # # retrieve Solr parameters (query view)
28
+ # slub_find_solr_params = slub_find.solr_params("manfred bonitz")
29
+ # assert slub_find_solr_params is not None
30
+
31
+ #def test_solr_params_via_url():
32
+ # # create SlubFind instance
33
+ # slub_find = SlubFind()
34
+ # # retrieve Solr parameters (query view)
35
+ # slub_find_solr_params_via_url = slub_find.solr_params_via_url("https://katalog.slub-dresden.de/?tx_find_find%5Bq%5D%5Bdefault%5D=manfred+bonitz")
36
+ # assert slub_find_solr_params_via_url is not None
37
+
38
+ def test_solr_request():
39
+ # create SlubFind instance
40
+ slub_find = SlubFind()
41
+ # retrieve Solr URL (query view)
42
+ slub_find_solr_request = slub_find.solr_request("manfred bonitz")
43
+ assert slub_find_solr_request is not None