Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
translator.TrManager Class Reference

Public Member Functions

def __init__ (self)
 
def getBgcolorByReadableStatus (self, readableStatus)
 
def generateTranslatorReport (self)
 
def generateLanguageDoc (self)
 

Public Attributes

 script
 
 script_name
 
 script_path
 
 doxy_path
 
 script_argLst
 
 doc_path
 
 src_path
 
 requiredMethodsDic
 
 adaptMethodsDic
 
 lastModificationTime
 
 translatorReportFileName
 
 maintainersFileName
 
 languageTplFileName
 
 languageDocFileName
 
 langLst
 
 supportedLangReadableStr
 
 numLang
 
 doxVersion
 
 upToDateIdLst
 
 EnBasedIdLst
 
 adaptIdLst
 

Private Member Functions

def __build (self)
 
def __extractProcessedInfo (self)
 
def __getNoTrSourceFilesLst (self)
 
def __removeUsedInFiles (self, fname, dic)
 
def __checkForNotUsedTrMethods (self)
 
def __emails (self, classId)
 
def __loadMaintainers (self)
 

Private Attributes

 __translDic
 
 __maintainersDic
 

Detailed Description

Collects basic info and builds subordinate Transl objects.

Definition at line 1204 of file translator.py.

Constructor & Destructor Documentation

def translator.TrManager.__init__ (   self)
Determines paths, creates and initializes structures.

The arguments of the script may explicitly say what languages should
be processed. Write the two letter identifications that are used
for composing the source filenames, so...

    python translator.py cz

this will process only translator_cz.h source.

Definition at line 1207 of file translator.py.

1207  def __init__(self):
1208  """Determines paths, creates and initializes structures.
1209 
1210  The arguments of the script may explicitly say what languages should
1211  be processed. Write the two letter identifications that are used
1212  for composing the source filenames, so...
1213 
1214  python translator.py cz
1215 
1216  this will process only translator_cz.h source.
1217  """
1218 
1219  # Determine the path to the script and its name.
1220  self.script = os.path.abspath(sys.argv[0])
1221  self.script_path, self.script_name = os.path.split(self.script)
1222  self.script_path = os.path.abspath(self.script_path)
1223 
1224  # Determine the absolute path to the Doxygen's root subdirectory.
1225  # If DOXYGEN environment variable is not found, the directory is
1226  # determined from the path of the script.
1227  doxy_default = os.path.join(self.script_path, '..')
1228  self.doxy_path = os.path.abspath(os.getenv('DOXYGEN', doxy_default))
1229 
1230  # Get the explicit arguments of the script.
1231  self.script_argLst = sys.argv[1:]
1232 
1233  # Build the path names based on the Doxygen's root knowledge.
1234  self.doc_path = os.path.join(self.doxy_path, 'doc')
1235  self.src_path = os.path.join(self.doxy_path, 'src')
1236 
1237  # Create the empty dictionary for Transl object identitied by the
1238  # class identifier of the translator.
1239  self.__translDic = {}
1240 
1241  # Create the None dictionary of required methods. The key is the
1242  # unified prototype, the value is the full prototype. Set inside
1243  # the self.__build().
1245 
1246  # Create the empty dictionary that says what method is implemented
1247  # by what adapter.
1249 
1250  # The last modification time will capture the modification of this
1251  # script, of the translator.h, of the translator_adapter.h (see the
1252  # self.__build() for the last two) of all the translator_xx.h files
1253  # and of the template for generating the documentation. So, this
1254  # time can be compared with modification time of the generated
1255  # documentation to decide, whether the doc should be re-generated.
1256  self.lastModificationTime = os.path.getmtime(self.script)
1257 
1258  # Set the names of the translator report text file, of the template
1259  # for generating "Internationalization" document, for the generated
1260  # file itself, and for the maintainers list.
1261  self.translatorReportFileName = 'translator_report.txt'
1262  self.maintainersFileName = 'maintainers.txt'
1263  self.languageTplFileName = 'language.tpl'
1264  self.languageDocFileName = 'language.doc'
1265 
1266  # The information about the maintainers will be stored
1267  # in the dictionary with the following name.
1268  self.__maintainersDic = None
1269 
1270  # Define the other used structures and variables for information.
1271  self.langLst = None # including English based
1272  self.supportedLangReadableStr = None # coupled En-based as a note
1273  self.numLang = None # excluding coupled En-based
1274  self.doxVersion = None # Doxygen version
1275 
1276  # Build objects where each one is responsible for one translator.
1277  self.__build()
1278 
1279 

Member Function Documentation

def translator.TrManager.__build (   self)
private
Find the translator files and build the objects for translators.

Definition at line 1280 of file translator.py.

