summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluke@maurits.id.au <luke@maurits.id.au@0f58610c-415a-11de-9c03-5d6cfad8e937>2013-10-07 02:43:54 +0000
committerluke@maurits.id.au <luke@maurits.id.au@0f58610c-415a-11de-9c03-5d6cfad8e937>2013-10-07 02:43:54 +0000
commitc21c692d379a5916453be07b206507f791aa4fc0 (patch)
tree21e98eb5a6c185513fd5416e8f2c2fb7b9a3a03b
parentdb788bff0e2e487f0e2b1a218a85c9140d3da2bf (diff)
downloadpython-prettytable-c21c692d379a5916453be07b206507f791aa4fc0.tar.gz
Improvements to title generation, especially do not include spurious junction characters.
git-svn-id: http://prettytable.googlecode.com/svn/trunk@136 0f58610c-415a-11de-9c03-5d6cfad8e937
-rw-r--r--prettytable.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/prettytable.py b/prettytable.py
index 5c39288..d8adc06 100644
--- a/prettytable.py
+++ b/prettytable.py
@@ -1095,19 +1095,22 @@ class PrettyTable(object):
return "".join(bits)
def _stringify_title(self, title, options):
- lpad, rpad = self._get_padding_widths(options)
- lines = [self._hrule]
+
+ lines = []
+ if options["border"]:
+ if options["vrules"] == ALL:
+ options["vrules"] = FRAME
+ lines.append(self._stringify_hrule(options))
+ options["vrules"] = ALL
+ elif options["vrules"] == FRAME:
+ lines.append(self._stringify_hrule(options))
bits = []
- if options["vrules"] in (ALL, FRAME):
- bits.append(options["vertical_char"])
- else:
- bits.append(" ")
- bits.append(" " * lpad + self._justify(title, len(self._hrule)-2-lpad-rpad, "c") + " " * rpad)
- if options["vrules"] in (ALL, FRAME):
- bits.append(options["vertical_char"])
- else:
- bits.append(" ")
- return "".join(bits)
+ endpoint = options["vertical_char"] if options["vrules"] in (ALL, FRAME) else " "
+ bits.append(endpoint)
+ bits.append(self._justify(title, len(self._hrule)-2, "c"))
+ bits.append(endpoint)
+ lines.append("".join(bits))
+ return "\n".join(lines)
def _stringify_header(self, options):