Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[125b23]: doc / accents2table.py Maximize Restore History

Download this file

accents2table.py    44 lines (35 with data), 932 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
"""
Generates reStructuredText table from accents.txt file
for inclusion in the users' guide.
$Id$
"""
import sys
HEADER = """\
.. This table generated by ``accents2table.py``.
========= ============
Character Abbreviation
========= ============"""
ROW_SEP = """\
--------- ------------"""
FOOTER = """\
========= ============"""
def accents2table(accents_file):
lines = file(accents_file).readlines()
# trim lines
lines = map(lambda x: x.strip(), lines)
# toss empty
lines = filter(None,lines)
# remove comments
lines = filter(lambda x: x[0] != '#',lines)
# print table
print HEADER
for i,line in enumerate(lines):
char,abbr = line.split('\t')
abbr = abbr.replace('`','\\`')
if i > 0:
print ROW_SEP
print char + (' ' * (10-len(char))) + abbr
print FOOTER
if __name__ == '__main__':
accents2table(sys.argv[1])