prettytable 0.2__py2.6.egg → 0.2.1__py2.6.egg

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.
Files changed (3) hide show
  1. EGG-INFO/PKG-INFO +1 -1
  2. prettytable.py +19 -7
  3. prettytable.pyc +0 -0
EGG-INFO/PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: prettytable
3
- Version: 0.2
3
+ Version: 0.2.1
4
4
  Summary: A simple Python library for easily displaying tabular data in a visually appealing ASCII table format
5
5
  Home-page: http://www.luke.maurits.id.au/software/prettytable
6
6
  Author: Luke Maurits
prettytable.py CHANGED
@@ -1,4 +1,4 @@
1
- # PrettyTable 0.2
1
+ # PrettyTable 0.2.1
2
2
  # Copyright (c) 2009, Luke Maurits <luke@maurits.id.au>
3
3
  # All rights reserved.
4
4
  #
@@ -26,6 +26,8 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  import copy
29
+ import cPickle
30
+ import sys
29
31
 
30
32
  class PrettyTable:
31
33
 
@@ -125,9 +127,8 @@ class PrettyTable:
125
127
  end - index of last data row to include in output PLUS ONE (list slice style)"""
126
128
 
127
129
  if self.caching:
128
- key = (start, end, fields, hrules)
130
+ key = cPickle.dumps((start, end, fields, hrules))
129
131
  if key in self.cache:
130
- print "Using cache!"
131
132
  return self.cache[key]
132
133
 
133
134
  bits = []
@@ -138,7 +139,7 @@ class PrettyTable:
138
139
  for row in self.rows[start:end]:
139
140
  bits.append(self._stringify_row(row, fields, hrule))
140
141
  if not hrule:
141
- bits.append(self._stringify_hrule())
142
+ bits.append(self._stringify_hrule(fields))
142
143
  string = "\n".join(bits)
143
144
 
144
145
  if self.caching:
@@ -168,7 +169,7 @@ class PrettyTable:
168
169
 
169
170
  def _stringify_header(self, fields=None):
170
171
 
171
- bits = [self._stringify_hrule()]
172
+ bits = [self._stringify_hrule(fields)]
172
173
  bits.append("\n")
173
174
  bits.append("|")
174
175
  for field, width in zip(self.fields, self.widths):
@@ -177,7 +178,7 @@ class PrettyTable:
177
178
  bits.append(field.center(width+2))
178
179
  bits.append("|")
179
180
  bits.append("\n")
180
- bits.append(self._stringify_hrule())
181
+ bits.append(self._stringify_hrule(fields))
181
182
  return "".join(bits)
182
183
 
183
184
  def _stringify_row(self, row, fields, hrule):
@@ -193,7 +194,8 @@ class PrettyTable:
193
194
  bits.append(str(value).center(width+2))
194
195
  bits.append("|")
195
196
  if hrule:
196
- bits.append(self._stringify_hrule())
197
+ bits.append("\n")
198
+ bits.append(self._stringify_hrule(fields))
197
199
  return "".join(bits)
198
200
 
199
201
  def main():
@@ -209,5 +211,15 @@ def main():
209
211
  x.add_row(["Perth", 5386, 1554769, 869.4])
210
212
  print x
211
213
 
214
+ if len(sys.argv) > 1 and sys.argv[1] == "test":
215
+ print "Testing field subset selection:"
216
+ x.printt(fields=["City name","Population"])
217
+ print "Testing row subset selection:"
218
+ x.printt(start=2, end=5)
219
+ print "Testing inter-line hrules:"
220
+ x.printt(hrules=True)
221
+ print "Testing everything at once:"
222
+ x.printt(start=2, end=5, fields=["City name","Population"], hrules=True)
223
+
212
224
  if __name__ == "__main__":
213
225
  main()
prettytable.pyc CHANGED
Binary file