summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-05-05 15:19:58 +0000
committerCoprDistGit <infra@openeuler.org>2023-05-05 15:19:58 +0000
commitba5ab57723399313ac59f2c84734615f2010d544 (patch)
tree83bca303e11c48fe6d76978c9c1c2126a9fed61c
parent4338c7845f8f6ccbf5a3eee86a92796750caf6ce (diff)
automatic import of python-museumpyopeneuler20.03
-rw-r--r--.gitignore1
-rw-r--r--python-museumpy.spec612
-rw-r--r--sources1
3 files changed, 614 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..ce9d439 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/museumpy-0.3.0.tar.gz
diff --git a/python-museumpy.spec b/python-museumpy.spec
new file mode 100644
index 0000000..5376c00
--- /dev/null
+++ b/python-museumpy.spec
@@ -0,0 +1,612 @@
+%global _empty_manifest_terminate_build 0
+Name: python-museumpy
+Version: 0.3.0
+Release: 1
+Summary: Client for MuseumPlus
+License: MIT
+URL: https://github.com/metaodi/museumpy
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/c8/16/915bd702e306ddf2d9847b003d1fad1302f67da12cbac1721a665c864e00/museumpy-0.3.0.tar.gz
+BuildArch: noarch
+
+Requires: python3-requests
+Requires: python3-defusedxml
+Requires: python3-xmltodict
+
+%description
+# museumpy
+
+**museum**py is a client for python to get data from [Zetcom MuseumPlus](https://www.zetcom.com/en/museumplus-en/) instances.
+
+## Table of Contents
+
+* [Installation](#installation)
+* [Usage](#usage)
+ * [`search`](#search)
+ * [`fulltext_search`](#fulltext_search)
+* [Advanced Usage](#advanced-usage)
+ * [`module_item`](#module_item)
+ * [`download_attachement`](#download_attachement)
+ * [Custom mapping of fields](#custom-mapping-of-fields)
+* [Release](#release)
+
+## Installation
+
+[museumpy is available on PyPI](https://pypi.org/project/museumpy/), so to install it simply use:
+
+```
+$ pip install museumpy
+```
+
+## Usage
+
+See the [`examples` directory](/examples) for more scripts.
+
+### `search`
+
+```python
+import museumpy
+
+records = museumpy.search(
+ base_url='https://mpzurichrietberg.zetcom.com/MpWeb-mpZurichRietberg',
+ field='ObjObjectNumberTxt',
+ value='2019.184',
+)
+
+
+for record in records:
+ print(record)
+```
+
+
+The return value of `search` is iterable, so you can easily loop over it. Or you can use indices to access elements, e.g. `records[1]` to get the second element, or `records[-1]` to get the last one.
+
+Even [slicing](https://python-reference.readthedocs.io/en/latest/docs/brackets/slicing.html) is supported, so you can do things like only iterate over the first 5 elements using
+
+```python
+for records in records[:5]:
+ print(record)
+```
+
+### `fulltext_search`
+```python
+import museumpy
+
+records = museumpy.fulltext_search(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ query='Patolu',
+)
+
+
+for record in records:
+ print(record)
+```
+
+## Advanced usage
+
+For more advanced usage of this library, it is recommened to first create a client instance and then use this to request data:
+
+```python
+import museumpy
+import requests
+
+s = requests.Session()
+s.auth = ('user', 'pass')
+s.headers.update({'Accept-Language': 'de'})
+
+client = museumpy.MuseumPlusClient(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ session=s
+)
+
+```
+
+
+### `module_item`
+```python
+import museumpy
+
+id = '98977'
+module = 'Multimedia'
+item = client.module_item(id, module)
+```
+
+### `download_attachement`
+```python
+import museumpy
+
+id = '98977'
+module = 'Multimedia'
+# download attachment to a directory called `files`
+attachment_path = client.download_attachment(id, module, 'files')
+print(attachment_path)
+```
+
+### Custom mapping of fields
+
+There are most likely custom fields on the MuseumPlus Instance you want to query.
+The returned XML is converted to a python `dict` using the [`xmltodict` library](https://pypi.org/project/xmltodict/).
+The raw dict is returned on the `raw` key of the result:
+
+```python
+import museumpy
+
+records = museumpy.search(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ query='Patolu',
+)
+for record in records:
+ print(record['raw'])
+```
+
+For convenience a default mapping is provided to access some fields more easily:
+
+
+```python
+for record in records:
+ print(record['hasAttachments'])
+ print(record['ObjObjectNumberTxt'])
+```
+
+If you want to customize this mapping, you can pass a `map_function` to the client, which is then used on all subsequent calls to `search` and `fulltext_search`:
+
+
+```python
+import museumpy
+
+def my_custom_map(record, xml_rec):
+ NS = "http://www.zetcom.com/ria/ws/module"
+ ID_XPATH = f".//{{{NS}}}dataField[@name='ObjObjectNumberTxt']/{{{NS}}}value"
+ TITLE_XPATH = f".//{{{NS}}}repeatableGroup[@name='ObjObjectTitleGrp']//{{{NS}}}dataField[@name='TitleTxt']//{{{NS}}}value"
+
+ xml_parser = museumpy.xmlparse.XMLParser()
+ my_new_record = {
+ 'my_id': xml_parser.find(xml_rec, ID_XPATH).text,
+ 'my_title': xml_parser.find(xml_rec, TITLE_XPATH).text
+ }
+ return my_new_record
+
+
+client = museumpy.MuseumPlusClient(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ map_function=my_custom_map,
+)
+
+records = client.search(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ query='Patolu',
+)
+for record in records:
+ print(record['my_id'])
+ print(record['my_title'])
+
+```
+
+## Release
+
+To create a new release, follow these steps (please respect [Semantic Versioning](http://semver.org/)):
+
+1. Adapt the version number in `museumpy/__init__.py`
+1. Update the CHANGELOG with the version
+1. Create a [pull request to merge `develop` into `main`](https://github.com/metaodi/museumpy/compare/main...develop?expand=1) (make sure the tests pass!)
+1. Create a [new release/tag on GitHub](https://github.com/metaodi/museumpy/releases) (on the main branch)
+1. The [publication on PyPI](https://pypi.python.org/pypi/museumpy) happens via [GitHub Actions](https://github.com/metaodi/museumpy/actions?query=workflow%3A%22Upload+Python+Package%22) on every tagged commit
+
+
+
+
+%package -n python3-museumpy
+Summary: Client for MuseumPlus
+Provides: python-museumpy
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-museumpy
+# museumpy
+
+**museum**py is a client for python to get data from [Zetcom MuseumPlus](https://www.zetcom.com/en/museumplus-en/) instances.
+
+## Table of Contents
+
+* [Installation](#installation)
+* [Usage](#usage)
+ * [`search`](#search)
+ * [`fulltext_search`](#fulltext_search)
+* [Advanced Usage](#advanced-usage)
+ * [`module_item`](#module_item)
+ * [`download_attachement`](#download_attachement)
+ * [Custom mapping of fields](#custom-mapping-of-fields)
+* [Release](#release)
+
+## Installation
+
+[museumpy is available on PyPI](https://pypi.org/project/museumpy/), so to install it simply use:
+
+```
+$ pip install museumpy
+```
+
+## Usage
+
+See the [`examples` directory](/examples) for more scripts.
+
+### `search`
+
+```python
+import museumpy
+
+records = museumpy.search(
+ base_url='https://mpzurichrietberg.zetcom.com/MpWeb-mpZurichRietberg',
+ field='ObjObjectNumberTxt',
+ value='2019.184',
+)
+
+
+for record in records:
+ print(record)
+```
+
+
+The return value of `search` is iterable, so you can easily loop over it. Or you can use indices to access elements, e.g. `records[1]` to get the second element, or `records[-1]` to get the last one.
+
+Even [slicing](https://python-reference.readthedocs.io/en/latest/docs/brackets/slicing.html) is supported, so you can do things like only iterate over the first 5 elements using
+
+```python
+for records in records[:5]:
+ print(record)
+```
+
+### `fulltext_search`
+```python
+import museumpy
+
+records = museumpy.fulltext_search(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ query='Patolu',
+)
+
+
+for record in records:
+ print(record)
+```
+
+## Advanced usage
+
+For more advanced usage of this library, it is recommened to first create a client instance and then use this to request data:
+
+```python
+import museumpy
+import requests
+
+s = requests.Session()
+s.auth = ('user', 'pass')
+s.headers.update({'Accept-Language': 'de'})
+
+client = museumpy.MuseumPlusClient(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ session=s
+)
+
+```
+
+
+### `module_item`
+```python
+import museumpy
+
+id = '98977'
+module = 'Multimedia'
+item = client.module_item(id, module)
+```
+
+### `download_attachement`
+```python
+import museumpy
+
+id = '98977'
+module = 'Multimedia'
+# download attachment to a directory called `files`
+attachment_path = client.download_attachment(id, module, 'files')
+print(attachment_path)
+```
+
+### Custom mapping of fields
+
+There are most likely custom fields on the MuseumPlus Instance you want to query.
+The returned XML is converted to a python `dict` using the [`xmltodict` library](https://pypi.org/project/xmltodict/).
+The raw dict is returned on the `raw` key of the result:
+
+```python
+import museumpy
+
+records = museumpy.search(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ query='Patolu',
+)
+for record in records:
+ print(record['raw'])
+```
+
+For convenience a default mapping is provided to access some fields more easily:
+
+
+```python
+for record in records:
+ print(record['hasAttachments'])
+ print(record['ObjObjectNumberTxt'])
+```
+
+If you want to customize this mapping, you can pass a `map_function` to the client, which is then used on all subsequent calls to `search` and `fulltext_search`:
+
+
+```python
+import museumpy
+
+def my_custom_map(record, xml_rec):
+ NS = "http://www.zetcom.com/ria/ws/module"
+ ID_XPATH = f".//{{{NS}}}dataField[@name='ObjObjectNumberTxt']/{{{NS}}}value"
+ TITLE_XPATH = f".//{{{NS}}}repeatableGroup[@name='ObjObjectTitleGrp']//{{{NS}}}dataField[@name='TitleTxt']//{{{NS}}}value"
+
+ xml_parser = museumpy.xmlparse.XMLParser()
+ my_new_record = {
+ 'my_id': xml_parser.find(xml_rec, ID_XPATH).text,
+ 'my_title': xml_parser.find(xml_rec, TITLE_XPATH).text
+ }
+ return my_new_record
+
+
+client = museumpy.MuseumPlusClient(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ map_function=my_custom_map,
+)
+
+records = client.search(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ query='Patolu',
+)
+for record in records:
+ print(record['my_id'])
+ print(record['my_title'])
+
+```
+
+## Release
+
+To create a new release, follow these steps (please respect [Semantic Versioning](http://semver.org/)):
+
+1. Adapt the version number in `museumpy/__init__.py`
+1. Update the CHANGELOG with the version
+1. Create a [pull request to merge `develop` into `main`](https://github.com/metaodi/museumpy/compare/main...develop?expand=1) (make sure the tests pass!)
+1. Create a [new release/tag on GitHub](https://github.com/metaodi/museumpy/releases) (on the main branch)
+1. The [publication on PyPI](https://pypi.python.org/pypi/museumpy) happens via [GitHub Actions](https://github.com/metaodi/museumpy/actions?query=workflow%3A%22Upload+Python+Package%22) on every tagged commit
+
+
+
+
+%package help
+Summary: Development documents and examples for museumpy
+Provides: python3-museumpy-doc
+%description help
+# museumpy
+
+**museum**py is a client for python to get data from [Zetcom MuseumPlus](https://www.zetcom.com/en/museumplus-en/) instances.
+
+## Table of Contents
+
+* [Installation](#installation)
+* [Usage](#usage)
+ * [`search`](#search)
+ * [`fulltext_search`](#fulltext_search)
+* [Advanced Usage](#advanced-usage)
+ * [`module_item`](#module_item)
+ * [`download_attachement`](#download_attachement)
+ * [Custom mapping of fields](#custom-mapping-of-fields)
+* [Release](#release)
+
+## Installation
+
+[museumpy is available on PyPI](https://pypi.org/project/museumpy/), so to install it simply use:
+
+```
+$ pip install museumpy
+```
+
+## Usage
+
+See the [`examples` directory](/examples) for more scripts.
+
+### `search`
+
+```python
+import museumpy
+
+records = museumpy.search(
+ base_url='https://mpzurichrietberg.zetcom.com/MpWeb-mpZurichRietberg',
+ field='ObjObjectNumberTxt',
+ value='2019.184',
+)
+
+
+for record in records:
+ print(record)
+```
+
+
+The return value of `search` is iterable, so you can easily loop over it. Or you can use indices to access elements, e.g. `records[1]` to get the second element, or `records[-1]` to get the last one.
+
+Even [slicing](https://python-reference.readthedocs.io/en/latest/docs/brackets/slicing.html) is supported, so you can do things like only iterate over the first 5 elements using
+
+```python
+for records in records[:5]:
+ print(record)
+```
+
+### `fulltext_search`
+```python
+import museumpy
+
+records = museumpy.fulltext_search(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ query='Patolu',
+)
+
+
+for record in records:
+ print(record)
+```
+
+## Advanced usage
+
+For more advanced usage of this library, it is recommened to first create a client instance and then use this to request data:
+
+```python
+import museumpy
+import requests
+
+s = requests.Session()
+s.auth = ('user', 'pass')
+s.headers.update({'Accept-Language': 'de'})
+
+client = museumpy.MuseumPlusClient(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ session=s
+)
+
+```
+
+
+### `module_item`
+```python
+import museumpy
+
+id = '98977'
+module = 'Multimedia'
+item = client.module_item(id, module)
+```
+
+### `download_attachement`
+```python
+import museumpy
+
+id = '98977'
+module = 'Multimedia'
+# download attachment to a directory called `files`
+attachment_path = client.download_attachment(id, module, 'files')
+print(attachment_path)
+```
+
+### Custom mapping of fields
+
+There are most likely custom fields on the MuseumPlus Instance you want to query.
+The returned XML is converted to a python `dict` using the [`xmltodict` library](https://pypi.org/project/xmltodict/).
+The raw dict is returned on the `raw` key of the result:
+
+```python
+import museumpy
+
+records = museumpy.search(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ query='Patolu',
+)
+for record in records:
+ print(record['raw'])
+```
+
+For convenience a default mapping is provided to access some fields more easily:
+
+
+```python
+for record in records:
+ print(record['hasAttachments'])
+ print(record['ObjObjectNumberTxt'])
+```
+
+If you want to customize this mapping, you can pass a `map_function` to the client, which is then used on all subsequent calls to `search` and `fulltext_search`:
+
+
+```python
+import museumpy
+
+def my_custom_map(record, xml_rec):
+ NS = "http://www.zetcom.com/ria/ws/module"
+ ID_XPATH = f".//{{{NS}}}dataField[@name='ObjObjectNumberTxt']/{{{NS}}}value"
+ TITLE_XPATH = f".//{{{NS}}}repeatableGroup[@name='ObjObjectTitleGrp']//{{{NS}}}dataField[@name='TitleTxt']//{{{NS}}}value"
+
+ xml_parser = museumpy.xmlparse.XMLParser()
+ my_new_record = {
+ 'my_id': xml_parser.find(xml_rec, ID_XPATH).text,
+ 'my_title': xml_parser.find(xml_rec, TITLE_XPATH).text
+ }
+ return my_new_record
+
+
+client = museumpy.MuseumPlusClient(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ map_function=my_custom_map,
+)
+
+records = client.search(
+ base_url='https://test.zetcom.com/MpWeb-mpTest',
+ query='Patolu',
+)
+for record in records:
+ print(record['my_id'])
+ print(record['my_title'])
+
+```
+
+## Release
+
+To create a new release, follow these steps (please respect [Semantic Versioning](http://semver.org/)):
+
+1. Adapt the version number in `museumpy/__init__.py`
+1. Update the CHANGELOG with the version
+1. Create a [pull request to merge `develop` into `main`](https://github.com/metaodi/museumpy/compare/main...develop?expand=1) (make sure the tests pass!)
+1. Create a [new release/tag on GitHub](https://github.com/metaodi/museumpy/releases) (on the main branch)
+1. The [publication on PyPI](https://pypi.python.org/pypi/museumpy) happens via [GitHub Actions](https://github.com/metaodi/museumpy/actions?query=workflow%3A%22Upload+Python+Package%22) on every tagged commit
+
+
+
+
+%prep
+%autosetup -n museumpy-0.3.0
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-museumpy -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 0.3.0-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..68dc90c
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+b183080b711cbdc4b379a9696b1ed36d museumpy-0.3.0.tar.gz