Skip to main content

Declarative Python fancy print statement

Project description

Deprint - Declarative Python fancy print statement

Deprint allows you to write a complex yet easy to understand print statement in Python, resulting in beautiful CLI interface on any ANSI/VT100 terminal emulators.

Installation

Install via pip

pip install deprint

Basic usage

Deprint can be used in either the declarative style or the imperative (persistent) style.

Declarative style

Declarative syntax of Deprint only applies the style to the text only once with no effect to other print statements.

from deprint import deprint

dp = deprint()

# clear screen
dp.clear()

# print red text
dp.colour('red').print('red text)

# print bold text
dp.style('bold').print('bold text')

# print light_blue text on yellow background
dp.colour('blue').bg('yellow').print('blue on yellow text')

# print green underlined text on white background
dp.style('underlined').colour('green').bg('white').print('underlined green text')

Persistent style

Persistent syntax of Deprint applies the style globally to the terminal session. All print statements (including Python's native print()) are affected by the persistent styling.

from deprint import deprint

dp = deprint()

# clear screen
dp.clear()

# print red text
dp.setColour('red')
dp.print('red text')
print('This text is also red')

# print light_blue text on yellow background
dp.setColour('light_blue')
dp.setBackground('yellow')
dp.print('blue on yellow text')

# print green underlined text on white background
dp.setColour('green')
dp.setBackground('white')
dp.setStyle('underlined')
dp.print('underlined green text)

# reset to default style
dp.reset()

API documentation

class deprint.deprint()

Print fancy terminal output.

Methods

deprint.deprint.clear()

Clear entire terminal screen.


deprint.deprint.emptylines(num=1)

Print num empty lines to the terminal.


deprint.deprint.reset()

Reset all style to terminal's default.


deprint.deprint.print(text)

Print text to the terminal with the applied style.

The print method will maintain the style if the style is set through the persistent methods, or reset to default if the style is set through the declarative methods.

Declarative

deprint.deprint.colour(colour)

Apply colour to the printed text.

Colour can be either a number between 1 - 256 (8bit colour) or one of the following strings: black, red, green, yellow, blue, magenta, cyan, light_grey,dark_grey, light_red, light_green, light_yellow, light_blue, light_magenta, light_cyan, white, default, reset.


deprint.deprint.bg(colour)

Apply background colour to the printed text.

Colour can be either a number between 1 - 256 (8bit colour) or one of the following strings: black, red, green, yellow, blue, magenta, cyan, light_grey,dark_grey, light_red, light_green, light_yellow, light_blue, light_magenta, light_cyan, white, default, reset.


deprint.deprint.style(style)

Apply text style to the printed text.

Style can be on of the following stings: bold, dim, underlined, blink, inverse, hidden, default, reset.


deprint.deprint.hold()

Prevent the print statement to end with a new line.

Persistent

deprint.deprint.setColour(colour)

Change the colour of the terminal's printed text.

Colour can be either a number between 1 - 256 (8bit colour) or one of the following strings: black, red, green, yellow, blue, magenta, cyan, light_grey,dark_grey, light_red, light_green, light_yellow, light_blue, light_magenta, light_cyan, white, default, reset.


deprint.deprint.setBackground(colour)

Change the colour of the terminal's printed text's background.

Colour can be either a number between 1 - 256 (8bit colour) or one of the following strings: black, red, green, yellow, blue, magenta, cyan, light_grey,dark_grey, light_red, light_green, light_yellow, light_blue, light_magenta, light_cyan, white, default, reset.


deprint.deprint.setStyle(style)

Change the text style of the terminal's printed text.

Style can be on of the following stings: bold, dim, underlined, blink, inverse, hidden, default, reset.

Project details


Release history Release notifications | RSS feed

This version

0.2

Download files

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

Source Distribution

deprint-0.2.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file deprint-0.2.tar.gz.

File metadata

  • Download URL: deprint-0.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for deprint-0.2.tar.gz
Algorithm Hash digest
SHA256 4afca91134d90cfbb00254469d3739ea2196df2fe235d3c14095d775cc268c45
MD5 c8f8749e5f2d97ada34f1fca4a1e2d60
BLAKE2b-256 e2ebb29765b22cb5d1fa3a85e2d1dd0198f3a2d3e5b4bf02e9784added9f62c9

See more details on using hashes here.

Supported by

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