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
This suite consists of two different scripts, made to automate attacks against NoSQL databases.

NoSQL-Attack-Suite This suite consists of two different scripts, made to automate attacks against NoSQL databases. The first one looks for a NoSQL Aut

16 Dec 26, 2022
The fetch of the delegator list and the input of the epoch nonce need to be done independently

raffle The fetch of the delegator list and the input of the epoch nonce need to be done independently. Get the list of delegators at the epoch change.

1 Dec 15, 2021
Welcome to my pod transcript search webb app!

pod_transcript_search Welcome to the pod transcript search webb app! Tech stack used: Languages used: Python (for the back-end), JavaScript (for the f

3 Feb 04, 2022
Tomador de ramos UC automatico para Windows, Linux y macOS

auto-ramos v2.0 Tomador de ramos UC automatico para Windows, Linux y macOS Funcion Este script de Python tiene como principal objetivo hacer que la to

Open Source eUC 13 Jun 29, 2022
ripgrep recursively searches directories for a regex pattern while respecting your gitignore

ripgrep (rg) ripgrep is a line-oriented search tool that recursively searches the current directory for a regex pattern. By default, ripgrep will resp

Andrew Gallant 35k Dec 31, 2022
A basic python project which replicates the functionalities on an 8 Ball.

Magic-8-Ball To the people who wish to make decisions using a Magic 8 Ball but can't get one? I gotchu. This is a basic python project which replicate

3 Jun 24, 2021
Localization and multifractal properties of the long-range Kitaev chain in the presence of an Aubry-Andrรฉ-Harper modulation

This repository contains the code for the paper Localization and multifractal properties of the long-range Kitaev chain in the presence of an Aubry-Andrรฉ-Harper modulation.

Joana Fraxanet 2 Apr 17, 2022
A simple Programming Language

R.S.O.C. A custom built programming language About The Project R.S.O.C. is a custom built programming language very similar to a low-level 8085 progra

Ravi Maurya 17 Sep 13, 2022
Custom Python code for calculating the Probability of Profit (POP) for options trading strategies using Monte Carlo Simulations.

Custom Python code for calculating the Probability of Profit (POP) for options trading strategies using Monte Carlo Simulations.

35 Nov 22, 2022
Annotates sequences with Eggnog-mapper and hhblits against PDB70

Annotating "hypothetical" proteins with the PDB See config/ for configuration information. This workflow takes as input a set of protein sequences. It

1 Apr 05, 2022
A full-featured, hackable tiling window manager written and configured in Python

A full-featured, hackable tiling window manager written and configured in Python Features Simple, small and extensible. It's easy to write your own la

Qtile 3.8k Dec 31, 2022
If Google News had a Python library

pygooglenews If Google News had a Python library Created by Artem from newscatcherapi.com but you do not need anything from us or from anyone else to

Artem Bugara 1.1k Jan 08, 2023
Homed - Light-weight, easily configurable, dockerized homepage

homed GitHub Repo Docker Hub homed is a light-weight customizable portal primari

Matt Walters 12 Dec 15, 2022
Utility functions for working with data from Nix in Python

Pynixutil - Utility functions for working with data from Nix in Python Examples Base32 encoding/decoding import pynixutil input = "v5sv61sszx301i0x6x

Tweag 11 Dec 16, 2022
This speeds up PyCharm's package index processes and avoids CPU & memory overloading

This speeds up PyCharm's package index processes and avoids CPU & memory overloading

1 Feb 09, 2022
The official repository of iGEM Paris Bettencourt team's software tools.

iGEM_ParisBettencourt21 The official repository of iGEM Paris Bettencourt team's software tools. Cell counting There are two programs dedicated to the

Abhay Koushik 1 Oct 21, 2021
urlwatch is intended to help you watch changes in webpages and get notified of any changes.

urlwatch is intended to help you watch changes in webpages and get notified (via e-mail, in your terminal or through various third party services) of any changes.

Thomas Perl 2.5k Jan 08, 2023
Low-level Python CFFI Bindings for Argon2

Low-level Python CFFI Bindings for Argon2 argon2-cffi-bindings provides low-level CFFI bindings to the Argon2 password hashing algorithm including a v

Hynek Schlawack 4 Dec 15, 2022
Solutions for the Advent of Code 2021 event.

About ๐Ÿ“‹ This repository holds all of the solution code for the Advent of Code 2021 event. All solutions are done in Python 3.9.9 and done in non-real

robert yin 0 Mar 21, 2022
Reproduction repository for the MDX 2021 Hybrid Demucs model

Submission This is the submission for MDX 2021 Track A, for Track B go to the track_b branch. Submission Summary Submission ID: 151378 Submitter: defo

Alexandre Dรฉfossez 62 Dec 18, 2022