Python library to decorate and beautify strings

Overview

outputformat

Python library to decorate and beautify your standard output ๐Ÿ’–

ouf_image_example

Installation

To get the latest version, simply use pip:

pip install outputformat

There are no dependencies.

Python>=3.6 is needed, as it uses f strings.

Basic usage

It is recommended to use ouf as shortcut for outputformat:

import outputformat as ouf

Main functions are:

  • ouf.boxtitle
  • ouf.linetitle
  • ouf.bigtitle
  • ouf.showlist
  • ouf.bar
  • ouf.barlist

By default, functions print the result. You have the alternative to return a string instead, by passing the argument return_str=True (nothing will be printed in this case).

Showing titles

To decorate titles with a box around it, use ouf.boxtitle:

ouf.boxtitle("Long title in a box")
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Long title in a box โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Boxes can have different styles:

ouf.boxtitle("Box with 'line' style", style="line")
ouf.boxtitle("Box with 'double' style", style="double")
ouf.boxtitle("Box with 'dashes' style", style="dashes")
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Box with 'line' style โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ Box with 'double' style โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
โ•ญโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•ฎ
โ”Š Box with 'dashes' style โ”Š
โ•ฐโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•Œโ•ฏ

Or you can pass any character and it will be used for the decoration:

ouf.boxtitle("Box with custom character as style", style="รธ")
รธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธ
รธ Box with custom character as style รธ
รธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธรธ

With all the same options as for boxtitle, you can use linetitle for a simple line underneath your text:

ouf.linetitle("Long title with 'double' underline", style="double")
Long title with 'double' underline
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Big title

It is possible to use ASCII art to generate big titles:

outputstring = ouf.bigtitle("Here's a big title!")
โ–ˆ โ–ˆ โ–ˆโ–€โ–€ โ–ˆโ–€โ–ˆ โ–ˆโ–€โ–€ โ–€ โ–ˆโ–€   โ–„โ–€โ–ˆ   โ–ˆโ–„โ–„ โ–ˆ โ–ˆโ–€โ–€   โ–€โ–ˆโ–€ โ–ˆ โ–€โ–ˆโ–€ โ–ˆ   โ–ˆโ–€โ–€ โ–ˆ 
โ–ˆโ–€โ–ˆ โ–ˆโ–ˆโ–„ โ–ˆโ–€โ–„ โ–ˆโ–ˆโ–„   โ–„โ–ˆ   โ–ˆโ–€โ–ˆ   โ–ˆโ–„โ–ˆ โ–ˆ โ–ˆโ–„โ–ˆ    โ–ˆ  โ–ˆ  โ–ˆ  โ–ˆโ–„โ–„ โ–ˆโ–ˆโ–„ โ–„

Currently, only one font is available, and the supported characters are: "0123456789abcdefghijklmnopqrstuvwxyz_-!.' "

(You can get them by using ouf.fonts.suported_chars)

Showing lists

You can simply show a list using bullet points:

data = ["Item A", "Item B", "Item C", "Item D"]
ouf.showlist(data)
โ€ข Item A
โ€ข Item B
โ€ข Item C
โ€ข Item D

And also there's an option to add a title to your list:

data = ["Item A", "Item B", "Item C", "Item D"]
ouf.showlist(data, title="List of items")
List of items
โ€ข Item A
โ€ข Item B
โ€ข Item C
โ€ข Item D

Different styles are available, as bullet, line, box and ordinal

data = ["Item A", "Item B", "Item C", "Item D"]

ouf.showlist(data, style="line", title="Style line")
ouf.showlist(data, style="box", title="Style box")
ouf.showlist(data, style="ordinal", title="Style ordinal")
 Style line
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
โ”œ Item A
โ”œ Item B
โ”œ Item C
โ•ฐ Item D

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Style box โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
โ”œ Item A
โ”œ Item B
โ”œ Item C
โ•ฐ Item D

Style ordinal
1. Item A
2. Item B
3. Item C
4. Item D

Or pass any string to be used as marker

data = ["Item A", "Item B", "Item C", "Item D"]
ouf.showlist(data, style="~>", title="Custom style list")
Custom style list
~> Item A
~> Item B
~> Item C
~> Item D

