Metadata-Version: 2.1
Name: colorpattern
Version: 1.3
Summary: Effortless console text colorization based on user-defined patterns in Python.
Home-page: https://github.com/croketillo/colorpattern
Author: croketillo
Author-email: croketillo@gmail.com
License: UNKNOWN
Keywords: color pattern console
Platform: UNKNOWN
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Terminals
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
License-File: LICENSE
Requires-Dist: colorama

ColorPattern
============

ColorPattern is a Python module designed for enhancing text output in
the console by applying color to specific patterns. It offers a flexible
way to define patterns and apply different text colors, background
colors, styles, and underlines to matching text in the output.

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

You can install ColorPattern using pip:

``pip install colorpattern``

Usage
-----

Use start_color() for initialize the color print, and end_color() for
stop colorization.

.. code:: python

   from colorpattern.colorpattern import *

   def main():
       # Define your color patterns
       pattern1 = SetPattern(r'\d+', color=Fore.GREEN)
       pattern2 = SetPattern(r'Colorpattern', color=Fore.LIGHTRED_EX, underline=True)
       pattern3 = SetPattern(r'Croketillo', color=Fore.RED, back=Back.LIGHTYELLOW_EX, style=Style.BRIGHT)
       email = SetPattern(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b', color=Fore.LIGHTCYAN_EX)

       # Initialize colorization and get the original print function and applied patterns
       print("\nSTART COLORIZED PRINT")
       print('-----------------------')
       start_color([pattern1, pattern2, pattern3, email])

       # Use the custom print function with colorization
       print('Colorpattern v1.3')
       print('By Croketillo - croketillo@gmail.com')

       # End colorization and restore the original print function
       end_color()
       print("\nNORMAL PRINT")
       # Now, printing returns to normal

       print('-----------------------')
       print('Colorpattern v1.3')
       print('By Croketillo - croketillo@gmail.com')

       # You can re-enable colorization with new patterns if necessary
       new_pattern = SetPattern(r'new pattern', color=Fore.LIGHTCYAN_EX)

       # Use the custom print function with new patterns
       print("\nSTART COLORIZED PRINT AGAIN")
       start_color([pattern1, new_pattern])

       print('-----------------------')
       print('This is a new pattern. 123456')

       # End colorization and restore the original print function
       end_color()
       print("\nNORMAL PRINT AGAIN")
       # Now, printing returns to normal even with the new patterns
       print('-----------------------')
       print('This is a normal message again.')

   if __name__ == "__main__":
       main()

Patterns
--------

-  ``pattern``: Regular expression pattern to match in the text.
-  ``color``: Text color (e.g., ‘green’, ‘red’, ‘yellow’).
-  ``back``: Background color (e.g., ‘black’, ‘blue’, ‘white’).
-  ``style``: Text style (e.g., ‘bright’, ‘dim’, ‘reset_all’).
-  ``underline``: Set to ``True`` for underlining matched text.

Colors (colorama):
------------------

Text Colors (Fore):
~~~~~~~~~~~~~~~~~~~

-  Fore.BLACK
-  Fore.RED
-  Fore.GREEN
-  Fore.YELLOW
-  Fore.BLUE
-  Fore.MAGENTA
-  Fore.CYAN
-  Fore.WHITE
-  Fore.LIGHTBLACK_EX
-  Fore.LIGHTRED_EX
-  Fore.LIGHTGREEN_EX
-  Fore.LIGHTYELLOW_EX
-  Fore.LIGHTBLUE_EX
-  Fore.LIGHTMAGENTA_EX
-  Fore.LIGHTCYAN_EX
-  Fore.LIGHTWHITE_EX
-  Fore.RESET

Background Colors (Back):
~~~~~~~~~~~~~~~~~~~~~~~~~

-  Back.BLACK
-  Back.RED
-  Back.GREEN
-  Back.YELLOW
-  Back.BLUE
-  Back.MAGENTA
-  Back.CYAN
-  Back.WHITE
-  Back.LIGHTBLACK_EX
-  Back.LIGHTRED_EX
-  Back.LIGHTGREEN_EX
-  Back.LIGHTYELLOW_EX
-  Back.LIGHTBLUE_EX
-  Back.LIGHTMAGENTA_EX
-  Back.LIGHTCYAN_EX
-  Back.LIGHTWHITE_EX
-  Back.RESET

Text Styles (Style):
~~~~~~~~~~~~~~~~~~~~

-  Style.RESET_ALL
-  Style.BRIGHT
-  Style.DIM
-  Style.NORMAL

License
-------

This project is licensed under the GNU-GLP,3 License - see the LICENSE
file for details.


