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
tade is a discussion/forum/link aggregator application. It provides three interfaces: a regular web page, a mailing list bridge and an NNTP server

tade is a discussion/forum/link aggregator application. It provides three interfaces: a regular web page, a mailing list bridge and an NNTP server

Manos Pitsidianakis 23 Nov 04, 2022
Format Norminette Output!

Format Norminette Output!

7 Apr 19, 2022
python package for generating typescript grpc-web stubs from protobuf files.

grpc-web-proto-compile NOTE: This package has been superseded by romnn/proto-compile, which provides the same functionality but offers a lot more flex

Roman Dahm 0 Sep 05, 2021
Random Number Generator

Application for generating a random number.

Michael J Bailey 1 Oct 12, 2021
Random Name and Slug Generator

Random Name and Slug Generator

Alexander Lukanin 104 Nov 30, 2022
Python HTTP Agent Parser

Features Fast Detects OS and Browser. Does not aim to be a full featured agent parser Will not turn into django-httpagentparser ;) Usage import ht

Shekhar 213 Dec 06, 2022
Cardano Stakepools: Check for scheduled blocks in current epoch.

ReLeaderLogs For Cardano Stakepool Operators: Lightweight Scheduled Blocks Checker for Current Epoch. No cardano-node Required, data is taken from blo

SNAKE (Cardano Stakepool) 2 Oct 19, 2021
A simple API that will return a key-value pair of randomly generated UUID

A simple API that will return a key-value pair of randomly generated UUID. Key will be a timestamp and value will be UUID. While the server is running, whenever the API is called, it should return al

Pius Lucky 2 Jan 18, 2022
Find version automatically based on git tags and commit messages.

GIT-CONVENTIONAL-VERSION Find version automatically based on git tags and commit messages. The tool is very specific in its function, so it is very fl

0 Nov 07, 2021
A collection of utility functions to prototype geometry processing research in python

gpytoolbox This repo is a work in progress and contains general utility functions I have needed to code while trying to work on geometry process resea

Silvia Sellรกn 73 Jan 06, 2023
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
Experimental python optimistic rollup fraud-proof generation

Macula Experimental python optimistic rollup fraud-proof generation tech by @protolambda. Working on a python version for brevity and simplicity. See

Diederik Loerakker 30 Sep 01, 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
Numbers-parser - Python module for parsing Apple Numbers .numbers files

numbers-parser numbers-parser is a Python module for parsing Apple Numbers .numbers files. It supports Numbers files generated by Numbers version 10.3

Jon Connell 154 Jan 05, 2023
Kanye West Lyrics Generator

aikanye Kanye West Lyrics Generator Python script for generating Kanye West lyrics Put kanye.txt in the same folder as the python script and run "pyth

4 Jan 21, 2022
Two fast AUC calculation implementations for python

fastauc Two fast AUC calculation implementations for python: python-based is approximately 5X faster than the default sklearn.metrics.roc_auc_score()

Vsevolod Kompantsev 26 Dec 11, 2022
Adding two matrix from scratch using python.

Adding-two-matrix-from-scratch-using-python. Here, I have take two matrix from user and add it without using any library. I made this program from scr

Sachin Vinayak Dabhade 4 Sep 24, 2021
Package that allows for validate and sanitize of string values.

py.validator A library of string validators and sanitizers Insipired by validator.js Strings only This library validates and sanitizes strings only. P

Sanel Hadzini 22 Nov 08, 2022
Shut is an opinionated tool to simplify publishing pure Python packages.

Welcome to Shut Shut is an opinionated tool to simplify publishing pure Python packages. What can Shut do for you? Generate setup files (setup.py, MAN

Niklas Rosenstein 6 Nov 18, 2022
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

Avi Perl 14 Oct 14, 2022