diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-04-10 07:32:46 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-04-10 07:32:46 +0000 |
| commit | 1a91ea01c0a98016b08c823de6ca9842289f26ae (patch) | |
| tree | c2905d1b3225b7b0d44d71447f846bfa4e8c34f5 | |
| parent | 6cb8e142050d494ffe6df7e0eb436084d7e650dc (diff) | |
automatic import of python-uritemplate
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-uritemplate.spec | 150 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 152 insertions, 0 deletions
@@ -0,0 +1 @@ +/uritemplate-4.1.1.tar.gz diff --git a/python-uritemplate.spec b/python-uritemplate.spec new file mode 100644 index 0000000..41a4197 --- /dev/null +++ b/python-uritemplate.spec @@ -0,0 +1,150 @@ +%global _empty_manifest_terminate_build 0 +Name: python-uritemplate +Version: 4.1.1 +Release: 1 +Summary: Implementation of RFC 6570 URI Templates +License: BSD 3-Clause License or Apache License, Version 2.0 +URL: https://uritemplate.readthedocs.org +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/d2/5a/4742fdba39cd02a56226815abfa72fe0aa81c33bed16ed045647d6000eba/uritemplate-4.1.1.tar.gz +BuildArch: noarch + + +%description +Documentation_ -- GitHub_ -- Travis-CI_ +Simple python library to deal with `URI Templates`_. The API looks like + from uritemplate import URITemplate, expand + # NOTE: URI params must be strings not integers + gist_uri = 'https://api.github.com/users/sigmavirus24/gists{/gist_id}' + t = URITemplate(gist_uri) + print(t.expand(gist_id='123456')) + # => https://api.github.com/users/sigmavirus24/gists/123456 + # or + print(expand(gist_uri, gist_id='123456')) + # also + t.expand({'gist_id': '123456'}) + print(expand(gist_uri, {'gist_id': '123456'})) +Where it might be useful to have a class + import requests + class GitHubUser(object): + url = URITemplate('https://api.github.com/user{/login}') + def __init__(self, name): + self.api_url = url.expand(login=name) + response = requests.get(self.api_url) + if response.status_code == 200: + self.__dict__.update(response.json()) +When the module containing this class is loaded, ``GitHubUser.url`` is +evaluated and so the template is created once. It's often hard to notice in +Python, but object creation can consume a great deal of time and so can the +``re`` module which uritemplate relies on. Constructing the object once should +reduce the amount of time your code takes to run. + +%package -n python3-uritemplate +Summary: Implementation of RFC 6570 URI Templates +Provides: python-uritemplate +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-uritemplate +Documentation_ -- GitHub_ -- Travis-CI_ +Simple python library to deal with `URI Templates`_. The API looks like + from uritemplate import URITemplate, expand + # NOTE: URI params must be strings not integers + gist_uri = 'https://api.github.com/users/sigmavirus24/gists{/gist_id}' + t = URITemplate(gist_uri) + print(t.expand(gist_id='123456')) + # => https://api.github.com/users/sigmavirus24/gists/123456 + # or + print(expand(gist_uri, gist_id='123456')) + # also + t.expand({'gist_id': '123456'}) + print(expand(gist_uri, {'gist_id': '123456'})) +Where it might be useful to have a class + import requests + class GitHubUser(object): + url = URITemplate('https://api.github.com/user{/login}') + def __init__(self, name): + self.api_url = url.expand(login=name) + response = requests.get(self.api_url) + if response.status_code == 200: + self.__dict__.update(response.json()) +When the module containing this class is loaded, ``GitHubUser.url`` is +evaluated and so the template is created once. It's often hard to notice in +Python, but object creation can consume a great deal of time and so can the +``re`` module which uritemplate relies on. Constructing the object once should +reduce the amount of time your code takes to run. + +%package help +Summary: Development documents and examples for uritemplate +Provides: python3-uritemplate-doc +%description help +Documentation_ -- GitHub_ -- Travis-CI_ +Simple python library to deal with `URI Templates`_. The API looks like + from uritemplate import URITemplate, expand + # NOTE: URI params must be strings not integers + gist_uri = 'https://api.github.com/users/sigmavirus24/gists{/gist_id}' + t = URITemplate(gist_uri) + print(t.expand(gist_id='123456')) + # => https://api.github.com/users/sigmavirus24/gists/123456 + # or + print(expand(gist_uri, gist_id='123456')) + # also + t.expand({'gist_id': '123456'}) + print(expand(gist_uri, {'gist_id': '123456'})) +Where it might be useful to have a class + import requests + class GitHubUser(object): + url = URITemplate('https://api.github.com/user{/login}') + def __init__(self, name): + self.api_url = url.expand(login=name) + response = requests.get(self.api_url) + if response.status_code == 200: + self.__dict__.update(response.json()) +When the module containing this class is loaded, ``GitHubUser.url`` is +evaluated and so the template is created once. It's often hard to notice in +Python, but object creation can consume a great deal of time and so can the +``re`` module which uritemplate relies on. Constructing the object once should +reduce the amount of time your code takes to run. + +%prep +%autosetup -n uritemplate-4.1.1 + +%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-uritemplate -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon Apr 10 2023 Python_Bot <Python_Bot@openeuler.org> - 4.1.1-1 +- Package Spec generated @@ -0,0 +1 @@ +6a40709eb966d0a57fea08c3f11ff325 uritemplate-4.1.1.tar.gz |