1280  def __build(self):
1281  """Find the translator files and build the objects for translators."""
1282 
1283  # The translator.h must exist (the Transl object will check it),
1284  # create the object for it and let it build the dictionary of
1285  # required methods.
1286  tr = Transl(os.path.join(self.src_path, 'translator.h'), self)
1287  self.requiredMethodsDic = tr.collectPureVirtualPrototypes()
1288  tim = tr.getmtime()
1289  if tim > self.lastModificationTime:
1290  self.lastModificationTime = tim
1291 
1292  # The translator_adapter.h must exist (the Transl object will check it),
1293  # create the object for it and store the reference in the dictionary.
1294  tr = Transl(os.path.join(self.src_path, 'translator_adapter.h'), self)
1295  self.adaptMethodsDic = tr.collectAdapterPrototypes()
1296  tim = tr.getmtime()
1297  if tim > self.lastModificationTime:
1298  self.lastModificationTime = tim
1299 
1300  # Create the list of the filenames with language translator sources.
1301  # If the explicit arguments of the script were typed, process only
1302  # those files.
1303  if self.script_argLst:
1304  lst = ['translator_' + x + '.h' for x in self.script_argLst]
1305  for fname in lst:
1306  if not os.path.isfile(os.path.join(self.src_path, fname)):
1307  sys.stderr.write("\a\nFile '%s' not found!\n" % fname)
1308  sys.exit(1)
1309  else:
1310  lst = os.listdir(self.src_path)
1311  lst = [x for x in lst if x[:11] == 'translator_'
1312  and x[-2:] == '.h'
1313  and x != 'translator_adapter.h']
1314 
1315  # Build the object for the translator_xx.h files, and process the
1316  # content of the file. Then insert the object to the dictionary
1317  # accessed via classId.
1318  for fname in lst:
1319  fullname = os.path.join(self.src_path, fname)
1320  tr = Transl(fullname, self)
1321  tr.processing()
1322  assert(tr.classId != 'Translator')
1323  self.__translDic[tr.classId] = tr
1324 
1325  # Extract the global information of the processed info.
1326  self.__extractProcessedInfo()
1327 
1328 
def __extractProcessedInfo(self)
Definition: translator.py:1329
def translator.TrManager.__checkForNotUsedTrMethods (   self)
private
Returns the dictionary of not used translator methods.

The method can be called only after self.requiredMethodsDic has been
built. The stripped prototypes are the values, the method identifiers
are the keys.

Definition at line 1457 of file translator.py.

1458  """Returns the dictionary of not used translator methods.
1459 
1460  The method can be called only after self.requiredMethodsDic has been
1461  built. The stripped prototypes are the values, the method identifiers
1462  are the keys.
1463  """
1464  # Build the dictionary of the required method prototypes with
1465  # method identifiers used as keys.
1466  trdic = {}
1467  for prototype in list(self.requiredMethodsDic.keys()):
1468  ri = prototype.split('(')[0]
1469  identifier = ri.split()[1].strip()
1470  trdic[identifier] = prototype
1471 
1472  # Build the list of source files where translator method identifiers
1473  # can be used.
1474  files = self.__getNoTrSourceFilesLst()
1475 
1476  # Loop through the files and reduce the dictionary of id -> proto.
1477  for fname in files:
1478  self.__removeUsedInFiles(fname, trdic)
1479 
1480  # Return the dictionary of not used translator methods.
1481  return trdic
1482 
1483 
def __getNoTrSourceFilesLst(self)
Definition: translator.py:1409
def __checkForNotUsedTrMethods(self)
Definition: translator.py:1457
def __removeUsedInFiles(self, fname, dic)
Definition: translator.py:1431
def translator.TrManager.__emails (   self,
  classId 
)
private
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 [xxx].

Definition at line 1484 of file translator.py.

1484  def __emails(self, classId):
1485  """Returns the list of maintainer emails.
1486 
1487  The method returns the list of e-mail adresses for the translator
1488  class, but only the addresses that were not marked as [xxx]."""
1489  lst = []
1490  for m in self.__maintainersDic[classId]:
1491  if not m[1].startswith('['):
1492  email = m[1]
1493  email = email.replace(' at ', '@') # Unmangle the mangled e-mail
1494  email = email.replace(' dot ', '.')
1495  lst.append(email)
1496  return lst
1497 
1498 
def __emails(self, classId)
Definition: translator.py:1484
def translator.TrManager.__extractProcessedInfo (   self)
private
Build lists and strings of the processed info.

Definition at line 1329 of file translator.py.

