File: README.rst

package info (click to toggle)
python-boolean.py 5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 308 kB
  • sloc: python: 2,081; makefile: 13; sh: 4
file content (114 lines) | stat: -rw-r--r-- 2,839 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
boolean.py
==========

"boolean.py" is a small library implementing a boolean algebra. It
defines two base elements, TRUE and FALSE, and a Symbol class that can
take on one of these two values. Calculations are done in terms of AND,
OR and NOT - other compositions like XOR and NAND are not implemented
but can be emulated with AND or and NOT. Expressions are constructed
from parsed strings or in Python.

It runs on Python 3.6+
You can use older version 3.x for Python 2.7+ support.

https://github.com/bastikr/boolean.py

Build status: |Build Status|


Example
-------

::

    >>> import boolean
    >>> algebra = boolean.BooleanAlgebra()
    >>> expression1 = algebra.parse(u'apple and (oranges or banana) and not banana', simplify=False)
    >>> expression1
    AND(Symbol('apple'), OR(Symbol('oranges'), Symbol('banana')), NOT(Symbol('banana')))

    >>> expression2 = algebra.parse('(oranges | banana) and not banana & apple', simplify=True)
    >>> expression2
    AND(Symbol('apple'), NOT(Symbol('banana')), Symbol('oranges'))

    >>> expression1 == expression2
    False
    >>> expression1.simplify() == expression2
    True


Documentation
-------------

http://readthedocs.org/docs/booleanpy/en/latest/


Installation
------------

Installation via pip
~~~~~~~~~~~~~~~~~~~~

To install boolean.py, you need to have the following pieces of software
on your computer:

-  Python 3.6+
-  pip

You then only need to run the following command:

``pip install boolean.py``


Installation via package managers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are packages available for easy install on some operating systems.
You are welcome to help us package this tool for more distributions!

-  boolean.py has been packaged as Arch Linux, Fedora, openSus,
   nixpkgs, Guix, DragonFly and FreeBSD 
   `packages <https://repology.org/project/python:boolean.py/versions>`__ .

In particular:

-  Arch Linux (AUR):
   `python-boolean.py <https://aur.archlinux.org/packages/python-boolean.py/>`__
-  Fedora:
   `python-boolean.py <https://apps.fedoraproject.org/packages/python-boolean.py>`__
-  openSUSE:
   `python-boolean.py <https://software.opensuse.org/package/python-boolean.py>`__


Testing
-------

Test ``boolean.py`` with your current Python environment:

``python setup.py test``

Test with all of the supported Python environments using ``tox``:

::

    pip install -r requirements-dev.txt
    tox

If ``tox`` throws ``InterpreterNotFound``, limit it to python
interpreters that are actually installed on your machine:

::

    tox -e py36

Alternatively use pytest.


License
-------

Copyright (c) Sebastian Kraemer, basti.kr@gmail.com and others
SPDX-License-Identifier: BSD-2-Clause

.. |Build Status| image:: https://travis-ci.org/bastikr/boolean.py.svg?branch=master
   :target: https://travis-ci.org/bastikr/boolean.py