prettytable 0.6.1__zip → 0.7.2__zip
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {prettytable-0.6.1 → prettytable-0.7.2}/CHANGELOG +28 -12
- {prettytable-0.6.1 → prettytable-0.7.2}/COPYING +3 -1
- {prettytable-0.6.1/prettytable.egg-info → prettytable-0.7.2}/PKG-INFO +3 -1
- {prettytable-0.6.1 → prettytable-0.7.2}/README +48 -12
- {prettytable-0.6.1 → prettytable-0.7.2/prettytable.egg-info}/PKG-INFO +3 -1
- {prettytable-0.6.1 → prettytable-0.7.2}/prettytable.py +590 -187
- {prettytable-0.6.1 → prettytable-0.7.2}/prettytable_test.py +173 -24
- {prettytable-0.6.1 → prettytable-0.7.2}/setup.py +2 -0
- {prettytable-0.6.1 → prettytable-0.7.2}/MANIFEST.in +0 -0
- {prettytable-0.6.1 → prettytable-0.7.2}/prettytable.egg-info/SOURCES.txt +0 -0
- {prettytable-0.6.1 → prettytable-0.7.2}/prettytable.egg-info/dependency_links.txt +0 -0
- {prettytable-0.6.1 → prettytable-0.7.2}/prettytable.egg-info/top_level.txt +0 -0
- {prettytable-0.6.1 → prettytable-0.7.2}/setup.cfg +0 -0
|
@@ -1,15 +1,31 @@
|
|
|
1
|
-
########## PrettyTable 0.
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
########## PrettyTable 0.7 - Feb 17, 2013 ###########
|
|
2
|
+
|
|
3
|
+
* Improved Python 2 and 3 compatibility (2.4-3.2).
|
|
4
|
+
* Improved support for non-Latin characters. Table widths should
|
|
5
|
+
now be calculated correctly for tables with e.g. Japanese text.
|
|
6
|
+
* Table contents can now be read in from a .csv file
|
|
7
|
+
* Table contents can now be read in from a DB-API compatible cursor
|
|
8
|
+
* Table contents can now be read in from a string containing a
|
|
9
|
+
HTML table (thanks to Christoph Robbert for submitting this patch!)
|
|
10
|
+
* new valign attribute controls vertical alignment of text when
|
|
11
|
+
some cells in a row have multiple lines of text and others don't.
|
|
12
|
+
(thanks to Google Code user maartendb for submitting this patch!)
|
|
13
|
+
* hrules attribute can now be set to HEADER, which draws a rule only
|
|
14
|
+
under the header row
|
|
15
|
+
* new vrules attribute controls drawing of vertical rules and can
|
|
16
|
+
be set to FRAME, ALL or NONE
|
|
17
|
+
* new header_style attribute controls formatting of text in table
|
|
18
|
+
headers and can be set to "cap", "title", "upper", "lower" or None
|
|
19
|
+
* Fixed a simple bug regarding validation of max_width (thanks to
|
|
20
|
+
Anthony Toole for pointing out this bug and providing a patch).
|
|
21
|
+
* Fixed a simple bug regarding initialisation of int_format value
|
|
22
|
+
for new tables (thanks to Ingo Schmiegel for pointing out this
|
|
23
|
+
bug!)
|
|
24
|
+
* Fixed a bug regarding some constructor keywords, such as "border",
|
|
25
|
+
being ignored (thanks to Google Code user antonio.s.messina for
|
|
26
|
+
reporting this bug).
|
|
27
|
+
|
|
28
|
+
########## PrettyTable 0.6 - May 5, 2012 ##########
|
|
13
29
|
|
|
14
30
|
* Code is now simultaneously compatible with Python 2 and 3
|
|
15
31
|
* Replaced all setter methods with managed attributes
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
# Copyright (c) 2009-
|
|
1
|
+
# Copyright (c) 2009-2013 Luke Maurits <luke@maurits.id.au>
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
# With contributions from:
|
|
4
4
|
# * Chris Clark
|
|
5
|
+
# * Christoph Robbert
|
|
5
6
|
# * Klein Stephane
|
|
7
|
+
# * "maartendb"
|
|
6
8
|
#
|
|
7
9
|
# Redistribution and use in source and binary forms, with or without
|
|
8
10
|
# modification, are permitted provided that the following conditions are met:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 1.0
|
|
2
2
|
Name: prettytable
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: A simple Python library for easily displaying tabular data in a visually appealing ASCII table format
|
|
5
5
|
Home-page: http://code.google.com/p/prettytable
|
|
6
6
|
Author: Luke Maurits
|
|
@@ -9,6 +9,8 @@ License: BSD (3 clause)
|
|
|
9
9
|
Description: UNKNOWN
|
|
10
10
|
Platform: UNKNOWN
|
|
11
11
|
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 2.4
|
|
13
|
+
Classifier: Programming Language :: Python :: 2.5
|
|
12
14
|
Classifier: Programming Language :: Python :: 2.6
|
|
13
15
|
Classifier: Programming Language :: Python :: 2.7
|
|
14
16
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
TUTORIAL ON HOW TO USE THE PRETTYTABLE 0.6 API
|
|
1
|
+
TUTORIAL ON HOW TO USE THE PRETTYTABLE 0.6+ API
|
|
2
2
|
|
|
3
3
|
*** This tutorial is distributed with PrettyTable and is meant to serve
|
|
4
4
|
as a "quick start" guide for the lazy or impatient. It is not an
|
|
@@ -13,15 +13,15 @@ Let's suppose you have a shiny new PrettyTable:
|
|
|
13
13
|
from prettytable import PrettyTable
|
|
14
14
|
x = PrettyTable()
|
|
15
15
|
|
|
16
|
-
and you want to put some data into it. You have
|
|
16
|
+
and you want to put some data into it. You have a few options.
|
|
17
17
|
|
|
18
18
|
== Row by row ==
|
|
19
19
|
|
|
20
|
-
You can add data one row at a time. To do this you
|
|
21
|
-
first using the `
|
|
20
|
+
You can add data one row at a time. To do this you can set the field names
|
|
21
|
+
first using the `field_names` attribute, and then add the rows one at a time
|
|
22
22
|
using the `add_row` method:
|
|
23
23
|
|
|
24
|
-
x.
|
|
24
|
+
x.field_names = ["City name", "Area", "Population", "Annual Rainfall"]
|
|
25
25
|
x.add_row(["Adelaide",1295, 1158259, 600.5])
|
|
26
26
|
x.add_row(["Brisbane",5905, 1857594, 1146.4])
|
|
27
27
|
x.add_row(["Darwin", 112, 120900, 1714.7])
|
|
@@ -54,6 +54,39 @@ nicely as if you'd done it using just one of the two approaches. Tables built
|
|
|
54
54
|
this way are kind of confusing for other people to read, though, so don't do
|
|
55
55
|
this unless you have a good reason.
|
|
56
56
|
|
|
57
|
+
== Importing data from a CSV file ==
|
|
58
|
+
|
|
59
|
+
If you have your table data in a comma separated values file (.csv), you can
|
|
60
|
+
read this data into a PrettyTable like this:
|
|
61
|
+
|
|
62
|
+
from prettytable import from_csv
|
|
63
|
+
fp = open("myfile.csv", "r")
|
|
64
|
+
mytable = from_csv(fp)
|
|
65
|
+
fp.close()
|
|
66
|
+
|
|
67
|
+
== Importing data from a HTML string ==
|
|
68
|
+
|
|
69
|
+
If you have a string containing a HTML <table>, you can read this data into a
|
|
70
|
+
PrettyTable like this:
|
|
71
|
+
|
|
72
|
+
from prettytable import from_html
|
|
73
|
+
mytable = from_html(html_string)
|
|
74
|
+
|
|
75
|
+
== Importing data from a database cursor ==
|
|
76
|
+
|
|
77
|
+
If you have your table data in a database which you can access using a library
|
|
78
|
+
which confirms to the Python DB-API (e.g. an SQLite database accessible using
|
|
79
|
+
the sqlite module), then you can build a PrettyTable using a cursor object,
|
|
80
|
+
like this:
|
|
81
|
+
|
|
82
|
+
import sqlite3
|
|
83
|
+
from prettytable import from_db_cursor
|
|
84
|
+
|
|
85
|
+
connection = sqlite3.connect("mydb.db")
|
|
86
|
+
cursor = connection.cursor()
|
|
87
|
+
cursor.execute("SELECT field1, field2, field3 FROM my_table")
|
|
88
|
+
mytable = from_db_cursor(cursor)
|
|
89
|
+
|
|
57
90
|
== Getting data out ==
|
|
58
91
|
|
|
59
92
|
There are three ways to get data out of a PrettyTable, in increasing order of
|
|
@@ -99,8 +132,9 @@ print(x)
|
|
|
99
132
|
|
|
100
133
|
in Python 3.x.
|
|
101
134
|
|
|
102
|
-
The old x.printt() method from versions 0.5 and earlier has been removed.
|
|
103
|
-
|
|
135
|
+
The old x.printt() method from versions 0.5 and earlier has been removed.
|
|
136
|
+
|
|
137
|
+
To pass options changing the look of the table, use the get_string() method
|
|
104
138
|
documented below:
|
|
105
139
|
|
|
106
140
|
print x.get_string()
|
|
@@ -314,9 +348,11 @@ The options are these:
|
|
|
314
348
|
or not the first row of the table is a header showing the names of all the
|
|
315
349
|
fields.
|
|
316
350
|
* `hrules` - Controls printing of horizontal rules after rows. Allowed
|
|
317
|
-
values: FRAME, ALL, NONE - note that these are variables defined
|
|
318
|
-
`prettytable` module so make sure you import them or use
|
|
319
|
-
etc.
|
|
351
|
+
values: FRAME, HEADER, ALL, NONE - note that these are variables defined
|
|
352
|
+
inside the `prettytable` module so make sure you import them or use
|
|
353
|
+
`prettytable.FRAME` etc.
|
|
354
|
+
* `vrules` - Controls printing of vertical rules between columns. Allowed
|
|
355
|
+
values: FRAME, ALL, NONE.
|
|
320
356
|
* `int_format` - A string which controls the way integer data is printed.
|
|
321
357
|
This works like: print "%<int_format>d" % data
|
|
322
358
|
* `float_format` - A string which controls the way floating point data is
|
|
@@ -390,7 +426,7 @@ exactly the same way as ASCII printing.
|
|
|
390
426
|
By default, PrettyTable outputs HTML for "vanilla" tables. The HTML code is
|
|
391
427
|
quite simple. It looks like this:
|
|
392
428
|
|
|
393
|
-
<table
|
|
429
|
+
<table>
|
|
394
430
|
<tr>
|
|
395
431
|
<th>City name</th>
|
|
396
432
|
<th>Area</th>
|
|
@@ -437,7 +473,7 @@ x.print_html(attributes={"name":"my_table", "class":"red_table"})
|
|
|
437
473
|
|
|
438
474
|
will print:
|
|
439
475
|
|
|
440
|
-
<table
|
|
476
|
+
<table name="my_table" class="red_table">
|
|
441
477
|
<tr>
|
|
442
478
|
<th>City name</th>
|
|
443
479
|
<th>Area</th>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 1.0
|
|
2
2
|
Name: prettytable
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: A simple Python library for easily displaying tabular data in a visually appealing ASCII table format
|
|
5
5
|
Home-page: http://code.google.com/p/prettytable
|
|
6
6
|
Author: Luke Maurits
|
|
@@ -9,6 +9,8 @@ License: BSD (3 clause)
|
|
|
9
9
|
Description: UNKNOWN
|
|
10
10
|
Platform: UNKNOWN
|
|
11
11
|
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 2.4
|
|
13
|
+
Classifier: Programming Language :: Python :: 2.5
|
|
12
14
|
Classifier: Programming Language :: Python :: 2.6
|
|
13
15
|
Classifier: Programming Language :: Python :: 2.7
|
|
14
16
|
Classifier: Programming Language :: Python :: 3
|