diff options
author | CoprDistGit <infra@openeuler.org> | 2023-06-20 03:28:10 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-06-20 03:28:10 +0000 |
commit | 972a5d88043db43b94d7a0940c58ff4b950319ab (patch) | |
tree | 2d5d1fffdcf56b732c568899eaca6ed9dd47ad48 | |
parent | 9b60dbc535a260f01d96095e487ca8c2d1587d66 (diff) |
automatic import of python-consopeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-cons.spec | 375 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 377 insertions, 0 deletions
@@ -0,0 +1 @@ +/cons-0.4.5.tar.gz diff --git a/python-cons.spec b/python-cons.spec new file mode 100644 index 0000000..c21b7c1 --- /dev/null +++ b/python-cons.spec @@ -0,0 +1,375 @@ +%global _empty_manifest_terminate_build 0 +Name: python-cons +Version: 0.4.5 +Release: 1 +Summary: An implementation of Lisp/Scheme-like cons in Python. +License: LGPL-3 +URL: https://github.com/pythological/python-cons +Source0: https://mirrors.aliyun.com/pypi/web/packages/1e/b1/263faca4ab3dab8859f0d725f2b64e3a0182dbf9a8ae156209d7a2b4b9de/cons-0.4.5.tar.gz +BuildArch: noarch + + +%description +[](https://travis-ci.org/pythological/python-cons) [](https://coveralls.io/github/pythological/python-cons?branch=master) [](https://pypi.org/project/cons/) + +# Python `cons` + +An implementation of [`cons`][cons] in Python. + +## Usage and Design + +The `cons` package attempts to emulate the semantics of Lisp/Scheme's `cons` as closely as possible while incorporating all the built-in Python sequence types: +```python +>>> from cons import cons, car, cdr +>>> cons(1, []) +[1] + +>>> cons(1, ()) +(1,) + +>>> cons(1, [2, 3]) +[1, 2, 3] +``` + +In general, `cons` is designed to work with `collections.abc.Sequence` types. + +According to the `cons` package, `None` corresponds to the empty built-in `list`, as `nil` does in some Lisps: +```python +>>> cons(1, None) +[1] +``` + +The `cons` package follows Scheme-like semantics for empty sequences: +```python +>>> car([]) +Traceback (most recent call last): + File "<stdin>", line 1, in <module> +ConsError: Not a cons pair + +>>> cdr([]) +Traceback (most recent call last): + File "<stdin>", line 1, in <module> +ConsError: Not a cons pair + +``` + +By default, `str` types are not considered cons-pairs, although they are sequences: +```python +>>> cons("a", "string") +ConsPair('a' 'a string') +``` + +This setting can be overridden and other types can be similarly excluded from consideration by registering classes with the `abc`-based classes `MaybeCons` and `NonCons`. + + +## Features + +* Built-in support for the standard Python ordered sequence types: i.e. `list`, `tuple`, `Iterator`, `OrderedDict`. +```python +>>> from collections import OrderedDict +>>> cons(('a', 1), OrderedDict()) +OrderedDict([('a', 1)]) + +``` +* Existing `cons` behavior can be changed and support for new collections can be added through the generic functions `cons.core._car` and `cons.core._cdr`. +* Built-in support for [`unification`][un]. +```python +>>> from unification import unify, reify, var +>>> unify([1, 2], cons(var('car'), var('cdr')), {}) +{~car: 1, ~cdr: [2]} + +>>> reify(cons(1, var('cdr')), {var('cdr'): [2, 3]}) +[1, 2, 3] + +>>> reify(cons(1, var('cdr')), {var('cdr'): None}) +[1] + +``` + +## Installation + +```python +pip install cons +``` + +### Development + +First obtain the project source: +```bash +git clone git@github.com:pythological/python-cons.git +``` + +Create a virtual environment and install the development dependencies: +```bash +$ pip install -r requirements.txt +``` + +Set up `pre-commit` hooks: + +```bash +$ pre-commit install --install-hooks +``` + +[cons]: https://en.wikipedia.org/wiki/Cons +[un]: https://github.com/pythological/unification + +%package -n python3-cons +Summary: An implementation of Lisp/Scheme-like cons in Python. +Provides: python-cons +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-cons +[](https://travis-ci.org/pythological/python-cons) [](https://coveralls.io/github/pythological/python-cons?branch=master) [](https://pypi.org/project/cons/) + +# Python `cons` + +An implementation of [`cons`][cons] in Python. + +## Usage and Design + +The `cons` package attempts to emulate the semantics of Lisp/Scheme's `cons` as closely as possible while incorporating all the built-in Python sequence types: +```python +>>> from cons import cons, car, cdr +>>> cons(1, []) +[1] + +>>> cons(1, ()) +(1,) + +>>> cons(1, [2, 3]) +[1, 2, 3] +``` + +In general, `cons` is designed to work with `collections.abc.Sequence` types. + +According to the `cons` package, `None` corresponds to the empty built-in `list`, as `nil` does in some Lisps: +```python +>>> cons(1, None) +[1] +``` + +The `cons` package follows Scheme-like semantics for empty sequences: +```python +>>> car([]) +Traceback (most recent call last): + File "<stdin>", line 1, in <module> +ConsError: Not a cons pair + +>>> cdr([]) +Traceback (most recent call last): + File "<stdin>", line 1, in <module> +ConsError: Not a cons pair + +``` + +By default, `str` types are not considered cons-pairs, although they are sequences: +```python +>>> cons("a", "string") +ConsPair('a' 'a string') +``` + +This setting can be overridden and other types can be similarly excluded from consideration by registering classes with the `abc`-based classes `MaybeCons` and `NonCons`. + + +## Features + +* Built-in support for the standard Python ordered sequence types: i.e. `list`, `tuple`, `Iterator`, `OrderedDict`. +```python +>>> from collections import OrderedDict +>>> cons(('a', 1), OrderedDict()) +OrderedDict([('a', 1)]) + +``` +* Existing `cons` behavior can be changed and support for new collections can be added through the generic functions `cons.core._car` and `cons.core._cdr`. +* Built-in support for [`unification`][un]. +```python +>>> from unification import unify, reify, var +>>> unify([1, 2], cons(var('car'), var('cdr')), {}) +{~car: 1, ~cdr: [2]} + +>>> reify(cons(1, var('cdr')), {var('cdr'): [2, 3]}) +[1, 2, 3] + +>>> reify(cons(1, var('cdr')), {var('cdr'): None}) +[1] + +``` + +## Installation + +```python +pip install cons +``` + +### Development + +First obtain the project source: +```bash +git clone git@github.com:pythological/python-cons.git +``` + +Create a virtual environment and install the development dependencies: +```bash +$ pip install -r requirements.txt +``` + +Set up `pre-commit` hooks: + +```bash +$ pre-commit install --install-hooks +``` + +[cons]: https://en.wikipedia.org/wiki/Cons +[un]: https://github.com/pythological/unification + +%package help +Summary: Development documents and examples for cons +Provides: python3-cons-doc +%description help +[](https://travis-ci.org/pythological/python-cons) [](https://coveralls.io/github/pythological/python-cons?branch=master) [](https://pypi.org/project/cons/) + +# Python `cons` + +An implementation of [`cons`][cons] in Python. + +## Usage and Design + +The `cons` package attempts to emulate the semantics of Lisp/Scheme's `cons` as closely as possible while incorporating all the built-in Python sequence types: +```python +>>> from cons import cons, car, cdr +>>> cons(1, []) +[1] + +>>> cons(1, ()) +(1,) + +>>> cons(1, [2, 3]) +[1, 2, 3] +``` + +In general, `cons` is designed to work with `collections.abc.Sequence` types. + +According to the `cons` package, `None` corresponds to the empty built-in `list`, as `nil` does in some Lisps: +```python +>>> cons(1, None) +[1] +``` + +The `cons` package follows Scheme-like semantics for empty sequences: +```python +>>> car([]) +Traceback (most recent call last): + File "<stdin>", line 1, in <module> +ConsError: Not a cons pair + +>>> cdr([]) +Traceback (most recent call last): + File "<stdin>", line 1, in <module> +ConsError: Not a cons pair + +``` + +By default, `str` types are not considered cons-pairs, although they are sequences: +```python +>>> cons("a", "string") +ConsPair('a' 'a string') +``` + +This setting can be overridden and other types can be similarly excluded from consideration by registering classes with the `abc`-based classes `MaybeCons` and `NonCons`. + + +## Features + +* Built-in support for the standard Python ordered sequence types: i.e. `list`, `tuple`, `Iterator`, `OrderedDict`. +```python +>>> from collections import OrderedDict +>>> cons(('a', 1), OrderedDict()) +OrderedDict([('a', 1)]) + +``` +* Existing `cons` behavior can be changed and support for new collections can be added through the generic functions `cons.core._car` and `cons.core._cdr`. +* Built-in support for [`unification`][un]. +```python +>>> from unification import unify, reify, var +>>> unify([1, 2], cons(var('car'), var('cdr')), {}) +{~car: 1, ~cdr: [2]} + +>>> reify(cons(1, var('cdr')), {var('cdr'): [2, 3]}) +[1, 2, 3] + +>>> reify(cons(1, var('cdr')), {var('cdr'): None}) +[1] + +``` + +## Installation + +```python +pip install cons +``` + +### Development + +First obtain the project source: +```bash +git clone git@github.com:pythological/python-cons.git +``` + +Create a virtual environment and install the development dependencies: +```bash +$ pip install -r requirements.txt +``` + +Set up `pre-commit` hooks: + +```bash +$ pre-commit install --install-hooks +``` + +[cons]: https://en.wikipedia.org/wiki/Cons +[un]: https://github.com/pythological/unification + +%prep +%autosetup -n cons-0.4.5 + +%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-cons -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 0.4.5-1 +- Package Spec generated @@ -0,0 +1 @@ +bd8f1e78e2a069e50ff8f1632bcd06bd cons-0.4.5.tar.gz |