1330  """Build lists and strings of the processed info."""
1331 
1332  # Build the auxiliary list with strings compound of the status,
1333  # readable form of the language, and classId.
1334  statLst = []
1335  for obj in list(self.__translDic.values()):
1336  assert(obj.classId != 'Translator')
1337  s = obj.status + '|' + obj.langReadable + '|' + obj.classId
1338  statLst.append(s)
1339 
1340  # Sort the list and extract the object identifiers (classId's) for
1341  # the up-to-date translators and English-based translators.
1342  statLst.sort()
1343  self.upToDateIdLst = [x.split('|')[2] for x in statLst if x[0] == '|']
1344  self.EnBasedIdLst = [x.split('|')[2] for x in statLst if x[:2] == 'En']
1345 
1346  # Reverse the list and extract the TranslatorAdapter based translators.
1347  statLst.reverse()
1348  self.adaptIdLst = [x.split('|')[2] for x in statLst if x[0].isdigit()]
1349 
1350  # Build the list of tuples that contain (langReadable, obj).
1351  # Sort it by readable name.
1352  self.langLst = []
1353  for obj in list(self.__translDic.values()):
1354  self.langLst.append((obj.langReadable, obj))
1355 
1356  self.langLst.sort(key=lambda x: x[0])
1357 
1358  # Create the list with readable language names. If the language has
1359  # also the English-based version, modify the item by appending
1360  # the note. Number of the supported languages is equal to the length
1361  # of the list.
1362  langReadableLst = []
1363  for name, obj in self.langLst:
1364  if obj.status == 'En': continue
1365 
1366  # Append the 'En' to the classId to possibly obtain the classId
1367  # of the English-based object. If the object exists, modify the
1368  # name for the readable list of supported languages.
1369  classIdEn = obj.classId + 'En'
1370  if classIdEn in self.__translDic:
1371  name += ' (+En)'
1372 
1373  # Append the result name of the language, possibly with note.
1374  langReadableLst.append(name)
1375 
1376  # Create the multiline string of readable language names,
1377  # with punctuation, wrapped to paragraph.
1378  if len(langReadableLst) == 1:
1379  s = langReadableLst[0]
1380  elif len(langReadableLst) == 2:
1381  s = ' and '.join(langReadableLst)
1382  else:
1383  s = ', '.join(langReadableLst[:-1]) + ', and '
1384  s += langReadableLst[-1]
1385 
1386  self.supportedLangReadableStr = fill(s + '.')
1387 
1388  # Find the number of the supported languages. The English based
1389  # languages are not counted if the non-English based also exists.
1390  self.numLang = len(self.langLst)
1391  for name, obj in self.langLst:
1392  if obj.status == 'En':
1393  classId = obj.classId[:-2]
1394  if classId in self.__translDic:
1395  self.numLang -= 1 # the couple will be counted as one
1396 
1397  # Extract the version of Doxygen.
1398  f = xopen(os.path.join(self.doxy_path, 'VERSION'))
1399  self.doxVersion = f.readline().strip()
1400  f.close()
1401 
1402  # Update the last modification time.
1403  for tr in list(self.__translDic.values()):
1404  tim = tr.getmtime()
1405  if tim > self.lastModificationTime:
1406  self.lastModificationTime = tim
1407 
1408 
def xopen(fname, mode='r', encoding='utf-8-sig')
Definition: translator.py:79
def __extractProcessedInfo(self)
Definition: translator.py:1329
def fill(s)
Definition: translator.py:93
def translator.TrManager.__getNoTrSourceFilesLst (   self)
private
Returns the list of sources to be checked.

All .cpp files and also .h files that do not declare or define
the translator methods are included in the list. The file names
are searched in doxygen/src directory.

Definition at line 1409 of file translator.py.

1410  """Returns the list of sources to be checked.
1411 
1412  All .cpp files and also .h files that do not declare or define
1413  the translator methods are included in the list. The file names
1414  are searched in doxygen/src directory.
1415  """
1416  files = []
1417  for item in os.listdir(self.src_path):
1418  # Split the bare name to get the extension.
1419  name, ext = os.path.splitext(item)
1420  ext = ext.lower()
1421 
1422  # Include only .cpp and .h files (case independent) and exclude
1423  # the files where the checked identifiers are defined.
1424  if ext == '.cpp' or (ext == '.h' and name.find('translator') == -1):
1425  fname = os.path.join(self.src_path, item)
1426  assert os.path.isfile(fname) # assumes no directory with the ext
1427  files.append(fname) # full name
1428  return files
1429 
1430 
def __getNoTrSourceFilesLst(self)
Definition: translator.py:1409
def translator.TrManager.__loadMaintainers (   self)
private
Load and process the file with the maintainers.

Fills the dictionary classId -> [(name, e-mail), ...].

Definition at line 1709 of file translator.py.

