pyenv-virtualenv for Windows 1.2
A 'pyenv' plugin to manage Python virtual environments, depending on different Python versions, for various Python projects.
Loading...
Searching...
No Matches
tbl Namespace Reference

Classes

class  SimpleTable
 

Functions

int readableLen (str cell_content)
 Calculate the length of cell content skipping ANSI ESC sequences (e.g.
 

Variables

int HEADER = 1
 
int SEPARATOR = 2
 
int DATA = 3
 
list ROW_TYPES = [HEADER, SEPARATOR, DATA]
 

Function Documentation

◆ readableLen()

int tbl.readableLen ( str cell_content)

Calculate the length of cell content skipping ANSI ESC sequences (e.g.

for color).

Parameters
cell_contentRaw cell content including ANSI ESC sequences.
Returns
Length of readable cell content without ANSI ESC sequences.
See also
https://stackoverflow.com/questions/14693701/how-can-i-remove-the-ansi-escape-sequences-from-a-string-in-python

Definition at line 50 of file tbl.py.

50def readableLen(cell_content: str) -> int:
51 ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
52 result = ansi_escape.sub('', cell_content)
53 return len(result)
54
55
56# --- CLASSES ----------------------------------------------------------
57

Variable Documentation

◆ HEADER

int tbl.HEADER = 1

Definition at line 36 of file tbl.py.

◆ SEPARATOR

int tbl.SEPARATOR = 2

Definition at line 37 of file tbl.py.

◆ DATA

int tbl.DATA = 3

Definition at line 38 of file tbl.py.

◆ ROW_TYPES

list tbl.ROW_TYPES = [HEADER, SEPARATOR, DATA]

Definition at line 40 of file tbl.py.