A Python library to give beuty to your python scripts printing structure
Report Bug
·
Request Feature
Table of Contents
Sometimes we all in hurry and just need simple printing tool just to preview our scripts scraping or processing output in more neat way than just plain text, each time need waste time writing something simple to print neatly, so I wrote this lib almost in all my projects since its meets my needs, I hope it will meet other people needs so I am sharing it with everyone
Project is uploaded to PYPI, so you can install it pretty easily using pip tool.
- Install package using pip command
pip install beuty-print
To use this library just import classes and create printer object
from beutyprint import *
printer = BeutyPrint()
Setting format:
Each format is a list of spans, can be defined as here (default instances):
# Each span object represents style applied for each printer word
# Sequentialy, if there will be more words, it will start repeat
format = [
BeutySpan(),
BeutySpan(),
BeutySpan()
]
# Setting default format pattern for printer
printer.setDefaultFormat(format)
Then we need to call print function of printer object:
# Takes one string
printer.print("Hello")
# Or string list
printer.print(["Test1", "Test2", "Test3"])
Output:
[ Hello ]
[ Test1 ][ Test2 ][ Test3 ]
Configuring Individual span:
format = [
BeutySpan(
# Text color used in span text
textColor = Fore.CYAN,
# Minimum length of span text field
textPadding = 10,
# In which direction unused span space will be inserted
textPaddingDirection = RIGHT,
# Span background color
textBackgroundColor = Back.GREEN,
# Span styles like text style
textStyle = Style.DIM,
# Left span seperator string
l_sep = '[ ',
# Right span seperator string
r_sep = ' ]',
# Default color of span string
defaultColor = Fore.RED,
# Advanced function for handling span differently
# dependent on message
postProcessor = functionHandler
)
]
Output looks like this, since we defined only 1 span, it keeps repeating for all messages
Second example:
format = [
# First pattern element
BeutySpan(
textColor = Fore.BLUE,
textPadding = 10,
textPaddingDirection = CENTER,
textStyle = Style.BRIGHT,
l_sep = '[[-> ',
r_sep = ' <-]]',
),
# Second pattern element
BeutySpan(
textColor = Fore.GREEN,
textPadding = 10,
textPaddingDirection = CENTER,
textStyle = Style.BRIGHT,
l_sep = '[[-> ',
r_sep = ' <-]]',
),
# Third pattern element
BeutySpan(
textColor = Fore.RED,
textPadding = 10,
textPaddingDirection = CENTER,
textStyle = Style.BRIGHT,
l_sep = '[[-> ',
r_sep = ' <-]]',
)
]
Output:
- Generalizing parent span
- Improve this readme
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Project has flexible python API object inheritence from parent API scrapping object, need more API Endpoints for scrapping in "api" folder, template is ProxyEngine.py file, which is template reference for other classes.
Distributed under the MIT License. See LICENSE.txt
for more information.
- Discord - Hex24#8712