1710  """Load and process the file with the maintainers.
1711 
1712  Fills the dictionary classId -> [(name, e-mail), ...]."""
1713 
1714  fname = os.path.join(self.doc_path, self.maintainersFileName)
1715 
1716  # Include the maintainers file to the group of files checked with
1717  # respect to the modification time.
1718  tim = os.path.getmtime(fname)
1719  if tim > self.lastModificationTime:
1720  self.lastModificationTime = tim
1721 
1722  # Process the content of the maintainers file.
1723  f = xopen(fname)
1724  inside = False # inside the record for the language
1725  lineReady = True
1726  classId = None
1727  maintainersLst = None
1728  self.__maintainersDic = {}
1729  while lineReady:
1730  line = f.readline() # next line
1731  lineReady = line != '' # when eof, then line == ''
1732 
1733  line = line.strip() # eof should also behave as separator
1734  if line != '' and line[0] == '%': # skip the comment line
1735  continue
1736 
1737  if not inside: # if outside of the record
1738  if line != '': # should be language identifier
1739  classId = line
1740  maintainersLst = []
1741  inside = True
1742  # Otherwise skip empty line that do not act as separator.
1743 
1744  else: # if inside the record
1745  if line == '': # separator found
1746  inside = False
1747  else:
1748  # If it is the first maintainer, create the empty list.
1749  if classId not in self.__maintainersDic:
1750  self.__maintainersDic[classId] = []
1751 
1752  # Split the information about the maintainer and append
1753  # the tuple. The address may be prefixed '[unreachable]'
1754  # or whatever '[xxx]'. This will be processed later.
1755  lst = line.split(':', 1)
1756  assert(len(lst) == 2)
1757  t = (lst[0].strip(), lst[1].strip())
1758  self.__maintainersDic[classId].append(t)
1759  f.close()
1760 
1761 
def xopen(fname, mode='r', encoding='utf-8-sig')
Definition: translator.py:79
def __loadMaintainers(self)
Definition: translator.py:1709
def translator.TrManager.__removeUsedInFiles (   self,
  fname,
  dic 
)
private
Removes items for method identifiers that are found in fname.

The method reads the content of the file as one string and searches
for all identifiers from dic. The identifiers that were found in
the file are removed from the dictionary.

Note: If more files is to be checked, the files where most items are
probably used should be checked first and the resulting reduced
dictionary should be used for checking the next files (speed up).

Definition at line 1431 of file translator.py.

1431  def __removeUsedInFiles(self, fname, dic):
1432  """Removes items for method identifiers that are found in fname.
1433 
1434  The method reads the content of the file as one string and searches
1435  for all identifiers from dic. The identifiers that were found in
1436  the file are removed from the dictionary.
1437 
1438  Note: If more files is to be checked, the files where most items are
1439  probably used should be checked first and the resulting reduced
1440  dictionary should be used for checking the next files (speed up).
1441  """
1442  lst_in = list(dic.keys()) # identifiers to be searched for
1443 
1444  # Read content of the file as one string.
1445  assert os.path.isfile(fname)
1446  f = xopen(fname)
1447  cont = f.read()
1448  f.close()
1449 
1450  # Remove the items for identifiers that were found in the file.
1451  while lst_in:
1452  item = lst_in.pop(0)
1453  if cont.find(item) != -1:
1454  del dic[item]
1455 
1456 
def xopen(fname, mode='r', encoding='utf-8-sig')
Definition: translator.py:79
def __removeUsedInFiles(self, fname, dic)
Definition: translator.py:1431
def translator.TrManager.generateLanguageDoc (   self)
Checks the modtime of files and generates language.doc.

Definition at line 1762 of file translator.py.

