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
Python code to generate and store certificates automatically , using names from a csv file

WOC-certificate-generator Python code to generate and store certificates automatically , using names from a csv file IMPORTANT In order to make the co

Google Developer Student Club - IIIT Kalyani 10 May 26, 2022
cssOrganizer - organize a css file by grouping them into categories

This python project was created to scan through a CSS file and produce a more organized CSS file by grouping related CSS Properties within selectors. Created in my spare time for fun and my own utili

Andrew Espindola 0 Aug 31, 2022
Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.

Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.

Lark - Parsing Library & Toolkit 3.5k Jan 05, 2023
A script to check for common mistakes in LaTeX source files of scientific papers.

LaTeX Paper Linter This script checks for common mistakes in LaTeX source files of scientific papers. Usage python3 paperlint.py file.tex [-i/x inc

Michael Schwarz 12 Nov 16, 2022
A Random Password Generator made from Python

Things you need Python Step 1 Download the python file from Releases Step 2 Go to the directory where the python file is and run it Step 3 Type the le

Kavindu Nimsara 3 May 30, 2022
Set of scripts for some automation during Magic Lantern development

~kitor Magic Lantern scripts A few automation scripts I wrote to automate some things in my ML development efforts. Used only on Debian running over W

Kajetan Krykwiล„ski 1 Jan 03, 2022
Nmap script to guess* a GitLab version.

gitlab-version-nse Nmap script to guess* a GitLab version. Usage https://github.com/righel/gitlab-version-nse cd gitlab-version-nse nmap target --s

Luciano Righetti 120 Dec 05, 2022
Export watched content from Tautulli to the Letterboxd CSV Import Format

Export watched content from Tautulli to the Letterboxd CSV Import Format

Evan J 5 Aug 31, 2022
A thing to simplify listening for PG notifications with asyncpg

A thing to simplify listening for PG notifications with asyncpg

ANNA 18 Dec 23, 2022
isort is a Python utility / library to sort imports alphabetically, and automatically separated into sections and by type.

isort is a Python utility / library to sort imports alphabetically, and automatically separated into sections and by type. It provides a command line utility, Python library and plugins for various e

Python Code Quality Authority 5.5k Jan 08, 2023
A simple package for handling variables in string.

A simple package for handling string variables. Welcome! This is a simple package for handling variables in string, You can add or remove variables wi

1 Dec 31, 2021
Dill_tils is a package that has my commonly used functions inside it for ease of use.

DilllonB07 Utilities Dill_tils is a package that has my commonly used functions inside it for ease of use. Installation Anyone can use this package by

Dillon Barnes 2 Dec 05, 2021
A collection of common regular expressions bundled with an easy to use interface.

CommonRegex Find all times, dates, links, phone numbers, emails, ip addresses, prices, hex colors, and credit card numbers in a string. We did the har

Madison May 1.5k Dec 31, 2022
Use generator for range function

Use the generator for the range function! installation method: pip install yrange How to use: First import yrange in your application. You can then wo

1 Oct 28, 2021
A color library based on pokemons colors!

pokepalette A simple pokemon color chooser " This repo is based on CDWimmer/PokePalette and was originated from this tweet. If you don't remember your

Thomas Capelle 5 Aug 30, 2021
Raganarok X: Next Generation Data Dump

Raganarok X Data Dump Raganarok X: Next Generation Data Dump More interesting Files File Name Contains en_langs All the variables you need in English

14 Jul 15, 2022
Bounding Boxes Python Utils

Bounding Boxes Python Utils

Vadim 4 May 01, 2022
password generator

Password generator technologies used What is? It is Password generator How to Download? Download on releases Clone repo git clone https://github.com/m

1 Dec 16, 2021
This script allows you to retrieve all functions / variables names of a Python code, and the variables values.

Memory Extractor This script allows you to retrieve all functions / variables names of a Python code, and the variables values. How to use it ? The si

Venax 2 Dec 26, 2021
This is a python table of data implementation with styles, colors

Table This is a python table of data implementation with styles, colors Example Table adapts to the lack of data Lambda color features Full power of l

ะฃั€ัะดะพะฒ ะะปะตะบัะตะน 5 Nov 09, 2021