-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Split pregex package into "pregex.core" and "pregex.meta". All previous modules were moved to "pregex.core", while a new module "essentials.py" was added to "pregex.meta". - Greatly improved documentation page. - Added classes "pregex.core.assertions.[Not]EnclosedBy". - Added "Pregex.print_pattern()" method just for printing the pattern. - Added "Pregex.purge()" static method for clearing the regex cache. - Added "__quantifiable" field and "_is_quantifiable" method. - All match-like methods are now able to receive a path to a text file to extract text from in order to look for matches, via the "is_path" parameter. - "Pregex.__infer_type" now also infers whether pattern is quantifiable or not, and returns said result along with the pattern's type.
- Loading branch information
Showing
40 changed files
with
2,527 additions
and
620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pregex==1.5.4 | ||
pregex==2.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
####################### | ||
Importing Practices | ||
####################### | ||
|
||
Due to the relatively large number of modules contained within pregex, | ||
having to import each class individually can quickly become extremely annoying. | ||
For this reason, it is suggested that one handles their imports by | ||
including the following statements at the top of their Python script: | ||
|
||
* ``from pregex.core import *`` - Imports all core modules by using short aliases. | ||
More specifically: | ||
|
||
* Module :py:mod:`pregex.core.assertions` is imported as ``asr`` | ||
* Module :py:mod:`pregex.core.classes` is imported as ``cl`` | ||
* Module :py:mod:`pregex.core.groups` is imported as ``gr`` | ||
* Module :py:mod:`pregex.core.operators` is imported as ``op`` | ||
* Module :py:mod:`pregex.core.quantifiers` is imported as ``qu`` | ||
* Module :py:mod:`pregex.core.tokens` is imported as ``tk`` | ||
* Classes :class:`pregex.core.pre.Pregex` and :class:`pregex.core.pre.Empty` are imported as is. | ||
|
||
Take a look at the example below to better understand how this works: | ||
|
||
.. code-block:: python | ||
from pregex.core import * | ||
|
||
pre = op.Either("Hello", "Bye") + " World" + qu.Optional("!") | ||
|
||
print(pre.get_pattern()) # This prints "(?:Hello|Bye) World!?" | ||
|
||
It is recommended that you follow this practice as besides the fact that | ||
it saves you the trouble of having to import from each module separately, | ||
it also ensures that you are aware of the module that each class belongs in, | ||
which in turn reveals a lot in regards to the class's functionality and how | ||
it can be used. | ||
|
||
* ``from pregex.meta import *`` - Directly imports every class defined within any | ||
one of the *meta* modules. | ||
|
||
|
||
Finally, one is also able to replace both of the above import statements | ||
with a single statement, namely ``from pregex import *``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
*********************** | ||
pregex.core.assertions | ||
*********************** | ||
.. automodule:: pregex.core.assertions | ||
:members: | ||
:undoc-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
********************* | ||
pregex.core.classes | ||
********************* | ||
.. automodule:: pregex.core.classes | ||
:members: | ||
:undoc-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
********************* | ||
pregex.core.groups | ||
********************* | ||
.. automodule:: pregex.core.groups | ||
:members: | ||
:undoc-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
********************* | ||
pregex.core.operators | ||
********************* | ||
.. automodule:: pregex.core.operators | ||
:members: | ||
:undoc-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
********************* | ||
pregex.core.pre | ||
********************* | ||
.. automodule:: pregex.core.pre | ||
:members: | ||
:undoc-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
************************* | ||
pregex.core.quantifiers | ||
************************* | ||
.. automodule:: pregex.core.quantifiers | ||
:members: | ||
:undoc-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
********************* | ||
pregex.core.tokens | ||
********************* | ||
.. automodule:: pregex.core.tokens | ||
:members: | ||
:undoc-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
*********************** | ||
pregex.meta.essentials | ||
*********************** | ||
.. automodule:: pregex.meta.essentials | ||
:members: | ||
:undoc-members: |
Oops, something went wrong.