summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-06-20 06:51:53 +0000
committerCoprDistGit <infra@openeuler.org>2023-06-20 06:51:53 +0000
commitf327785a27651a5fa29f5a54c6ef4bb286e3f37b (patch)
tree82d465baca1cae54cbeb44015507875d98b7528d
parentc85190492dac3bde6bdb7628bbdcf088e0a51ca4 (diff)
automatic import of python-apimapperopeneuler20.03
-rw-r--r--.gitignore1
-rw-r--r--python-apimapper.spec305
-rw-r--r--sources1
3 files changed, 307 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..e330fc9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/apimapper-0.7.9.tar.gz
diff --git a/python-apimapper.spec b/python-apimapper.spec
new file mode 100644
index 0000000..cc44dae
--- /dev/null
+++ b/python-apimapper.spec
@@ -0,0 +1,305 @@
+%global _empty_manifest_terminate_build 0
+Name: python-apimapper
+Version: 0.7.9
+Release: 1
+Summary: API Mapper
+License: MIT
+URL: https://github.com/acdh-oeaw/apimapper
+Source0: https://mirrors.aliyun.com/pypi/web/packages/68/c6/eab4525895270166631c93dcf55687b5bd0b37e5f83be5b2445fd2488628/apimapper-0.7.9.tar.gz
+BuildArch: noarch
+
+Requires: python3-markdown
+Requires: python3-requests
+
+%description
+# API Wrapper
+
+## Install package
+* from PyPi:
+ pip install apimapper
+* from source:
+ pip install -e .
+
+## Unit Testing
+ >pytest
+
+## Usage
+
+* See https://github.com/acdh-oeaw/apimapper/blob/develop/demo/APIMapper%20Demo.ipynb
+* Multiple APIs (GND and VIAF) mapped to a common JSON schema
+
+VIAF only returns VIAF ID - which is contructed into a url using a "rule"
+```
+from apimapper import APIMapper
+from apimapper import config
+
+GND_PERSON_MAP = {config.DIRECT: {'uri': 'id',
+ 'label': 'label'}}
+
+VIAF_PERSON_MAP = {config.RESULT: 'result',
+ config.FILTER: {'nametype': 'personal'},
+ config.DIRECT: {'label': 'displayForm'},
+ config.RULES: {'uri': {config.RULE: '"http://www.viaf.org/viaf/{p1}"',
+ config.FIELDS: {'p1': 'viafid'}}}}
+
+GND_PERSON_SOURCE = {config.URL: 'https://lobid.org/gnd/search',
+ config.QUERY_FIELD: 'q',
+ config.PAYLOAD: {'format':'json:suggest',
+ 'filter': 'type:Person'}}
+
+VIAF_PERSON_SOURCE = {config.URL: 'http://www.viaf.org/viaf/AutoSuggest',
+ config.QUERY_FIELD: 'query'}
+
+
+gnd = APIMapper(GND_PERSON_SOURCE, GND_PERSON_MAP)
+viaf = APIMapper(VIAF_PERSON_SOURCE, VIAF_PERSON_MAP)
+apis = [gnd, viaf]
+results = []
+for api in apis:
+ res = api.fetch_results('Pratchett')
+ results.extend(res)
+
+print(results)
+```
+
+* Using mapping rules
+
+Splitting the GND label field into meaningful subparts
+```
+from apimapper import APIMapper
+from apimapper import config
+
+GND_PERSON_SOURCE = {config.URL: 'https://lobid.org/gnd/search',
+ config.QUERY_FIELD: 'q',
+ config.PAYLOAD: {'format':'json:suggest',
+ 'filter': 'type:Person'}}
+
+GND_PERSON_MAP = {config.DIRECT: {'label': 'label',
+ 'uri': 'id'},
+ config.RULES: {'source': {config.RULE: '"GND"'},
+ 'label_name': {config.RULE: '"{p1}".split("|")[0].strip()',
+ config.FIELDS: {'p1': 'label'}},
+ 'label_year': {config.RULE: '"{p1}".split("|")[1].strip() if "{p1}".split("|")[1].strip()[0].isnumeric() else ""',
+ config.FIELDS: {'p1': 'label'}},
+ 'label_profession': {config.RULE: '"{p1}".split("|")[2].strip() if "{p1}".split("|")[1].strip()[0].isnumeric() else "{p1}".split("|")[1].strip()',
+ config.FIELDS: {'p1': 'label'}}}}
+
+api = APIMapper(GND_PERSON_SOURCE, GND_PERSON_MAP)
+res = api.fetch_results('Rosalind Franklin')
+```
+
+* More example usage in apimapper/demo
+
+
+%package -n python3-apimapper
+Summary: API Mapper
+Provides: python-apimapper
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-apimapper
+# API Wrapper
+
+## Install package
+* from PyPi:
+ pip install apimapper
+* from source:
+ pip install -e .
+
+## Unit Testing
+ >pytest
+
+## Usage
+
+* See https://github.com/acdh-oeaw/apimapper/blob/develop/demo/APIMapper%20Demo.ipynb
+* Multiple APIs (GND and VIAF) mapped to a common JSON schema
+
+VIAF only returns VIAF ID - which is contructed into a url using a "rule"
+```
+from apimapper import APIMapper
+from apimapper import config
+
+GND_PERSON_MAP = {config.DIRECT: {'uri': 'id',
+ 'label': 'label'}}
+
+VIAF_PERSON_MAP = {config.RESULT: 'result',
+ config.FILTER: {'nametype': 'personal'},
+ config.DIRECT: {'label': 'displayForm'},
+ config.RULES: {'uri': {config.RULE: '"http://www.viaf.org/viaf/{p1}"',
+ config.FIELDS: {'p1': 'viafid'}}}}
+
+GND_PERSON_SOURCE = {config.URL: 'https://lobid.org/gnd/search',
+ config.QUERY_FIELD: 'q',
+ config.PAYLOAD: {'format':'json:suggest',
+ 'filter': 'type:Person'}}
+
+VIAF_PERSON_SOURCE = {config.URL: 'http://www.viaf.org/viaf/AutoSuggest',
+ config.QUERY_FIELD: 'query'}
+
+
+gnd = APIMapper(GND_PERSON_SOURCE, GND_PERSON_MAP)
+viaf = APIMapper(VIAF_PERSON_SOURCE, VIAF_PERSON_MAP)
+apis = [gnd, viaf]
+results = []
+for api in apis:
+ res = api.fetch_results('Pratchett')
+ results.extend(res)
+
+print(results)
+```
+
+* Using mapping rules
+
+Splitting the GND label field into meaningful subparts
+```
+from apimapper import APIMapper
+from apimapper import config
+
+GND_PERSON_SOURCE = {config.URL: 'https://lobid.org/gnd/search',
+ config.QUERY_FIELD: 'q',
+ config.PAYLOAD: {'format':'json:suggest',
+ 'filter': 'type:Person'}}
+
+GND_PERSON_MAP = {config.DIRECT: {'label': 'label',
+ 'uri': 'id'},
+ config.RULES: {'source': {config.RULE: '"GND"'},
+ 'label_name': {config.RULE: '"{p1}".split("|")[0].strip()',
+ config.FIELDS: {'p1': 'label'}},
+ 'label_year': {config.RULE: '"{p1}".split("|")[1].strip() if "{p1}".split("|")[1].strip()[0].isnumeric() else ""',
+ config.FIELDS: {'p1': 'label'}},
+ 'label_profession': {config.RULE: '"{p1}".split("|")[2].strip() if "{p1}".split("|")[1].strip()[0].isnumeric() else "{p1}".split("|")[1].strip()',
+ config.FIELDS: {'p1': 'label'}}}}
+
+api = APIMapper(GND_PERSON_SOURCE, GND_PERSON_MAP)
+res = api.fetch_results('Rosalind Franklin')
+```
+
+* More example usage in apimapper/demo
+
+
+%package help
+Summary: Development documents and examples for apimapper
+Provides: python3-apimapper-doc
+%description help
+# API Wrapper
+
+## Install package
+* from PyPi:
+ pip install apimapper
+* from source:
+ pip install -e .
+
+## Unit Testing
+ >pytest
+
+## Usage
+
+* See https://github.com/acdh-oeaw/apimapper/blob/develop/demo/APIMapper%20Demo.ipynb
+* Multiple APIs (GND and VIAF) mapped to a common JSON schema
+
+VIAF only returns VIAF ID - which is contructed into a url using a "rule"
+```
+from apimapper import APIMapper
+from apimapper import config
+
+GND_PERSON_MAP = {config.DIRECT: {'uri': 'id',
+ 'label': 'label'}}
+
+VIAF_PERSON_MAP = {config.RESULT: 'result',
+ config.FILTER: {'nametype': 'personal'},
+ config.DIRECT: {'label': 'displayForm'},
+ config.RULES: {'uri': {config.RULE: '"http://www.viaf.org/viaf/{p1}"',
+ config.FIELDS: {'p1': 'viafid'}}}}
+
+GND_PERSON_SOURCE = {config.URL: 'https://lobid.org/gnd/search',
+ config.QUERY_FIELD: 'q',
+ config.PAYLOAD: {'format':'json:suggest',
+ 'filter': 'type:Person'}}
+
+VIAF_PERSON_SOURCE = {config.URL: 'http://www.viaf.org/viaf/AutoSuggest',
+ config.QUERY_FIELD: 'query'}
+
+
+gnd = APIMapper(GND_PERSON_SOURCE, GND_PERSON_MAP)
+viaf = APIMapper(VIAF_PERSON_SOURCE, VIAF_PERSON_MAP)
+apis = [gnd, viaf]
+results = []
+for api in apis:
+ res = api.fetch_results('Pratchett')
+ results.extend(res)
+
+print(results)
+```
+
+* Using mapping rules
+
+Splitting the GND label field into meaningful subparts
+```
+from apimapper import APIMapper
+from apimapper import config
+
+GND_PERSON_SOURCE = {config.URL: 'https://lobid.org/gnd/search',
+ config.QUERY_FIELD: 'q',
+ config.PAYLOAD: {'format':'json:suggest',
+ 'filter': 'type:Person'}}
+
+GND_PERSON_MAP = {config.DIRECT: {'label': 'label',
+ 'uri': 'id'},
+ config.RULES: {'source': {config.RULE: '"GND"'},
+ 'label_name': {config.RULE: '"{p1}".split("|")[0].strip()',
+ config.FIELDS: {'p1': 'label'}},
+ 'label_year': {config.RULE: '"{p1}".split("|")[1].strip() if "{p1}".split("|")[1].strip()[0].isnumeric() else ""',
+ config.FIELDS: {'p1': 'label'}},
+ 'label_profession': {config.RULE: '"{p1}".split("|")[2].strip() if "{p1}".split("|")[1].strip()[0].isnumeric() else "{p1}".split("|")[1].strip()',
+ config.FIELDS: {'p1': 'label'}}}}
+
+api = APIMapper(GND_PERSON_SOURCE, GND_PERSON_MAP)
+res = api.fetch_results('Rosalind Franklin')
+```
+
+* More example usage in apimapper/demo
+
+
+%prep
+%autosetup -n apimapper-0.7.9
+
+%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-apimapper -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 0.7.9-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..960d2b7
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+f4d84b613b8f8ae64626a67ee59e1255 apimapper-0.7.9.tar.gz