summaryrefslogtreecommitdiffstats
path: root/doc/translator.py
diff options
context:
space:
mode:
Diffstat (limited to 'doc/translator.py')
-rw-r--r--doc/translator.py113
1 files changed, 53 insertions, 60 deletions
diff --git a/doc/translator.py b/doc/translator.py
index 14f8c3c..995f910 100644
--- a/doc/translator.py
+++ b/doc/translator.py
@@ -56,10 +56,16 @@
2010/03/03 - Added [unreachable] prefix used in maintainers.txt.
2010/05/28 - BOM skipped; minor code cleaning.
2010/05/31 - e-mail mangled already in maintainers.txt
+ 2010/08/20 - maintainers.txt to UTF-8, related processin of unicode strings
+ - [any mark] introduced instead of [unreachable] only
+ - marks hihglighted in HTML
"""
from __future__ import generators
-import os, re, sys
+import codecs
+import os
+import re
+import sys
def fill(s):
@@ -1535,10 +1541,10 @@ class TrManager:
"""Returns the list of maintainer emails.
The method returns the list of e-mail adresses for the translator
- class, but only the addresses that were not marked as [unreachable]."""
+ class, but only the addresses that were not marked as [xxx]."""
lst = []
for m in self.__maintainersDic[classId]:
- if not m[1].startswith('[unreachable]'):
+ if not m[1].startswith('['):
email = m[1]
email = email.replace(' at ', '@') # Unmangle the mangled e-mail
email = email.replace(' dot ', '.')
@@ -1737,7 +1743,7 @@ class TrManager:
self.lastModificationTime = tim
# Process the content of the maintainers file.
- f = open(fname)
+ f = codecs.open(fname, 'r', 'utf-8')
inside = False # inside the record for the language
lineReady = True
classId = None
@@ -1748,18 +1754,18 @@ class TrManager:
lineReady = line != '' # when eof, then line == ''
line = line.strip() # eof should also behave as separator
- if line != '' and line[0] == '%': # skip the comment line
+ if line != u'' and line[0] == u'%': # skip the comment line
continue
if not inside: # if outside of the record
- if line != '': # should be language identifier
+ if line != u'': # should be language identifier
classId = line
maintainersLst = []
inside = True
# Otherwise skip empty line that do not act as separator.
else: # if inside the record
- if line == '': # separator found
+ if line == u'': # separator found
inside = False
else:
# If it is the first maintainer, create the empty list.
@@ -1767,9 +1773,9 @@ class TrManager:
self.__maintainersDic[classId] = []
# Split the information about the maintainer and append
- # the tuple. The address may be prefixed '[unreachable]'.
- # This will be processed later.
- lst = line.split(':', 1)
+ # the tuple. The address may be prefixed '[unreachable]'
+ # or whatever '[xxx]'. This will be processed later.
+ lst = line.split(u':', 1)
assert(len(lst) == 2)
t = (lst[0].strip(), lst[1].strip())
self.__maintainersDic[classId].append(t)
@@ -1801,32 +1807,33 @@ class TrManager:
#
# Read the template of the documentation, and remove the first
# attention lines.
- f = open(fTplName)
- line = f.readline()
- while line[0] != '/':
- line = f.readline()
- doctpl = line + f.read()
+ f = codecs.open(fTplName, 'r', 'utf-8')
+ doctpl = f.read()
f.close()
+ pos = doctpl.find(u'/***')
+ assert pos != -1
+ doctpl = doctpl[pos:]
+
# Fill the tplDic by symbols that will be inserted into the
# document template.
tplDic = {}
- s = 'Do not edit this file. It was generated by the %s script.' % self.script_name
+ s = u'Do not edit this file. It was generated by the %s script.' % self.script_name
tplDic['editnote'] = s
tplDic['doxVersion'] = self.doxVersion
tplDic['supportedLangReadableStr'] = self.supportedLangReadableStr
tplDic['translatorReportFileName'] = self.translatorReportFileName
- ahref = '<a href="../doc/' + self.translatorReportFileName
- ahref += '"\n><code>doxygen/doc/' + self.translatorReportFileName
- ahref += '</code></a>'
+ ahref = u'<a href="../doc/' + self.translatorReportFileName
+ ahref += u'"\n><code>doxygen/doc/' + self.translatorReportFileName
+ ahref += u'</code></a>'
tplDic['translatorReportLink'] = ahref
tplDic['numLangStr'] = str(self.numLang)
# Define templates for HTML table parts of the documentation.
- htmlTableTpl = '''\
+ htmlTableTpl = u'''\
\\htmlonly
<table align="center" cellspacing="0" cellpadding="0" border="0">
<tr bgcolor="#000000">
@@ -1849,8 +1856,8 @@ class TrManager:
\\endhtmlonly
'''
htmlTableTpl = dedent(htmlTableTpl)
- htmlTrTpl = '\n <tr bgcolor="#ffffff">%s\n </tr>'
- htmlTdTpl = '\n <td>%s</td>'
+ htmlTrTpl = u'\n <tr bgcolor="#ffffff">%s\n </tr>'
+ htmlTdTpl = u'\n <td>%s</td>'
# Loop through transl objects in the order of sorted readable names
# and add generate the content of the HTML table.
@@ -1871,28 +1878,26 @@ class TrManager:
classId = obj.classId[:-2]
if self.__translDic.has_key(classId):
lang = self.__translDic[classId].langReadable
- mm = 'see the %s language' % lang
- ee = '&nbsp;'
+ mm = u'see the %s language' % lang
+ ee = u'&nbsp;'
if not mm and self.__maintainersDic.has_key(obj.classId):
lm = [ m[0] for m in self.__maintainersDic[obj.classId] ]
- mm = '<br/>'.join(lm)
+ mm = u'<br/>'.join(lm)
- # Unreachable adresses will not be displayed at all.
+ # The marked adresses (they start with the mark '[unreachable]',
+ # '[resigned]', whatever '[xxx]') will not be displayed at all.
+ # Only the mark will be used instead.
+ rexMark = re.compile(ur'(?P<mark>\[.*?\])')
le = []
- for m in self.__maintainersDic[obj.classId]:
- address = m[1]
- if address.startswith('[unreachable]'):
- address = '[unreachable]'
+ for maintainer in self.__maintainersDic[obj.classId]:
+ address = maintainer[1]
+ m = rexMark.search(address)
+ if m is not None:
+ address = u'<span style="color: red; background-color: yellow">'\
+ + m.group(u'mark') + u'</span>'
le.append(address)
- ee = '<br/>'.join(le)
-
- # Replace the entity references.
- if mm:
- mm = mm.replace('&ccaron;', '&#x010d;')
- mm = mm.replace('&rcaron;', '&#x0159;')
- mm = mm.replace('&scaron;', '&#x0161;')
- mm = mm.replace('&zcaron;', '&#x017e;')
+ ee = u'<br/>'.join(le)
# Append the maintainer and e-mail elements.
lst.append(htmlTdTpl % mm)
@@ -1908,7 +1913,7 @@ class TrManager:
htmlTable = htmlTableTpl % (''.join(trlst))
# Define templates for LaTeX table parts of the documentation.
- latexTableTpl = r'''
+ latexTableTpl = ur'''
\latexonly
\footnotesize
\begin{longtable}{|l|l|l|l|}
@@ -1922,7 +1927,7 @@ class TrManager:
\endlatexonly
'''
latexTableTpl = dedent(latexTableTpl)
- latexLineTpl = '\n' + r' %s & %s & {\tt\tiny %s} & %s \\'
+ latexLineTpl = u'\n' + r' %s & %s & {\tt\tiny %s} & %s \\'
# Loop through transl objects in the order of sorted readable names
# and add generate the content of the LaTeX table.
@@ -1944,8 +1949,8 @@ class TrManager:
classId = obj.classId[:-2]
if self.__translDic.has_key(classId):
langNE = self.__translDic[classId].langReadable
- maintainer = 'see the %s language' % langNE
- email = '~'
+ maintainer = u'see the %s language' % langNE
+ email = u'~'
if not maintainer and self.__maintainersDic.has_key(obj.classId):
lm = [ m[0] for m in self.__maintainersDic[obj.classId] ]
@@ -1956,38 +1961,26 @@ class TrManager:
# Use the template to produce the line of the table and insert
# the hline plus the constructed line into the table content.
- trlst.append('\n \\hline')
+ trlst.append(u'\n \\hline')
trlst.append(latexLineTpl % (lang, maintainer, email, status))
# List the other maintainers for the language. Do not set
# lang and status for them.
- lang = '~'
- status = '~'
+ lang = u'~'
+ status = u'~'
for m in maintainers[1:]:
maintainer = m[0]
email = m[1]
trlst.append(latexLineTpl % (lang, maintainer, email, status))
# Join the table lines and insert into the template.
- latexTable = latexTableTpl % (''.join(trlst))
+ latexTable = latexTableTpl % (u''.join(trlst))
- # Do the LaTeX replacements.
- latexTable = latexTable.replace('&aacute;', "\\'{a}")
- latexTable = latexTable.replace('&Aacute;', "\\'{A}")
- latexTable = latexTable.replace('&auml;', '\\"{a}')
- latexTable = latexTable.replace('&ouml;', '\\"{o}')
- latexTable = latexTable.replace('&oslash;', '\\o{}')
- latexTable = latexTable.replace('&ccaron;', '\\v{c}')
- latexTable = latexTable.replace('&rcaron;', '\\v{r}')
- latexTable = latexTable.replace('&scaron;', '\\v{s}')
- latexTable = latexTable.replace('&zcaron;', '\\v{z}')
- latexTable = latexTable.replace('_', '\\_')
-
# Put the HTML and LaTeX parts together and define the dic item.
- tplDic['informationTable'] = htmlTable + '\n' + latexTable
+ tplDic['informationTable'] = htmlTable + u'\n' + latexTable
# Insert the symbols into the document template and write it down.
- f = open(fDocName, 'w')
+ f = codecs.open(fDocName, 'w', 'utf-8')
f.write(doctpl % tplDic)
f.close()