summaryrefslogtreecommitdiffstats
path: root/scripts/external_libs/texttable-0.8.4/README.md
blob: 0d9895e84f49e2716a148a712d5e1cd34bd742da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# texttable

Python module for creating simple ASCII tables

## Availability

This module is available on [PypI](https://pypi.python.org/pypi/texttable/0.8.4), and has been packaged for several Linux/Unix platforms
([Debian](https://packages.debian.org/search?&searchon=names&keywords=python-texttable+),
[FreeBSD](https://www.freebsd.org/cgi/ports.cgi?query=texttable&stype=all), Fedora, Suse...).

## Documentation

```
NAME
    texttable - module for creating simple ASCII tables

FILE
    /usr/lib/python2.3/site-packages/texttable.py

DESCRIPTION
    
    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

CLASSES
    class Texttable
     |  Methods defined here:
     |  
     |  __init__(self, max_width=80)
     |      Constructor
     |      
     |      - max_width is an integer, specifying the maximum width of the table
     |      - if set to 0, size is unlimited, therefore cells won't be wrapped
     |  
     |  add_row(self, array)
     |      Add a row in the rows stack
     |      
     |      - cells can contain newlines and tabs
     |  
     |  add_rows(self, rows, header=True)
     |      Add several rows in the rows stack
     |      
     |      - The 'rows' argument can be either an iterator returning arrays,
     |        or a by-dimensional array
     |      - 'header' specifies if the first row should be used as the header
     |        of the table
     |  
     |  draw(self)
     |      Draw the table
     |      
     |      - the table is returned as a whole string
     |  
     |  header(self, array)
     |      Specify the header of the table
     |  
     |  reset(self)
     |      Reset the instance
     |      
     |      - reset rows and header
     |  
     |  set_chars(self, array)
     |      Set the characters used to draw lines between rows and columns
     |      
     |      - the array should contain 4 fields:
     |      
     |          [horizontal, vertical, corner, header]
     |      
     |      - default is set to:
     |      
     |          ['-', '|', '+', '=']
     |  
     |  set_cols_align(self, array)
     |      Set the desired columns alignment
     |      
     |      - the elements of the array should be either "l", "c" or "r":
     |      
     |          * "l": column flushed left
     |          * "c": column centered
     |          * "r": column flushed right
     |  
     |  set_cols_dtype(self, array)
     |      Set the desired columns datatype for the cols.
     |      
     |      - the elements of the array should be either "a", "t", "f", "e" or "i":
     |      
     |          * "a": automatic (try to use the most appropriate datatype)
     |          * "t": treat as text
     |          * "f": treat as float in decimal format
     |          * "e": treat as float in exponential format
     |          * "i": treat as int
     |      
     |      - by default, automatic datatyping is used for each column
     |  
     |  set_cols_valign(self, array)
     |      Set the desired columns vertical alignment
     |      
     |      - the elements of the array should be either "t", "m" or "b":
     |      
     |          * "t": column aligned on the top of the cell
     |          * "m": column aligned on the middle of the cell
     |          * "b": column aligned on the bottom of the cell
     |  
     |  set_cols_width(self, array)
     |      Set the desired columns width
     |      
     |      - the elements of the array should be integers, specifying the
     |        width of each column. For example:
     |      
     |              [10, 20, 5]
     |  
     |  set_deco(self, deco)
     |      Set the table decoration
     |      
     |      - 'deco' can be a combinaison of:
     |      
     |          Texttable.BORDER: Border around the table
     |          Texttable.HEADER: Horizontal line below the header
     |          Texttable.HLINES: Horizontal lines between rows
     |          Texttable.VLINES: Vertical lines between columns
     |      
     |         All of them are enabled by default
     |      
     |      - example:
     |      
     |          Texttable.BORDER | Texttable.HEADER
     |  
     |  set_precision(self, width)
     |      Set the desired precision for float/exponential formats
     |      
     |      - width must be an integer >= 0
     |      
     |      - default value is set to 3
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |  
     |  BORDER = 1
     |  
     |  HEADER = 2
     |  
     |  HLINES = 4
     |  
     |  VLINES = 8

DATA
    __all__ = ['Texttable', 'ArraySizeError']
    __author__ = 'Gerome Fournier <jef(at)foutaise.org>'
    __credits__ = 'Jeff Kowalczyk:\n    - textwrap improved import\n ...:\...
    __license__ = 'LGPL'
    __version__ = '0.8.4'

VERSION
    0.8.4

AUTHOR
    Gerome Fournier <jef(at)foutaise.org>

CREDITS
    Jeff Kowalczyk:
        - textwrap improved import
        - comment concerning header output
    
    Anonymous:
        - add_rows method, for adding rows in one go
    
    Sergey Simonenko:
        - redefined len() function to deal with non-ASCII characters
    
    Roger Lew:
        - columns datatype specifications
    
    Brian Peterson:
        - better handling of unicode errors
    
    Frank Sachsenheim:
        - add Python 2/3-compatibility
    
    Maximilian Hils:
        - fix minor bug for Python 3 compatibility
```