Showing bars

You can create a simple horizontal bar using ouf.bar The first parameter (value) is the filled amount, the second (maxvalue) is the maximum amount

ouf.bar(35, 50)
โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 35/50 ( 70.00%)

Note that there's some integer rounding needed to create the bar, so the size is not precise, more like a ballpark visualisation.

The size of the bar (in characters) is defined by length

ouf.bar(35, 50, length=10)
ouf.bar(35, 50, length=50)
โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–‘โ–‘โ–‘ 35/50 ( 70.00%)
โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 35/50 ( 70.00%)

Different styles are available, as well as the option to have a title before the bar:

ouf.bar(35, 50, style="block", length=15, title="Block style", title_pad=15)
ouf.bar(35, 50, style="battery", length=15,title="Battery style", title_pad=15)
ouf.bar(35, 50, style="bar", length=15, title="Bar style", title_pad=15)
ouf.bar(35, 50, style="circle", length=15, title="Circle style", title_pad=15)
Block style....: โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–‘โ–‘โ–‘โ–‘โ–‘ 35/50 ( 70.00%)

Battery style..: โ”ซโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ     โ”ฃ 35/50 ( 70.00%)

Bar style......: [โ– โ– โ– โ– โ– โ– โ– โ– โ– โ–      ] 35/50 ( 70.00%)

Circle style...: โ—โ—โ—โ—โ—โ—โ—โ—โ—โ—โ—‹โ—‹โ—‹โ—‹โ—‹ 35/50 ( 70.00%)

There's also a star emoji style, that works better with small values for length and using show_percentage=False and show_values=False

ouf.bar(60, 100, style="star", length=5, title="Item A", show_percentage=False, show_values=False)
ouf.bar(20, 100, style="star", length=5, title="Item B", show_percentage=False, show_values=False)
ouf.bar(90, 100, style="star", length=5, title="Item C", show_percentage=False, show_values=False)
Item A: โญโญโญ
Item B: โญ
Item C: โญโญโญโญ

Custom bars

A totally custom style for the bar can be created, passing a list of characters as style

ouf.bar(35, 50, style=["(", "X", "-", ")"], title="Custom style")
Custom style: (XXXXXXXXXXXXXXXXXXXXXX----------) 35/50 ( 70.00%)

Or you can pass just a simple character, and it will be used for a basic bar:

ouf.bar(35, 50, style="$", title="Custom style")
Custom style: [$$$$$$$$$$$$$$$$$$$$$$          ] 35/50 ( 70.00%)

Multiple bars from list

It is possible to use ouf.barlist and pass directly a list of values with the correspondent list of titles

values = [6, 3, 13, 8]
titles = ["var", "long var name", "medium var", "one more"]
ouf.barlist(values, titles, maxvalue=15, style="bar")
var..........: [โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ–                     ]  6/15 ( 40.00%)
long var name: [โ– โ– โ– โ– โ– โ–                           ]  3/15 ( 20.00%)
medium var...: [โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ–      ] 13/15 ( 86.67%)
one more.....: [โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ– โ–                ]  8/15 ( 53.33%)

The same parameters from ouf.bar can be used. Only one maxvalue is used for all the lists

Show emoji

Some shortcuts for the unicode values of common emoji are available

print(ouf.emoji.heart, ouf.emoji.thumbs_up)
๐Ÿ’– ๐Ÿ‘

Current shortcuts are the following:

crazy.............:๐Ÿคช
sad...............:๐Ÿ˜ฅ
circle_red........:๐Ÿ”ด
circle_orange.....:๐ŸŸ 
circle_yellow.....:๐ŸŸก
circle_green......:๐ŸŸข
circle_white......:โšช
circle_black......:โšซ
star..............:โญ
heart.............:๐Ÿ’–
thumbs_up.........:๐Ÿ‘
check.............:โœ…
clap..............:๐Ÿ‘
bomb..............:๐Ÿ’ฃ
You might also like...
A simple gpsd client and python library.

gpsdclient A small and simple gpsd client and library Installation Needs Python 3 (no other dependencies). If you want to use the library, use pip: pi

