diff options
| -rw-r--r-- | README.rst | 109 | ||||
| -rw-r--r-- | images/cover.png | bin | 0 -> 30720 bytes | |||
| -rw-r--r-- | images/logo_1500px.png | bin | 0 -> 107381 bytes | |||
| -rw-r--r-- | images/logo_500px.png | bin | 0 -> 27748 bytes | |||
| -rw-r--r-- | images/logo_no_text_1500px.png | bin | 0 -> 152434 bytes | |||
| -rw-r--r-- | images/logo_no_text_500px.png | bin | 0 -> 39699 bytes | |||
| -rw-r--r-- | images/logo_no_text_black_1500px.png | bin | 0 -> 152571 bytes | |||
| -rw-r--r-- | images/logo_no_text_black_500px.png | bin | 0 -> 39699 bytes | |||
| -rw-r--r-- | images/logo_no_text_t_1500px.png | bin | 0 -> 115382 bytes | |||
| -rw-r--r-- | images/logo_no_text_t_500px.png | bin | 0 -> 31255 bytes | |||
| -rw-r--r-- | images/logo_no_text_t_black_1500px.png | bin | 0 -> 104661 bytes | |||
| -rw-r--r-- | images/logo_no_text_t_black_500px.png | bin | 0 -> 28410 bytes | |||
| -rw-r--r-- | images/logo_t_1500px.png | bin | 0 -> 80839 bytes | |||
| -rw-r--r-- | images/logo_t_500px.png | bin | 0 -> 21161 bytes | |||
| -rw-r--r-- | images/logo_t_black_1500px.png | bin | 0 -> 73939 bytes | |||
| -rw-r--r-- | images/logo_t_black_500px.png | bin | 0 -> 19427 bytes | |||
| -rw-r--r-- | images/logo_wob_1500px.png | bin | 0 -> 105201 bytes | |||
| -rw-r--r-- | images/logo_wob_500px.png | bin | 0 -> 26378 bytes |
18 files changed, 76 insertions, 33 deletions
@@ -1,28 +1,22 @@ ======== -Overview +Edify ======== -.. start-badges +.. Cover Image +.. image:: images/cover.png + :alt: Cover Image -.. list-table:: - :stub-columns: 1 +| - * - docs - - |docs| - * - tests - - | |github-actions| |codecov| - * - package - - | |version| |wheel| |supported-versions| |supported-implementations| - | |commits-since| -.. |docs| image:: https://readthedocs.org/projects/edify/badge/?style=flat +.. image:: https://readthedocs.org/projects/edify/badge/?style=flat :target: https://edify.readthedocs.io/ :alt: Documentation Status -.. |github-actions| image:: https://github.com/luciferreeves/edify/actions/workflows/github-actions.yml/badge.svg +.. image:: https://github.com/luciferreeves/edify/actions/workflows/github-actions.yml/badge.svg?branch=main :alt: GitHub Actions Build Status :target: https://github.com/luciferreeves/edify/actions -.. |codecov| image:: https://codecov.io/gh/luciferreeves/edify/branch/main/graphs/badge.svg?branch=main +.. image:: https://codecov.io/gh/luciferreeves/edify/branch/main/graphs/badge.svg?branch=main :alt: Coverage Status :target: https://codecov.io/github/luciferreeves/edify @@ -50,9 +44,9 @@ Overview .. end-badges -Regular Expressions Made Simple +Edify (/ˈɛdɪfaɪ/, "ed-uh-fahy") is a Python library that allows you to easily create regular expressions for matching text in a programmatically-friendly way. It is designed to be used in conjunction with the ``re`` module. -* Free software: Apache Software License 2.0 +It also allows you to verify a string quickly by providing commonly used regex patterns in its extensive set of built-in patterns. To tap into a pattern, simply import the pattern function from the ``edify.library`` module. Installation ============ @@ -66,33 +60,82 @@ You can also install the in-development version with:: pip install https://github.com/luciferreeves/edify/archive/main.zip -Documentation +Why Edify? +=========== + +Regex is a powerful tool, but its syntax is not very intuitive and can be difficult to build, understand, and use. It gets even more difficult when you have to deal with backtracking, look-ahead, and other features that make regex difficult. + +That's where Edify becomes extremely useful. It allows you to create regular expressions in a programmatic way by invoking the ``RegexBuilder`` class, based on the SuperExpressive_ library. The API uses the `fluent builder pattern <https://en.wikipedia.org/wiki/Fluent_interface>`_, and is completely immutable. It is built to be discoverable and predictable. + +- Properties and methods describe what they do in plain English. +- Order matters! Quantifiers are specified before the thing they change, just like in English (e.g. ``RegexBuilder().exactly(5).digit()``.) +- If you make a mistake, you'll know how to fix it. Edify will guide you towards a fix if your expression is invalid. +- ``subexpressions`` can be used to create meaningful, reusable components. + +Edify turns those complex and unwieldy regexes that appear in code reviews into something that can be read, understood, and **properly reviewed** by your peers - and maintained by anyone! + + +.. _SuperExpressive: https://github.com/francisrstokes/super-expressive + +Quick Start ============= +To get started make sure you have python 3.7 or later installed and then, install Edify from ``pip``:: -https://edify.readthedocs.io/ + pip install edify +Then go on to import the ``RegexBuilder`` class from the ``edify`` module. -Development -=========== +Using Pre-Built Patterns +------------------------ + +The following example recognises and captures any email like ``[email protected]``. -To run all the tests run:: +.. code-block:: python - tox -Note, to combine the coverage data from all the tox environments run: + from edify.library import email -.. list-table:: - :widths: 10 90 - :stub-columns: 1 + email_addr = "[email protected]" + assert email(email_addr) == True - - - Windows - - :: - set PYTEST_ADDOPTS=--cov-append - tox +Building Regex Example +---------------------- + +The following example recognises and captures the value of a 16-bit hexadecimal number like ``0xC0D3``. + +.. code-block:: python + + + import re + from edify import RegexBuilder + + expr = ( + RegexBuilder() + .start_of_input() + .optional().string("0x") + .capture() + .exactly(4).any_of() + .range("A", "F") + .range("a", "f") + .range("0", "9") + .end() + .end() + .end_of_input() + .to_regex() + ) + + """ + Produces the following regular expression: + re.compile(^(?:0x)?([A-Fa-f0-9]{4})$) + """ + + assert expr.match("0xC0D3") + + +Documentation +============= - - - Other - - :: +Further API documentation is available on `edify.rftd.io <https://edify.readthedocs.io>`_. - PYTEST_ADDOPTS=--cov-append tox diff --git a/images/cover.png b/images/cover.png Binary files differnew file mode 100644 index 0000000..24c06d9 --- /dev/null +++ b/images/cover.png diff --git a/images/logo_1500px.png b/images/logo_1500px.png Binary files differnew file mode 100644 index 0000000..9c7c75b --- /dev/null +++ b/images/logo_1500px.png diff --git a/images/logo_500px.png b/images/logo_500px.png Binary files differnew file mode 100644 index 0000000..6f77726 --- /dev/null +++ b/images/logo_500px.png diff --git a/images/logo_no_text_1500px.png b/images/logo_no_text_1500px.png Binary files differnew file mode 100644 index 0000000..22804b5 --- /dev/null +++ b/images/logo_no_text_1500px.png diff --git a/images/logo_no_text_500px.png b/images/logo_no_text_500px.png Binary files differnew file mode 100644 index 0000000..bbcfc41 --- /dev/null +++ b/images/logo_no_text_500px.png diff --git a/images/logo_no_text_black_1500px.png b/images/logo_no_text_black_1500px.png Binary files differnew file mode 100644 index 0000000..18ab859 --- /dev/null +++ b/images/logo_no_text_black_1500px.png diff --git a/images/logo_no_text_black_500px.png b/images/logo_no_text_black_500px.png Binary files differnew file mode 100644 index 0000000..9bf361c --- /dev/null +++ b/images/logo_no_text_black_500px.png diff --git a/images/logo_no_text_t_1500px.png b/images/logo_no_text_t_1500px.png Binary files differnew file mode 100644 index 0000000..0f476a9 --- /dev/null +++ b/images/logo_no_text_t_1500px.png diff --git a/images/logo_no_text_t_500px.png b/images/logo_no_text_t_500px.png Binary files differnew file mode 100644 index 0000000..5c507e7 --- /dev/null +++ b/images/logo_no_text_t_500px.png diff --git a/images/logo_no_text_t_black_1500px.png b/images/logo_no_text_t_black_1500px.png Binary files differnew file mode 100644 index 0000000..3371816 --- /dev/null +++ b/images/logo_no_text_t_black_1500px.png diff --git a/images/logo_no_text_t_black_500px.png b/images/logo_no_text_t_black_500px.png Binary files differnew file mode 100644 index 0000000..194cd13 --- /dev/null +++ b/images/logo_no_text_t_black_500px.png diff --git a/images/logo_t_1500px.png b/images/logo_t_1500px.png Binary files differnew file mode 100644 index 0000000..7e7ebe1 --- /dev/null +++ b/images/logo_t_1500px.png diff --git a/images/logo_t_500px.png b/images/logo_t_500px.png Binary files differnew file mode 100644 index 0000000..7a10cb0 --- /dev/null +++ b/images/logo_t_500px.png diff --git a/images/logo_t_black_1500px.png b/images/logo_t_black_1500px.png Binary files differnew file mode 100644 index 0000000..abf3dd2 --- /dev/null +++ b/images/logo_t_black_1500px.png diff --git a/images/logo_t_black_500px.png b/images/logo_t_black_500px.png Binary files differnew file mode 100644 index 0000000..649b3de --- /dev/null +++ b/images/logo_t_black_500px.png diff --git a/images/logo_wob_1500px.png b/images/logo_wob_1500px.png Binary files differnew file mode 100644 index 0000000..acf4848 --- /dev/null +++ b/images/logo_wob_1500px.png diff --git a/images/logo_wob_500px.png b/images/logo_wob_500px.png Binary files differnew file mode 100644 index 0000000..76c83c2 --- /dev/null +++ b/images/logo_wob_500px.png |
