Skip to main content

Just a simple library to print your script outputs in more neat / colorful way without much overhead

Project description


Logo

BeutyPrinter

A Python library to give beuty to your python scripts printing structure
Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

Product Name Screen Shot

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

(back to top)

Built With:

  • Visual Studio Code
  • Python

(back to top)

Getting Started

Project is uploaded to PYPI, so you can install it pretty easily using pip tool.

Installation

  1. Install package using pip command
    pip install beuty-print
    

(back to top)

Usage

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

Product Name Screen Shot


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:

Product Name Screen Shot

Roadmap

  • Generalizing parent span
  • Improve this readme

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. 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.

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

  • Discord - Hex24#8712

(back to top)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beuty-print-1.0.2.tar.gz (5.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page