A library for interacting with Path of Exile game and economy data, and a unique loot filter generation framework.

wraeblast A library for interfacing with Path of Exile game and economy data, and a set of item filters geared towards trade league players. Filter Ge

A functional standard library for Python.

Toolz A set of utility functions for iterators, functions, and dictionaries. See the PyToolz documentation at https://toolz.readthedocs.io LICENSE New

Retrying library for Python

Tenacity Tenacity is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just

Retrying is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just about anything.

Retrying Retrying is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just

ecowater-softner is a Python library for collecting information from Ecowater water softeners.

Ecowater Softner ecowater-softner is a Python library for collecting information from Ecowater water softeners. Installation Use the package manager p

A tiny Python library for generating public IDs from integers

pids Create short public identifiers based on integer IDs. Installation pip install pids Usage from pids import pid public_id = pid.from_int(1234) #

Helpful functions for use alongside the rich Python library.

๐Ÿ”ง Rich Tools A python package with helpful functions for use alongside with the rich python library. ๓ € ๓ €  The current features are: Convert a Pandas

The git for the Python Story Utility Package library.

SUP The git for the Python Story Utility Package library. Installation: Install SUP by simply running pip install psup in your terminal. Check out our

Comments
  • New big font

    New big font

    New style for bigtitle :point_right: big

    for style in ouf.fonts.font_styles:
        outputstring = ouf.bigtitle(f"style: {style}", style=style)
    
    opened by delestro 0
  • Basic colors

    Basic colors

    added color functionality

    Examples:

    ouf.boxtitle("Box title here", color="rainbow", cmap="cool", bold=True)
    
    ouf.bigtitle("big title in color", color="#9030BA")
    
    ouf.bigtitle("big title in color", color="#9030BA")
    
    ouf.c("Hello!", "red" , bold=True)
    
    for cmap in ouf.color.cmaps:
        ouf.b(cmap)
        ouf.rainbow("โ–‡"*50, cmap=cmap)
        ouf.br(2)
    
    opened by delestro 0
  • basic showdict

    basic showdict

    ouf.showdict added:

    data = {"Variable0001": 42,
            "Var2": [24, 32, 64.00000000001, "string"],
            "Variable3": False,
            "V4": [39.032323423525623, 23.68],
            "Var5": [42, -43, 29],
            "Vari6": 39,
             }
    
    ouf.showdict(data, style="box", title="Title here", precision=2)
    
    โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
    โ”‚ Title here โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
    โ”œ Variable0001: 42
    โ”œ V4..........: 24, 32, 64.00, string
    โ”œ Variable3...: False
    โ”œ Var2........: 39.03, 23.68
    โ”œ Variable3...: +42, -43, +29
    โ•ฐ Vari6.......: 39
    
    opened by delestro 0
  • Fix empty values for barlist

    Fix empty values for barlist

    barlist was breaking in case NaNs or None was given. Now works as expected:

    values = [np.nan, 24, None, 10]
    titles = ["VarA", np.nan, "VarCCCC", None]
    
    ouf.barlist(values, titles=titles, maxvalue=100)
    

    Gives as output:

    VarA...: 
    nan....: [โ– โ– โ– โ– โ– โ– โ–                          ]  24.00/100.00 ( 24.00%)
    VarCCCC: 
    None...: [โ– โ– โ–                              ]  10.00/100.00 ( 10.00%)
    
    
    opened by delestro 0
Releases(v0.1.3)
Owner
Felipe Delestro Matos
Felipe Delestro Matos
Fcpy: A Python package for high performance, fast convergence and high precision numerical fractional calculus computing.

Fcpy: A Python package for high performance, fast convergence and high precision numerical fractional calculus computing.

SciFracX 1 Mar 23, 2022
Tools for binary data on cassette

Micro Manchester Tape Storage Tools for storing binary data on cassette Includes: Python script for encoding Arduino sketch for decoding Eagle CAD fil

Zack Nelson 28 Dec 25, 2022
โœจ Un juste prix totalement fait en Python par moi, et en franรงais.

