Python library to decorate and beautify strings

Overview

outputformater

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

ouf_image_example

Installation

To get the latest version, simply use pip:

pip install outputformater

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 outputformater:

import outputformater 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...
๐Ÿ”ฉ Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.

Boltons boltons should be builtins. Boltons is a set of over 230 BSD-licensed, pure-Python utilities in the same spirit as โ€” and yet conspicuously mis

App and Python library for parsing, writing, and validation of the STAND013 file format.

python-stand013 python-stand013 is a Python app and library for parsing, writing, and validation of the STAND013 file format. Features The following i

This Python library searches through a static directory and appends artist, title, track number, album title, duration, and genre to a .json object

This Python library searches through a static directory (needs to match your environment) and appends artist, title, track number, album title, duration, and genre to a .json object. This .json object is then used to post data to a specified table in a local MySQL database, credentials of which the user must set.

 PREFS is a Python library to store and manage preferences and settings.
PREFS is a Python library to store and manage preferences and settings.

PREFS PREFS is a Python library to store and manage preferences and settings. PREFS stores a Python dictionary in a total human-readable file, the PRE

Simple, high-school-leveled sequence library written in Python / ๊ฐ„๋‹จํ•œ ๊ณ ๋“ฑํ•™๊ต ์ˆ˜์ค€ ์ˆ˜์—ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ (Python)
Ikaros is a free financial library built in pure python that can be used to get information for single stocks, generate signals and build prortfolios

Ikaros is a free financial library built in pure python that can be used to get information for single stocks, generate signals and build prortfolios

Python library and cli util for https://www.zerochan.net/

Zerochan Library for Zerochan.net with pics parsing and downloader included! Features CLI utility for pics downloading from zerochan.net Library for c

Datargsing is a data management and manipulation Python library
Datargsing is a data management and manipulation Python library

Datargsing What is It? Datargsing is a data management and manipulation Python library which is currently in deving Why this library is good? This Pyt

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
For radiometrically calibrating and PSF deconvolving IRIS data

irispreppy For radiometrically calibrating and PSF deconvolving IRIS data. I dislike how I need to own proprietary software (IDL) just to simply prepa

Aaron W. Peat 4 Nov 01, 2022
Python samples for Google Cloud Platform products.

Google Cloud Platform Python Samples Python samples for Google Cloud Platform products. Setup Install pip and virtualenv if you do not already have th

Google Cloud Platform 6k Jan 03, 2023
Fabric mod where anyone can PR anything, concerning or not. I'll merge everything as soon as it works.

Guess What Will Happen In This Fabric mod where anyone can PR anything, concerning or not (Unless it's too concerning). I'll merge everything as soon

anatom 65 Dec 25, 2022
python based clash stars made by grade 7 and 5

clash_stars python based clash stars made by grade 7 and 5 How to play: PLAYER ONE (LEFT PLAYER) Move: W,A,S,D Shoot: SHIFT PLAYER TWO (RIGHT PLAYER)

5 Oct 22, 2021
Inviare messaggi tramite app IO a partire da dati contenuti in file .csv

parlaConIO Inviare messaggi tramite app IO a partire da dati contenuti in file .csv -- Nessun obbligo, ma in caso di clonazione o uso del programma c

Francesco Del Castillo 6 Aug 22, 2022
CRC Reverse Engineering Tool in Python

CRC Beagle CRC Beagle is a tool for reverse engineering CRCs. It is designed for commnication protocols where you often have several messages of the s

Colin O'Flynn 51 Jan 05, 2023
Forward RSS feeds to your email address, community maintained

Getting Started With rss2email We highly recommend that you watch the rss2email project on GitHub so you can keep up to date with the latest version,

248 Dec 28, 2022
This is an implementation of NeuronJ work with python.

NeuronJ This is an implementation of NeuronJ work with python. NeuronJ is a plug-in for ImageJ that allows you to create and edit neurons masks. Image

Mohammad Mahdi Samei 3 Aug 28, 2022
Gerador de dafaces

๐ŸŽด DefaceGenerator Obs: esse script foi criado com a intenรงรฃo de ajudar pessoas iniciantes no hacking que ainda nรฃo conseguem criar suas prรณprias defa

LordShinigami 3 Jan 09, 2022
Hands-on machine learning workshop

emb-ntua-workshop This workshop discusses introductory concepts of machine learning and data mining following a hands-on approach using popular tools

ISSEL Soft Eng Team 12 Oct 30, 2022
Analyzes crypto candles over a set time period and then trades based on winning patterns found

patternstrade Analyzes crypto candles over a set time period and then trades based on winning patterns found. Heavily customizable. Warning: This was

ConnorCreate 14 May 29, 2022
Abilian Core: an enterprise application development platform based on the Flask micro-framework, the SQLAlchemy ORM

About Abilian Core is an enterprise application development platform based on the Flask micro-framework, the SQLAlchemy ORM, good intentions and best

Abilian open source projects 47 Apr 14, 2022
Programa que organiza pastas automaticamente

๐Ÿ“‚ Folder Organizer ๐Ÿ“‚ Programa que organiza pastas automaticamente Requisitos โ€ข Como usar โ€ข Melhorias futuras โ€ข Capturas de Tela Requisitos Antes de

Joรฃo Victor Vilela dos Santos 1 Nov 02, 2021
Lectures for Udemy - Complete Python Bootcamp Course

Complete-Python-Bootcamp Welcome to the Repository for the Complete Python Bootcamp! This is the Repository for the Udemy course - "Complete Python Bo

Marci 2k Dec 28, 2022
A reference implementation for processing the content.log files found at opendata.dwd.de/weather

A reference implementation for processing the content.log files found at opendata.dwd.de/weather.

Deutscher Wetterdienst (DWD) 6 Nov 26, 2022
Iยณ Tracker for Essential Open Innovation Datasets

Iยณ Tracker for Essential Open Innovation Datasets This repository is set up to track, version, and contribute updates to the Iยณ Essential Open Innovat

1 Feb 08, 2022
A self contained invitation management system for gatekeeping.

Invitease Description A self contained invitation management system for gatekeeping. Purpose Serves as a focal point for inviting guests to a venue pr

ืžืขื’ืŸ ืžื™ื›ืืœ 7 Jul 19, 2022
Blender-3D-SH-Dma-plugin - Import and export Sonic Heroes Delta Morph animations (.anm) into Blender 3D

io_scene_sonic_heroes_dma This plugin for Blender 3D allows you to import and ex

Psycrow 3 Mar 22, 2022
jmespath.rs Python binding

rjmespath-py jmespath.rs Python binding.

messense 3 Dec 14, 2022
freeCodeCamp Scientific Computing with Python Project for Certification.

Time_Calculator_freeCodeCamp freeCodeCamp Scientific Computing with Python Project for Certification. Write a function named add_time that takes in tw

Rajdeep Mondal 1 Dec 23, 2021