Classes | Functions | Variables
translator Namespace Reference

Classes

class  Transl
 
class  TrManager
 

Functions

def xopen (fname, mode='r', encoding='utf-8-sig')
 
def fill (s)
 

Variables

 major
 
 minor
 
 patch
 
 trMan = TrManager()
 

Detailed Description

Script to generate reports on translator classes from Doxygen sources.

  The main purpose of the script is to extract the information from sources
  related to internationalization (the translator classes). It uses the
  information to generate documentation (language.doc,
  translator_report.txt) from templates (language.tpl, maintainers.txt).

  Simply run the script without parameters to get the reports and
  documentation for all supported languages. If you want to generate the
  translator report only for some languages, pass their codes as arguments
  to the script. In that case, the language.doc will not be generated.
  Example:

    python translator.py en nl cz

  Originally, the script was written in Perl and was known as translator.pl.
  The last Perl version was dated 2002/05/21 (plus some later corrections)

                             Petr Prikryl (prikryl at atlas dot cz)

  History:
  --------
  2002/05/21 - This was the last Perl version.
  2003/05/16 - List of language marks can be passed as arguments.
  2004/01/24 - Total reimplementation started: classes TrManager, and Transl.
  2004/02/05 - First version that produces translator report. No language.doc yet.
  2004/02/10 - First fully functional version that generates both the translator
   report and the documentation. It is a bit slower than the
   Perl version, but is much less tricky and much more flexible.
   It also solves some problems that were not solved by the Perl
   version. The translator report content should be more useful
   for developers.
  2004/02/11 - Some tuning-up to provide more useful information.
  2004/04/16 - Added new tokens to the tokenizer (to remove some warnings).
  2004/05/25 - Added from __future__ import generators not to force Python 2.3.
  2004/06/03 - Removed dependency on textwrap module.
  2004/07/07 - Fixed the bug in the fill() function.
  2004/07/21 - Better e-mail mangling for HTML part of language.doc.
 - Plural not used for reporting a single missing method.
 - Removal of not used translator adapters is suggested only
   when the report is not restricted to selected languages
   explicitly via script arguments.
  2004/07/26 - Better reporting of not-needed adapters.
  2004/10/04 - Reporting of not called translator methods added.
  2004/10/05 - Modified to check only doxygen/src sources for the previous report.
  2005/02/28 - Slight modification to generate "mailto.txt" auxiliary file.
  2005/08/15 - Doxygen's root directory determined primarily from DOXYGEN
   environment variable. When not found, then relatively to the script.
  2007/03/20 - The "translate me!" searched in comments and reported if found.
  2008/06/09 - Warning when the MAX_DOT_GRAPH_HEIGHT is still part of trLegendDocs().
  2009/05/09 - Changed HTML output to fit it with XHTML DTD
  2009/09/02 - Added percentage info to the report (implemented / to be implemented).
  2010/02/09 - Added checking/suggestion 'Reimplementation using UTF-8 suggested.
  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
  2010/08/30 - Highlighting in what will be the table in langhowto.html modified.
  2010/09/27 - The underscore in \latexonly part of the generated language.doc
   was prefixed by backslash (was LaTeX related error).
  2013/02/19 - Better diagnostics when translator_xx.h is too crippled.
  2013/06/25 - TranslatorDecoder checks removed after removing the class.
  2013/09/04 - Coloured status in langhowto. *ALMOST up-to-date* category
   of translators introduced.
  2014/06/16 - unified for Python 2.6+ and 3.0+

Function Documentation

def translator.fill (   s)
Returns string formated to the wrapped paragraph multiline string.

Replaces whitespaces by one space and then uses he textwrap.fill().

Definition at line 93 of file translator.py.

93 def fill(s):
94  """Returns string formated to the wrapped paragraph multiline string.
95 
96  Replaces whitespaces by one space and then uses he textwrap.fill()."""
97 
98  # Replace all whitespace by spaces, remove whitespaces that are not
99  # necessary, strip the left and right whitespaces, and break the string
100  # to list of words.
101  rexWS = re.compile(r'\s+')
102  lst = rexWS.sub(' ', s).strip().split()
103 
104  # If the list is not empty, put the words together and form the lines
105  # of maximum 70 characters. Build the list of lines.
106  lines = []
107  if lst:
108  line = lst.pop(0) # no separation space in front of the first word
109  for word in lst:
110  if len(line) + len(word) < 70:
111  line += ' ' + word
112  else:
113  lines.append(line) # another full line formed
114  line = word # next line started
115  lines.append(line) # the last line
116  return '\n'.join(lines)
117 
118 
def fill(s)
Definition: translator.py:93
void split(std::string const &s, char c, OutIter dest)
Definition: split.h:35
def translator.xopen (   fname,
  mode = 'r',
  encoding = 'utf-8-sig' 
)
Unified file opening for Python 2 an Python 3.

Python 2 does not have the encoding argument. Python 3 has one, and
the default 'utf-8-sig' is used (skips the BOM automatically).

Definition at line 79 of file translator.py.

79 def xopen(fname, mode='r', encoding='utf-8-sig'):
80  '''Unified file opening for Python 2 an Python 3.
81 
82  Python 2 does not have the encoding argument. Python 3 has one, and
83  the default 'utf-8-sig' is used (skips the BOM automatically).
84  '''
85 
86  major, minor, patch = (int(e) for e in platform.python_version_tuple())
87  if major == 2:
88  return open(fname, mode=mode) # Python 2 without encoding
89  else:
90  return open(fname, mode=mode, encoding=encoding) # Python 3 with encoding
91 
92 
def xopen(fname, mode='r', encoding='utf-8-sig')
Definition: translator.py:79
int open(const char *, int)
Opens a file descriptor.

Variable Documentation

translator.major

Definition at line 1993 of file translator.py.

translator.minor

Definition at line 1993 of file translator.py.

translator.patch

Definition at line 1993 of file translator.py.

translator.trMan = TrManager()

Definition at line 2000 of file translator.py.