Juste Prix โ— Un juste prix totalement fait en Python par moi, et en franรงais. ๐Ÿ”ฎ Avec l'utilisation du module "random", j'ai pu faire un choix alรฉatoi

MrGabin 3 Jun 06, 2021
About Library for extract infomation from thai personal identity card.

ThaiPersonalCardExtract Library for extract infomation from thai personal identity card. imprement from easyocr and tesseract New Feature v1.3.2 ๐ŸŽ In

ggafiled 26 Nov 15, 2022
EthTx - Ethereum transactions decoder

EthTx - Ethereum transactions decoder Installation pip install ethtx Requirements The package needs a few external resources, defined in EthTxConfig o

398 Dec 25, 2022
Automatically Generate Rulesets for IIS for Intelligent HTTP/S C2 Redirection

Automatically Generate Rulesets for IIS for Intelligent HTTP/S C2 Redirection This project converts a Cobalt Strike profile to a functional web.config

Jesse 99 Dec 13, 2022
A simple and easy to use Spam Bot made in Python!

This is a simple spam bot made in python. You can use to to spam anyone with anything on any platform.

7 Sep 08, 2022
โœจ Un chois alรฉatoire d'un article sur Wikipedia totalement fait en Python par moi, et en franรงais.

Wikipedia Random Article โ— Un chois alรฉatoire d'un article sur Wikipedia totalement fait en Python par moi, et en franรงais. ๐Ÿ”ฎ Grรขce a une requรจte a w

MrGabin 4 Jul 18, 2021
A clock app, which helps you with routine tasks.

Clock This app helps you with routine tasks. Alarm Clock Timer Stop Watch World Time (Which city you want) About me Full name: Matin Ardestani Age: 14

Matin Ardestani 13 Jul 30, 2022
SmarTool - Smart Util Tool for Python

A set of tools that keep Python sweeter.

Liu Tao 9 Sep 30, 2022
Check the basic quality of any dataset

Data Quality Checker in Python Check the basic quality of any dataset. Sneak Peek Read full tutorial at Medium. Explore the app Requirements python 3.

MalaDeep 8 Feb 23, 2022
A Tool that provides automatic kerning for ligature based OpenType fonts in Microsoft Volt

Kerning A Tool that provides automatic kerning for ligature based OpenType fonts in Microsoft Volt There are three stages of the algorithm. The first

Sayed Zeeshan Asghar 6 Aug 01, 2022
Toolkit for collecting and applying templates of prompting instances

PromptSource Toolkit for collecting and applying templates of prompting instances. WIP Setup Download the repo Navigate to root directory of the repo

BigScience Workshop 1k Jan 05, 2023
This is Cool Utility tools that you can use in python.

This is Cool Utility tools that you can use in python. There are a few tools that you might find very useful, you can use this on pretty much any project and some utils might help you a lot and save

Senarc Studios 6 Apr 18, 2022
Import the module and create an object of the class LocalVariable.

LocalVariable Import the module and create an object of the class LocalVariable. Call the save method with the name and the value of a variable as arg

Sajedur Rahman Fiad 2 Dec 14, 2022
A BlackJack simulator in Python to simulate thousands or millions of hands using different strategies.

BlackJack Simulator (in Python) A BlackJack simulator to play any number of hands using different strategies The Rules To keep the code relatively sim

Hamid 4 Jun 24, 2022
Backman is a random/fixed background image setter for wlroots based compositors

backman Backman is a random/fixed background image setter for wlroots based compositors Dependencies: The program depends on swaybg, python3-toml (or

Hemish 3 Mar 09, 2022
UUID version 7, which are time-sortable (following the Peabody RFC4122 draft)

uuid7 - time-sortable UUIDs This module implements the version 7 UUIDs, proposed by Peabody and Davis in https://www.ietf.org/id/draft-peabody-dispatc

Steve Simmons 22 Dec 20, 2022
A python script to generate wallpaper

wallpaper eits Warning You need to set the path to Robot Mono font in the source code. (Settings are in the main function) Usage A script that given a

Henrique Tsuyoshi Yara 5 Dec 02, 2021
Bounding Boxes Python Utils

Bounding Boxes Python Utils

Vadim 4 May 01, 2022