Skip to main content

Small package made for using ANSI codes

Project description

pylor

Library for outputting colorful text

Supports 16 foreground and 16 background colors


Color table

Table from Wikipedia


QuickStart

Use: pip install pylor to install the module.

Imports

import pylor
from pylor import colors # Imports class full of colors to choose from
from pylor import decorations # Imports class full of decorations
from pylor import cursor # Imports class for cursor movement

Testing the installation

import pylor
print( pylor.test() ) # This will print the project logo

Functions

color()

The color function is used to create colored strings.

Arguments:

  • String
  • Foreground color
  • Background color [Optional]

Example:

import pylor
from pylor import colors

print( pylor.color("Hello world!", colors.foreground.red) )

Returns string


colorNoReset()

The color function is used to create colored strings, does not set the color back to default (continues to color any future output).

Arguments:

  • String
  • Foreground color
  • Background color [Optional]

Example:

import pylor
from pylor import colors

print( pylor.colorNoReset("Hello world!", colors.foreground.red) )

Returns string


formatting()

Function used for formatting text.

Arguments:

  • String
  • Formatting type

Example:

import pylor
from pylor import decorations

print( pylor.formatting("Hello world!", decorations.bold) )

Returns string


formattingNoReset()

Function used for formatting text, does not set the color back to default (continues to decorate any future output).

Arguments:

  • String
  • Formatting type

Example:

import pylor
from pylor import decorations

print( pylor.formatting("Hello world!", decorations.bold) )

Returns string


reset()

Function used for resetting the color after using colorNoReset()

Arguments:

  • None

Example:

import pylor

print( pylor.reset() )

Returns string


test()

Function for testing the installation of the package, returns the project logo.

Arguments:

  • None

Example:

import pylor

print( pylor.test() )

Returns string


Codes

Colors

Foreground

colors.foreground.

red
black
green
yellow
blue
magenta
cyan
white
brightBlack
brightRed
brightGreen
brightYellow
brightBlue
brightMagenta
brightCyan
brightWhite

Background

colors.background.

red
black
green
yellow
blue
magenta
cyan
white
brightBlack
brightRed
brightGreen
brightYellow
brightBlue
brightMagenta
brightCyan
brightWhite

Decorations

decorations.

bold
underline
reverse

Cursor

cursor.

up
down
right
left

Exceptions

NotAColor

Exception for when the argument given is not an ANSI code.

Example of code that would trigger this Exception:

import pylor
from pylor import colors

print( pylor.color("Hello world!", "red") ) # This is an example of bad code, do not use this, it will not work.

correct code:

import pylor
from pylor import colors

print( pylor.color("Hello world!", colors.foreground.red) )

SameType

Exception for when the background/foreground colors are used twice.

Example of code that would trigger this Exception:

import pylor
from pylor import colors

print( pylor.color("Hello world!", colors.foreground.red, colors.foreground.green) ) # This is an example of bad code, do not use this, it will not work.

correct code:

import pylor
from pylor import colors

print( pylor.color("Hello world!", colors.foreground.red, colors.background.red) )

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

pylor-0.0.2.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

pylor-0.0.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file pylor-0.0.2.tar.gz.

File metadata

  • Download URL: pylor-0.0.2.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.6

File hashes

Hashes for pylor-0.0.2.tar.gz
Algorithm Hash digest
SHA256 16ac276b3e50370ff0e30588662908b4b8be140b267b3563a55c52223f7efe1f
MD5 519ae408f1cd98d343a16b5fa69651f9
BLAKE2b-256 074345426800acb9f22d0274d79ba2b22ac38e4394e0127a8f51647bcb2e0f7e

See more details on using hashes here.

File details

Details for the file pylor-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pylor-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.6

File hashes

Hashes for pylor-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 59ad3c684fa6c4d212b3aa08fb528411c163c404dd804174a337effe032cc709
MD5 e896a63731470043f4d313ac2a3eed7c
BLAKE2b-256 23f1afe25d25973a660b385535d89b296ccf626e2641dbf59fd002e9679757bb

See more details on using hashes here.

Supported by

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