1763  """Checks the modtime of files and generates language.doc."""
1764  self.__loadMaintainers()
1765 
1766  # Check the last modification time of the template file. It is the
1767  # last file from the group that decide whether the documentation
1768  # should or should not be generated.
1769  fTplName = os.path.join(self.doc_path, self.languageTplFileName)
1770  tim = os.path.getmtime(fTplName)
1771  if tim > self.lastModificationTime:
1772  self.lastModificationTime = tim
1773 
1774  # If the generated documentation exists and is newer than any of
1775  # the source files from the group, do not generate it and quit
1776  # quietly.
1777  fDocName = os.path.join(self.doc_path, self.languageDocFileName)
1778  if os.path.isfile(fDocName):
1779  if os.path.getmtime(fDocName) > self.lastModificationTime:
1780  return
1781 
1782  # The document or does not exist or is older than some of the
1783  # sources. It must be generated again.
1784  #
1785  # Read the template of the documentation, and remove the first
1786  # attention lines.
1787  f = xopen(fTplName)
1788  doctpl = f.read()
1789  f.close()
1790 
1791  pos = doctpl.find('/***')
1792  assert pos != -1
1793  doctpl = doctpl[pos:]
1794 
1795  # Fill the tplDic by symbols that will be inserted into the
1796  # document template.
1797  tplDic = {}
1798 
1799  s = ('Do not edit this file. It was generated by the %s script.\n' +\
1800  ' * Edit the %s and %s files instead.') % (
1802  tplDic['editnote'] = s
1803 
1804  tplDic['doxVersion'] = self.doxVersion
1805  tplDic['supportedLangReadableStr'] = self.supportedLangReadableStr
1806  tplDic['translatorReportFileName'] = self.translatorReportFileName
1807 
1808  ahref = '<a href="../doc/' + self.translatorReportFileName
1809  ahref += '"\n><code>doxygen/doc/' + self.translatorReportFileName
1810  ahref += '</code></a>'
1811  tplDic['translatorReportLink'] = ahref
1812  tplDic['numLangStr'] = str(self.numLang)
1813 
1814  # Define templates for HTML table parts of the documentation.
1815  htmlTableTpl = '''\
1816  \\htmlonly
1817  </p>
1818  <table align="center" cellspacing="0" cellpadding="0" border="0">
1819  <tr bgcolor="#000000">
1820  <td>
1821  <table cellspacing="1" cellpadding="2" border="0">
1822  <tr bgcolor="#4040c0">
1823  <td ><b><font size="+1" color="#ffffff"> Language </font></b></td>
1824  <td ><b><font size="+1" color="#ffffff"> Maintainer </font></b></td>
1825  <td ><b><font size="+1" color="#ffffff"> Contact address </font>
1826  <font size="-2" color="#ffffff">(replace the at and dot)</font></b></td>
1827  <td ><b><font size="+1" color="#ffffff"> Status </font></b></td>
1828  </tr>
1829  <!-- table content begin -->
1830  %s
1831  <!-- table content end -->
1832  </table>
1833  </td>
1834  </tr>
1835  </table>
1836  <p>
1837  \\endhtmlonly
1838  '''
1839  htmlTableTpl = textwrap.dedent(htmlTableTpl)
1840  htmlTrTpl = '\n <tr bgcolor="#ffffff">%s\n </tr>'
1841  htmlTdTpl = '\n <td>%s</td>'
1842  htmlTdStatusColorTpl = '\n <td bgcolor="%s">%s</td>'
1843 
1844  # Loop through transl objects in the order of sorted readable names
1845  # and add generate the content of the HTML table.
1846  trlst = []
1847  for name, obj in self.langLst:
1848  # Fill the table data elements for one row. The first element
1849  # contains the readable name of the language. Only the oldest
1850  # translator are colour marked in the language columnt. Less
1851  # "heavy" color is used (when compared with the Status column).
1852  if obj.readableStatus.startswith('1.4'):
1853  bkcolor = self.getBgcolorByReadableStatus('1.4')
1854  else:
1855  bkcolor = '#ffffff'
1856 
1857  lst = [ htmlTdStatusColorTpl % (bkcolor, obj.langReadable) ]
1858 
1859  # The next two elements contain the list of maintainers
1860  # and the list of their mangled e-mails. For English-based
1861  # translators that are coupled with the non-English based,
1862  # insert the 'see' note.
1863  mm = None # init -- maintainer
1864  ee = None # init -- e-mail address
1865  if obj.status == 'En':
1866  # Check whether there is the coupled non-English.
1867  classId = obj.classId[:-2]
1868  if classId in self.__translDic:
1869  lang = self.__translDic[classId].langReadable
1870  mm = 'see the %s language' % lang
1871  ee = '&nbsp;'
1872 
1873  if not mm and obj.classId in self.__maintainersDic:
1874  # Build a string of names separated by the HTML break element.
1875  # Special notes used instead of names are highlighted.
1876  lm = []
1877  for maintainer in self.__maintainersDic[obj.classId]:
1878  name = maintainer[0]
1879  if name.startswith('--'):
1880  name = '<span style="color: red; background-color: yellow">'\
1881  + name + '</span>'
1882  lm.append(name)
1883  mm = '<br/>'.join(lm)
1884 
1885  # The marked adresses (they start with the mark '[unreachable]',
1886  # '[resigned]', whatever '[xxx]') will not be displayed at all.
1887  # Only the mark will be used instead.
1888  rexMark = re.compile('(?P<mark>\\[.*?\\])')
1889  le = []
1890  for maintainer in self.__maintainersDic[obj.classId]:
1891  address = maintainer[1]
1892  m = rexMark.search(address)
1893  if m is not None:
1894  address = '<span style="color: brown">'\
1895  + m.group('mark') + '</span>'
1896  le.append(address)
1897  ee = '<br/>'.join(le)
1898 
1899  # Append the maintainer and e-mail elements.
1900  lst.append(htmlTdTpl % mm)
1901  lst.append(htmlTdTpl % ee)
1902 
1903  # The last element contains the readable form of the status.
1904  bgcolor = self.getBgcolorByReadableStatus(obj.readableStatus)
1905  lst.append(htmlTdStatusColorTpl % (bgcolor, obj.readableStatus))
1906 
1907  # Join the table data to one table row.
1908  trlst.append(htmlTrTpl % (''.join(lst)))
1909 
1910  # Join the table rows and insert into the template.
1911  htmlTable = htmlTableTpl % (''.join(trlst))
1912 
1913  # Define templates for LaTeX table parts of the documentation.
1914  latexTableTpl = r'''
1915  \latexonly
1916  \footnotesize
1917  \begin{longtable}{|l|l|l|l|}
1918  \hline
1919  {\bf Language} & {\bf Maintainer} & {\bf Contact address} & {\bf Status} \\
1920  \hline
1921  %s
1922  \hline
1923  \end{longtable}
1924  \normalsize
1925  \endlatexonly
1926  '''
1927  latexTableTpl = textwrap.dedent(latexTableTpl)
1928  latexLineTpl = '\n' + r' %s & %s & {\tt\tiny %s} & %s \\'
1929 
1930  # Loop through transl objects in the order of sorted readable names
1931  # and add generate the content of the LaTeX table.
1932  trlst = []
1933  for name, obj in self.langLst:
1934  # For LaTeX, more maintainers for the same language are
1935  # placed on separate rows in the table. The line separator
1936  # in the table is placed explicitly above the first
1937  # maintainer. Prepare the arguments for the LaTeX row template.
1938  maintainers = []
1939  if obj.classId in self.__maintainersDic:
1940  maintainers = self.__maintainersDic[obj.classId]
1941 
1942  lang = obj.langReadable
1943  maintainer = None # init
1944  email = None # init
1945  if obj.status == 'En':
1946  # Check whether there is the coupled non-English.
1947  classId = obj.classId[:-2]
1948  if classId in self.__translDic:
1949  langNE = self.__translDic[classId].langReadable
1950  maintainer = 'see the %s language' % langNE
1951  email = '~'
1952 
1953  if not maintainer and (obj.classId in self.__maintainersDic):
1954  lm = [ m[0] for m in self.__maintainersDic[obj.classId] ]
1955  maintainer = maintainers[0][0]
1956  email = maintainers[0][1]
1957 
1958  status = obj.readableStatus
1959 
1960  # Use the template to produce the line of the table and insert
1961  # the hline plus the constructed line into the table content.
1962  # The underscore character must be escaped.
1963  trlst.append('\n \\hline')
1964  s = latexLineTpl % (lang, maintainer, email, status)
1965  s = s.replace('_', '\\_')
1966  trlst.append(s)
1967 
1968  # List the other maintainers for the language. Do not set
1969  # lang and status for them.
1970  lang = '~'
1971  status = '~'
1972  for m in maintainers[1:]:
1973  maintainer = m[0]
1974  email = m[1]
1975  s = latexLineTpl % (lang, maintainer, email, status)
1976  s = s.replace('_', '\\_')
1977  trlst.append(s)
1978 
1979  # Join the table lines and insert into the template.
1980  latexTable = latexTableTpl % (''.join(trlst))
1981 
1982  # Put the HTML and LaTeX parts together and define the dic item.
1983  tplDic['informationTable'] = htmlTable + '\n' + latexTable
1984 
1985  # Insert the symbols into the document template and write it down.
1986  f = xopen(fDocName, 'w')
1987  f.write(doctpl % tplDic)
1988  f.close()
1989 
def generateLanguageDoc(self)
Definition: translator.py:1762
def xopen(fname, mode='r', encoding='utf-8-sig')
Definition: translator.py:79
def __loadMaintainers(self)
Definition: translator.py:1709
static QCString str
def getBgcolorByReadableStatus(self, readableStatus)
Definition: translator.py:1499
def translator.TrManager.generateTranslatorReport (   self)
Generates the translator report.

Definition at line 1517 of file translator.py.

1518  """Generates the translator report."""
1519 
1520  output = os.path.join(self.doc_path, self.translatorReportFileName)
1521 
1522  # Open the textual report file for the output.
1523  f = xopen(output, 'w')
1524 
1525  # Output the information about the version.
1526  f.write('(' + self.doxVersion + ')\n\n')
1527 
1528  # Output the information about the number of the supported languages
1529  # and the list of the languages, or only the note about the explicitly
1530  # given languages to process.
1531  if self.script_argLst:
1532  f.write('The report was generated for the following, explicitly')
1533  f.write(' identified languages:\n\n')
1534  f.write(self.supportedLangReadableStr + '\n\n')
1535  else:
1536  f.write('Doxygen supports the following ')
1537  f.write(str(self.numLang))
1538  f.write(' languages (sorted alphabetically):\n\n')
1539  f.write(self.supportedLangReadableStr + '\n\n')
1540 
1541  # Write the summary about the status of language translators (how
1542  # many translators) are up-to-date, etc.
1543  s = 'Of them, %d translators are up-to-date, ' % len(self.upToDateIdLst)
1544  s += '%d translators are based on some adapter class, ' % len(self.adaptIdLst)
1545  s += 'and %d are English based.' % len(self.EnBasedIdLst)
1546  f.write(fill(s) + '\n\n')
1547 
1548  # The e-mail addresses of the maintainers will be collected to
1549  # the auxiliary file in the order of translator classes listed
1550  # in the translator report.
1551  fmail = xopen('mailto.txt', 'w')
1552 
1553  # Write the list of "up-to-date" translator classes.
1554  if self.upToDateIdLst:
1555  s = '''The following translator classes are up-to-date (sorted
1556  alphabetically). This means that they derive from the
1557  Translator class, they implement all %d of the required
1558  methods, and even minor problems were not spotted by the script:'''
1559  s = s % len(self.requiredMethodsDic)
1560  f.write('-' * 70 + '\n')
1561  f.write(fill(s) + '\n\n')
1562 
1563  mailtoLst = []
1564  for x in self.upToDateIdLst:
1565  obj = self.__translDic[x]
1566  if obj.note is None:
1567  f.write(' ' + obj.classId + '\n')
1568  mailtoLst.extend(self.__emails(obj.classId))
1569 
1570  fmail.write('up-to-date\n')
1571  fmail.write('; '.join(mailtoLst))
1572 
1573 
1574  # Write separately the list of "ALMOST up-to-date" translator classes.
1575  s = '''The following translator classes are ALMOST up-to-date (sorted
1576  alphabetically). This means that they derive from the
1577  Translator class, but there still may be some minor problems
1578  listed for them:'''
1579  f.write('\n' + ('-' * 70) + '\n')
1580  f.write(fill(s) + '\n\n')
1581  mailtoLst = []
1582  for x in self.upToDateIdLst:
1583  obj = self.__translDic[x]
1584  if obj.note is not None:
1585  f.write(' ' + obj.classId + '\t-- ' + obj.note + '\n')
1586  mailtoLst.extend(self.__emails(obj.classId))
1587 
1588  fmail.write('\n\nalmost up-to-date\n')
1589  fmail.write('; '.join(mailtoLst))
1590 
1591  # Write the list of the adapter based classes. The very obsolete
1592  # translators that derive from TranslatorEnglish are included.
1593  if self.adaptIdLst:
1594  s = '''The following translator classes need maintenance
1595  (the most obsolete at the end). The other info shows the
1596  estimation of Doxygen version when the class was last
1597  updated and number of methods that must be implemented to
1598  become up-to-date:'''
1599  f.write('\n' + '-' * 70 + '\n')
1600  f.write(fill(s) + '\n\n')
1601 
1602  # Find also whether some adapter classes may be removed.
1603  adaptMinVersion = '9.9.99'
1604 
1605  mailtoLst = []
1606  numRequired = len(self.requiredMethodsDic)
1607  for x in self.adaptIdLst:
1608  obj = self.__translDic[x]
1609  f.write(' %-30s' % obj.classId)
1610  f.write(' %-6s' % obj.readableStatus)
1611  numimpl = len(obj.missingMethods)
1612  pluralS = ''
1613  if numimpl > 1: pluralS = 's'
1614  percent = 100 * numimpl / numRequired
1615  f.write('\t%2d method%s to implement (%d %%)' % (
1616  numimpl, pluralS, percent))
1617  if obj.note:
1618  f.write('\n\tNote: ' + obj.note + '\n')
1619  f.write('\n')
1620  mailtoLst.extend(self.__emails(obj.classId)) # to maintainer
1621 
1622  # Check the level of required adapter classes.
1623  if obj.status != '0.0.00' and obj.status < adaptMinVersion:
1624  adaptMinVersion = obj.status
1625 
1626  fmail.write('\n\ntranslator based\n')
1627  fmail.write('; '.join(mailtoLst))
1628 
1629  # Set the note if some old translator adapters are not needed
1630  # any more. Do it only when the script is called without arguments,
1631  # i.e. all languages were checked against the needed translator
1632  # adapters.
1633  if not self.script_argLst:
1634  to_remove = {}
1635  for version, adaptClassId in list(self.adaptMethodsDic.values()):
1636  if version < adaptMinVersion:
1637  to_remove[adaptClassId] = True
1638 
1639  if to_remove:
1640  lst = list(to_remove.keys())
1641  lst.sort()
1642  plural = len(lst) > 1
1643  note = 'Note: The adapter class'
1644  if plural: note += 'es'
1645  note += ' ' + ', '.join(lst)
1646  if not plural:
1647  note += ' is'
1648  else:
1649  note += ' are'
1650  note += ' not used and can be removed.'
1651  f.write('\n' + fill(note) + '\n')
1652 
1653  # Write the list of the English-based classes.
1654  if self.EnBasedIdLst:
1655  s = '''The following translator classes derive directly from the
1656  TranslatorEnglish. The class identifier has the suffix 'En'
1657  that says that this is intentional. Usually, there is also
1658  a non-English based version of the translator for
1659  the language:'''
1660  f.write('\n' + '-' * 70 + '\n')
1661  f.write(fill(s) + '\n\n')
1662 
1663  for x in self.EnBasedIdLst:
1664  obj = self.__translDic[x]
1665  f.write(' ' + obj.classId)
1666  f.write('\timplements %d methods' % len(obj.implementedMethods))
1667  if obj.note:
1668  f.write(' -- ' + obj.note)
1669  f.write('\n')
1670 
1671  # Check for not used translator methods and generate warning if found.
1672  # The check is rather time consuming, so it is not done when report
1673  # is restricted to explicitly given language identifiers.
1674  if not self.script_argLst:
1675  dic = self.__checkForNotUsedTrMethods()
1676  if dic:
1677  s = '''WARNING: The following translator methods are declared
1678  in the Translator class but their identifiers do not appear
1679  in source files. The situation should be checked. The .cpp
1680  files and .h files excluding the '*translator*' files
1681  in doxygen/src directory were simply searched for occurrence
1682  of the method identifiers:'''
1683  f.write('\n' + '=' * 70 + '\n')
1684  f.write(fill(s) + '\n\n')
1685 
1686  keys = list(dic.keys())
1687  keys.sort()
1688  for key in keys:
1689  f.write(' ' + dic[key] + '\n')
1690  f.write('\n')
1691 
1692  # Write the details for the translators.
1693  f.write('\n' + '=' * 70)
1694  f.write('\nDetails for translators (classes sorted alphabetically):\n')
1695 
1696  cls = list(self.__translDic.keys())
1697  cls.sort()
1698 
1699  for c in cls:
1700  obj = self.__translDic[c]
1701  assert(obj.classId != 'Translator')
1702  obj.report(f)
1703 
1704  # Close the report file and the auxiliary file with e-mails.
1705  f.close()
1706  fmail.close()
1707 
1708 
def xopen(fname, mode='r', encoding='utf-8-sig')
Definition: translator.py:79
def __checkForNotUsedTrMethods(self)
Definition: translator.py:1457
def __emails(self, classId)
Definition: translator.py:1484
def generateTranslatorReport(self)
Definition: translator.py:1517
def fill(s)
Definition: translator.py:93
static QCString str
def translator.TrManager.getBgcolorByReadableStatus (   self,
  readableStatus 
)

Definition at line 1499 of file translator.py.

1499  def getBgcolorByReadableStatus(self, readableStatus):
1500  if readableStatus == 'up-to-date':
1501  color = '#ccffcc' # green
1502  elif readableStatus.startswith('almost'):
1503  color = '#ffffff' # white
1504  elif readableStatus.startswith('English'):
1505  color = '#ccffcc' # green
1506  elif readableStatus.startswith('1.8'):
1507  color = '#ffffcc' # yellow
1508  elif readableStatus.startswith('1.7'):
1509  color = '#ffcccc' # pink
1510  elif readableStatus.startswith('1.6'):
1511  color = '#ffcccc' # pink
1512  else:
1513  color = '#ff5555' # red
1514  return color
1515 
1516 
def getBgcolorByReadableStatus(self, readableStatus)
Definition: translator.py:1499

Member Data Documentation

translator.TrManager.__maintainersDic
private

Definition at line 1268 of file translator.py.

translator.TrManager.__translDic
private

Definition at line 1239 of file translator.py.

translator.TrManager.adaptIdLst

Definition at line 1348 of file translator.py.

translator.TrManager.adaptMethodsDic

Definition at line 1248 of file translator.py.

translator.TrManager.doc_path

Definition at line 1234 of file translator.py.

translator.TrManager.doxVersion

Definition at line 1274 of file translator.py.

translator.TrManager.doxy_path

Definition at line 1228 of file translator.py.

translator.TrManager.EnBasedIdLst

Definition at line 1344 of file translator.py.

translator.TrManager.langLst

Definition at line 1271 of file translator.py.

translator.TrManager.languageDocFileName

Definition at line 1264 of file translator.py.

translator.TrManager.languageTplFileName

Definition at line 1263 of file translator.py.

translator.TrManager.lastModificationTime

Definition at line 1256 of file translator.py.

translator.TrManager.maintainersFileName

Definition at line 1262 of file translator.py.

translator.TrManager.numLang

Definition at line 1273 of file translator.py.

translator.TrManager.requiredMethodsDic

Definition at line 1244 of file translator.py.

translator.TrManager.script

Definition at line 1220 of file translator.py.

translator.TrManager.script_argLst

Definition at line 1231 of file translator.py.

translator.TrManager.script_name

Definition at line 1221 of file translator.py.

translator.TrManager.script_path

Definition at line 1222 of file translator.py.

translator.TrManager.src_path

Definition at line 1235 of file translator.py.

translator.TrManager.supportedLangReadableStr

Definition at line 1272 of file translator.py.

translator.TrManager.translatorReportFileName

Definition at line 1261 of file translator.py.

translator.TrManager.upToDateIdLst

Definition at line 1343 of file translator.py.


The documentation for this class was generated from the following file: