diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-xpath-expressions.spec | 234 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 236 insertions, 0 deletions
@@ -0,0 +1 @@ +/xpath-expressions-1.0.2.tar.gz diff --git a/python-xpath-expressions.spec b/python-xpath-expressions.spec new file mode 100644 index 0000000..e49cf43 --- /dev/null +++ b/python-xpath-expressions.spec @@ -0,0 +1,234 @@ +%global _empty_manifest_terminate_build 0 +Name: python-xpath-expressions +Version: 1.0.2 +Release: 1 +Summary: Treat XPath expressions as Python objects +License: MIT +URL: https://github.com/orf/xpath-expressions +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/2d/c8/46e6efccaef9ed5b76077ec6ee0e97163b11a4b87d8c2a85b23294dc76a3/xpath-expressions-1.0.2.tar.gz +BuildArch: noarch + + +%description +# XPath-expressions + + + + + +This is a small, lightweight Python 3.5+ library to aide in the manipulations of +xpath expressions. It allows you to manipulate them as Python objects with +Python expressions and operators. + +### Install + +`pip install xpath-expressions` + + +### Quickstart + +```python +from xpath import Expression, Attribute + +root_node = Expression('/root') +print(root_node.children) # /root/* +print(root_node.name) # name(/root) +print(root_node.attributes[1]) # /root/@*[1] +print(root_node / 'abc' / 'def') # /root/abc/def + +# Filtering expressions: +print(root_node.text == 'abc') # /root/text()='abc' + +expr = Attribute('abc') == 'def' +print(expr) # @abc='def' +print(root_node.children[expr]) # /root/*[@abc='def'] + +# The library handles quoting for you: +expr = Attribute('abc') == "def'" +filtered2 = root_node.children[expr] # /root/*[@abc="def'"] + +# You can use xpath functions: +from xpath import func +# Pass arguments like usual +expr = func.string_length(root_node.name) +print(expr) # string-length(name(/root/)) + +# And treat those as normal expressions +print(expr == 5) # string-length(name(/root/)) == 5 + +# The library normalizes python reserved names: +print(func.or_()) # or() + +# Use custom namespaces +from xpath import Functions +ns_functions = Functions('my-ns:') +print(ns_functions.something()) # my-ns:something() +``` + + +%package -n python3-xpath-expressions +Summary: Treat XPath expressions as Python objects +Provides: python-xpath-expressions +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-xpath-expressions +# XPath-expressions + + + + + +This is a small, lightweight Python 3.5+ library to aide in the manipulations of +xpath expressions. It allows you to manipulate them as Python objects with +Python expressions and operators. + +### Install + +`pip install xpath-expressions` + + +### Quickstart + +```python +from xpath import Expression, Attribute + +root_node = Expression('/root') +print(root_node.children) # /root/* +print(root_node.name) # name(/root) +print(root_node.attributes[1]) # /root/@*[1] +print(root_node / 'abc' / 'def') # /root/abc/def + +# Filtering expressions: +print(root_node.text == 'abc') # /root/text()='abc' + +expr = Attribute('abc') == 'def' +print(expr) # @abc='def' +print(root_node.children[expr]) # /root/*[@abc='def'] + +# The library handles quoting for you: +expr = Attribute('abc') == "def'" +filtered2 = root_node.children[expr] # /root/*[@abc="def'"] + +# You can use xpath functions: +from xpath import func +# Pass arguments like usual +expr = func.string_length(root_node.name) +print(expr) # string-length(name(/root/)) + +# And treat those as normal expressions +print(expr == 5) # string-length(name(/root/)) == 5 + +# The library normalizes python reserved names: +print(func.or_()) # or() + +# Use custom namespaces +from xpath import Functions +ns_functions = Functions('my-ns:') +print(ns_functions.something()) # my-ns:something() +``` + + +%package help +Summary: Development documents and examples for xpath-expressions +Provides: python3-xpath-expressions-doc +%description help +# XPath-expressions + + + + + +This is a small, lightweight Python 3.5+ library to aide in the manipulations of +xpath expressions. It allows you to manipulate them as Python objects with +Python expressions and operators. + +### Install + +`pip install xpath-expressions` + + +### Quickstart + +```python +from xpath import Expression, Attribute + +root_node = Expression('/root') +print(root_node.children) # /root/* +print(root_node.name) # name(/root) +print(root_node.attributes[1]) # /root/@*[1] +print(root_node / 'abc' / 'def') # /root/abc/def + +# Filtering expressions: +print(root_node.text == 'abc') # /root/text()='abc' + +expr = Attribute('abc') == 'def' +print(expr) # @abc='def' +print(root_node.children[expr]) # /root/*[@abc='def'] + +# The library handles quoting for you: +expr = Attribute('abc') == "def'" +filtered2 = root_node.children[expr] # /root/*[@abc="def'"] + +# You can use xpath functions: +from xpath import func +# Pass arguments like usual +expr = func.string_length(root_node.name) +print(expr) # string-length(name(/root/)) + +# And treat those as normal expressions +print(expr == 5) # string-length(name(/root/)) == 5 + +# The library normalizes python reserved names: +print(func.or_()) # or() + +# Use custom namespaces +from xpath import Functions +ns_functions = Functions('my-ns:') +print(ns_functions.something()) # my-ns:something() +``` + + +%prep +%autosetup -n xpath-expressions-1.0.2 + +%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-xpath-expressions -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu Mar 09 2023 Python_Bot <Python_Bot@openeuler.org> - 1.0.2-1 +- Package Spec generated @@ -0,0 +1 @@ +da8ee1570e47b233e1f3fadfe746d55b xpath-expressions-1.0.2.tar.gz |