prettytable 0.6.1__tar.bz2 → 0.7.2__tar.bz2

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.
@@ -1,15 +1,31 @@
1
- ########## PrettyTable 0.6.1 - June 03, 2012 ##########
2
-
3
- * Unicode encoding scheme can now be set by user
4
- * __str__ now uses user-specified encoding instead of ASCII. This
5
- fixes a bug where tables with non-ASCII characters would print
6
- correctly with "print x.get_string()" but not "print x" in 2.x
7
- (thanks to Google Code user kevincobain2000 for reporting this
8
- bug!)
9
- * Fixed an incompatibility with 3.0 and 3.1 (html.escape was new
10
- in 3.2)
11
-
12
- ########## PrettyTable 0.6 - April 05, 2012 ##########
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-2012 Luke Maurits <luke@maurits.id.au>
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.6.1
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 two (sane) options
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 need to set the field names
21
- first using the `set_field_names` method, and then add the rows one at a time
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.set_field_names(["City name", "Area", "Population", "Annual Rainfall"])
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. To
103
- pass options changing the look of the table, use the get_string() method
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 inside the
318
- `prettytable` module so make sure you import them or use `prettytable.FRAME`
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 border="1">
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 border="1" name="my_table" class="red_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.6.1
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