DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
afc.click_texttable Namespace Reference

Classes

class  ArraySizeError
 
class  bcolors
 
class  Texttable
 

Functions

 len (iterable)
 
 get_color_string (type, string)
 

Variables

list __all__ = ["Texttable", "ArraySizeError"]
 
str __author__ = 'Gerome Fournier <jef(at)foutaise.org>'
 
str __license__ = 'GPL'
 
str __version__ = '0.8.1'
 
str __credits__
 
 table = Texttable()
 

Detailed Description

module for creating simple ASCII tables


Example:

    table = Texttable()
    table.set_cols_align(["l", "r", "c"])
    table.set_cols_valign(["t", "m", "b"])
    table.add_rows([ ["Name", "Age", "Nickname"],
                     ["Mr\\nXavier\\nHuon", 32, "Xav'"],
                     ["Mr\\nBaptiste\\nClement", 1, "Baby"] ])
    print table.draw() + "\\n"

    table = Texttable()
    table.set_deco(Texttable.HEADER)
    table.set_cols_dtype(['t',  # text
                          'f',  # float (decimal)
                          'e',  # float (exponent)
                          'i',  # integer
                          'a']) # automatic
    table.set_cols_align(["l", "r", "r", "r", "l"])
    table.add_rows([["text",    "float", "exp", "int", "auto"],
                    ["abcd",    "67",    654,   89,    128.001],
                    ["efghijk", 67.5434, .654,  89.6,  12800000000000000000000.00023],
                    ["lmn",     5e-78,   5e-78, 89.4,  .000000000000128],
                    ["opqrstu", .023,    5e+78, 92.,   12800000000000000000000]])
    print table.draw()

Result:

    +----------+-----+----------+
    |   Name   | Age | Nickname |
    +==========+=====+==========+
    | Mr       |     |          |
    | Xavier   |  32 |          |
    | Huon     |     |   Xav'   |
    +----------+-----+----------+
    | Mr       |     |          |
    | Baptiste |   1 |          |
    | Clement  |     |   Baby   |
    +----------+-----+----------+

    text   float       exp      int     auto
    ===========================================
    abcd   67.000   6.540e+02   89    128.001
    efgh   67.543   6.540e-01   90    1.280e+22
    ijkl   0.000    5.000e-78   89    0.000
    mnop   0.023    5.000e+78   92    1.280e+22

Function Documentation

◆ get_color_string()

afc.click_texttable.get_color_string ( type,
string )

Definition at line 143 of file click_texttable.py.

143def get_color_string(type, string):
144 end = bcolors.ENDC
145 if type == bcolors.WHITE:
146 end = ''
147 return '%s%s%s' % (type, string, end)
148

◆ len()

afc.click_texttable.len ( iterable)
Redefining len here so it will be able to work with non-ASCII characters

Definition at line 110 of file click_texttable.py.

110def len(iterable):
111 """Redefining len here so it will be able to work with non-ASCII characters
112 """
113 if not isinstance(iterable, str):
114 return iterable.__len__()
115
116 try:
117 return len(str(iterable, 'utf'))
118 except:
119 return iterable.__len__()
120

Variable Documentation

◆ __all__

list afc.click_texttable.__all__ = ["Texttable", "ArraySizeError"]
private

Definition at line 70 of file click_texttable.py.

◆ __author__

str afc.click_texttable.__author__ = 'Gerome Fournier <jef(at)foutaise.org>'
private

Definition at line 72 of file click_texttable.py.

◆ __credits__

str afc.click_texttable.__credits__
private
Initial value:
1= """\
2Jeff Kowalczyk:
3 - textwrap improved import
4 - comment concerning header output
5
6Anonymous:
7 - add_rows method, for adding rows in one go
8
9Sergey Simonenko:
10 - redefined len() function to deal with non-ASCII characters
11
12Roger Lew:
13 - columns datatype specifications
14
15Brian Peterson:
16 - better handling of unicode errors
17"""

Definition at line 75 of file click_texttable.py.

◆ __license__

str afc.click_texttable.__license__ = 'GPL'
private

Definition at line 73 of file click_texttable.py.

◆ __version__

str afc.click_texttable.__version__ = '0.8.1'
private

Definition at line 74 of file click_texttable.py.

◆ table

afc.click_texttable.table = Texttable()

Definition at line 665 of file click_texttable.py.