Closed rtulke closed 9 years ago
Hmm, I'm having trouble reproducing the problem. If you were using terminaltables together with colorclass then I fixed a unicode problem with that library earlier today. However I didn't change any of terminaltables' code and it seems to be working for me:
from terminaltables import AsciiTable
table_data = [
['Name', 'Color', 'Type'],
['Avocado', 'green', 'nut'],
[u'Cupuaçu', 'yellow', 'fruit'],
[u'äöüß', '', 'neither'],
]
table = AsciiTable(table_data, 'Foods')
print table.table
+Foods----+--------+---------+
| Name | Color | Type |
+---------+--------+---------+
| Avocado | green | nut |
| Cupuaçu | yellow | fruit |
| äöüß | | neither |
+---------+--------+---------+
Can you tell me the problem you were seeing, pasting the output? If you can, also provide example code so I may try to reproduce it on my machine.
Hmm i used the terminaltables version from pip under Mac OS X 10.10.1 Python 2.7.8
from ConfigParser import SafeConfigParser
from terminaltables import AsciiTable
parser = SafeConfigParser()
parser.read('my.conf')
table_data = [['id', 'repository', 'url', 'description', 'location']]
count = 0
for section_name in parser.sections():
count = count + 1
id = str(count)
description = parser.get(section_name, 'description')
url = parser.get(section_name, 'url')
location = parser.get(section_name, 'location')
table_data.append([id, section_name, url, description, location])
table = AsciiTable(table_data)
table.outer_border = False
table.inner_column_border = False
table.inner_row_border = False
table.inner_heading_row_border = Fals = False
print table.table
my.conf
[bug_tracker]
description = alles über bugtracker
url = http://localhost:8080/bugs/
location = /home/repo/bug_tracker
username = dhellmann
password = SECRET
[wiki]
description = foo bar bla
location = /home/repo/wiki
url = http://localhost:8080/wiki/
username = dhellmann
password = SECRET
a :D it works with u'fööö' :-)
Your code seems to work fine on my OS X 10.9.5 with 2.7.6. The table was aligned properly.
[tw-mbp ~]$ virtualenv ~/virtualenvs/test_tt
New python executable in /Users/me/virtualenvs/test_tt/bin/python2.7
Also creating executable in /Users/me/virtualenvs/test_tt/bin/python
Installing setuptools, pip...done.
[tw-mbp ~]$ . ~/virtualenvs/test_tt/bin/activate
(test_tt)[tw-mbp ~]$ pip freeze
wsgiref==0.1.2
(test_tt)[tw-mbp ~]$ pip install terminaltables
Downloading/unpacking terminaltables
Downloading terminaltables-1.1.1.tar.gz
Running setup.py (path:/Users/me/virtualenvs/test_tt/build/terminaltables/setup.py) egg_info for package terminaltables
Installing collected packages: terminaltables
Running setup.py install for terminaltables
Successfully installed terminaltables
Cleaning up...
(test_tt)[tw-mbp ~]$ pip freeze
terminaltables==1.1.1
wsgiref==0.1.2
(test_tt)[tw-mbp ~]$ cat my.conf
[bug_tracker]
description = alles über bugtracker
url = http://localhost:8080/bugs/
location = /home/repo/bug_tracker
username = dhellmann
password = SECRET
[wiki]
description = foo bar bla
location = /home/repo/wiki
url = http://localhost:8080/wiki/
username = dhellmann
password = SECRET
(test_tt)[tw-mbp ~]$ python my.py
id repository url description location
1 bug_tracker http://localhost:8080/bugs/ alles über bugtracker /home/repo/bug_tracker
2 wiki http://localhost:8080/wiki/ foo bar bla /home/repo/wiki
(test_tt)[tw-mbp ~]$ python -V
Python 2.7.6
mh my misstake i forgot the u' infront the umlaut thx!
Ah cool, no worries.
After a long time ....
sorry but i try to test your code ... and i see in your code has the same broken table :) please enable table frame ( table.outer_border = False, table.inner_column_border = True, table.inner_row_border = False, table.inner_heading_row_border = True) and than you will see the broken table it is one char ...
Still works fine for me. Can you post a screen shot?
Sorry here is my Screenshot i forgot!
in the first column id: (15 and 16) is an umlaut "ü" in second column and it seems like the break in my table
I tested terminaltables with umlauts and i get an broken table.