Commit 4827ec0c authored by Dimitri van Heesch's avatar Dimitri van Heesch
Browse files

Merge branch 'pepr-master'

parents 0bb9b762 4b8b9430
Loading
Loading
Loading
Loading
+2003 −2030
Original line number Diff line number Diff line
@@ -64,13 +64,30 @@
  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+
  """

from __future__ import print_function

import codecs
import os
import platform
import re
import sys
import textwrap


def 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).
    '''

    major, minor, patch = (int(e) for e in platform.python_version_tuple())
    if major == 2:
        return open(fname, mode=mode) # Python 2 without encoding
    else:
        return open(fname, mode=mode, encoding=encoding) # Python 3 with encoding


def fill(s):
@@ -99,58 +116,6 @@ def fill(s):
    return '\n'.join(lines)


# The following function dedent() is the verbatim copy from the textwrap.py
# module. The textwrap.py was introduced in Python 2.3. To make this script
# working also in older Python versions, I have decided to copy it.
# Notice that the textwrap.py is copyrighted:
#
# Copyright (C) 1999-2001 Gregory P. Ward.
# Copyright (C) 2002, 2003 Python Software Foundation.
# Written by Greg Ward <gward@python.net>
#
# The explicit permission to use the code here was sent by Guido van Rossum
# (4th June, 2004).
#
def dedent(text):
    """dedent(text : string) -> string

    Remove any whitespace than can be uniformly removed from the left
    of every line in `text`.

    This can be used e.g. to make triple-quoted strings line up with
    the left edge of screen/whatever, while still presenting it in the
    source code in indented form.

    For example:

        def test():
            # end first line with \ to avoid the empty line!
            s = '''\
            hello
              world
            '''
            print repr(s)          # prints '    hello\n      world\n    '
            print repr(dedent(s))  # prints 'hello\n  world\n'
    """
    lines = text.expandtabs().split('\n')
    margin = None
    for line in lines:
        content = line.lstrip()
        if not content:
            continue
        indent = len(line) - len(content)
        if margin is None:
            margin = indent
        else:
            margin = min(margin, indent)

    if margin is not None and margin > 0:
        for i in range(len(lines)):
            lines[i] = lines[i][margin:]

    return '\n'.join(lines)


class Transl:
    """One instance is build for each translator.

@@ -237,7 +202,7 @@ class Transl:

        # Open the file for reading and extracting tokens until the eof.
        # Initialize the finite automaton.
        f = open(self.fname)
        f = xopen(self.fname)
        lineNo = 0
        line = ''         # init -- see the pos initialization below
        linelen = 0       # init
@@ -256,8 +221,6 @@ class Transl:
            else:
                lineNo += 1
                line = f.readline()
                if line.startswith('\xef\xbb\xbf'):
                    line = line[3:]    # skip the BOM
                linelen = len(line)
                pos = 0
                if line == '':         # eof
@@ -1108,6 +1071,7 @@ class Transl:
        for p in myDic:
            if p not in reqDic:
                self.obsoleteMethods.append(p)
        self.obsoleteMethods.sort()

        # Build the list of missing methods and the list of implemented
        # required methods.
@@ -1118,6 +1082,8 @@ class Transl:
                self.implementedMethods.append(p)
            else:
                self.missingMethods.append(p)
        self.missingMethods.sort()
        self.implementedMethods.sort()

        # Check whether adapter must be used or suggest the newest one.
        # Change the status and set the note accordingly.
@@ -1386,8 +1352,8 @@ class TrManager:
        self.langLst = []
        for obj in list(self.__translDic.values()):
            self.langLst.append((obj.langReadable, obj))
        #self.langLst.sort(lambda a, b: cmp(a[0], b[0]))
        self.langLst.sort(key=lambda a: a[0])

        self.langLst.sort(key=lambda x: x[0])

        # Create the list with readable language names. If the language has
        # also the English-based version, modify the item by appending
@@ -1429,7 +1395,7 @@ class TrManager:
                    self.numLang -= 1    # the couple will be counted as one

        # Extract the version of Doxygen.
        f = open(os.path.join(self.doxy_path, 'VERSION'))
        f = xopen(os.path.join(self.doxy_path, 'VERSION'))
        self.doxVersion = f.readline().strip()
        f.close()

@@ -1477,7 +1443,7 @@ class TrManager:

        # Read content of the file as one string.
        assert os.path.isfile(fname)
        f = open(fname)
        f = xopen(fname)
        cont = f.read()
        f.close()

@@ -1554,7 +1520,7 @@ class TrManager:
        output = os.path.join(self.doc_path, self.translatorReportFileName)

        # Open the textual report file for the output.
        f = open(output, 'w')
        f = xopen(output, 'w')

        # Output the information about the version.
        f.write('(' + self.doxVersion + ')\n\n')
@@ -1582,7 +1548,7 @@ class TrManager:
        # The e-mail addresses of the maintainers will be collected to
        # the auxiliary file in the order of translator classes listed
        # in the translator report.
        fmail = open('mailto.txt', 'w')
        fmail = xopen('mailto.txt', 'w')

        # Write the list of "up-to-date" translator classes.
        if self.upToDateIdLst:
@@ -1754,7 +1720,7 @@ class TrManager:
            self.lastModificationTime = tim

        # Process the content of the maintainers file.
        f = codecs.open(fname, 'r', 'utf-8')
        f = xopen(fname)
        inside = False  # inside the record for the language
        lineReady = True
        classId = None
@@ -1818,7 +1784,7 @@ class TrManager:
        #
        # Read the template of the documentation, and remove the first
        # attention lines.
        f = codecs.open(fTplName, 'r', 'utf-8')
        f = xopen(fTplName)
        doctpl = f.read()
        f.close()

@@ -1830,7 +1796,7 @@ class TrManager:
        # document template.
        tplDic = {}

        s = 'Do not edit this file. It was generated by the %s script.\n * Instead edit %s and %s' % (self.script_name, self.languageTplFileName, self.maintainersFileName)
        s = 'Do not edit this file. It was generated by the %s script. * Instead edit %s and %s' % (self.script_name, self.languageTplFileName, self.maintainersFileName)
        tplDic['editnote'] = s

        tplDic['doxVersion'] = self.doxVersion
@@ -1866,7 +1832,7 @@ class TrManager:
            </table>
            \\endhtmlonly
            '''
        htmlTableTpl = dedent(htmlTableTpl)
        htmlTableTpl = textwrap.dedent(htmlTableTpl)
        htmlTrTpl = '\n  <tr bgcolor="#ffffff">%s\n  </tr>'
        htmlTdTpl = '\n    <td>%s</td>'
        htmlTdStatusColorTpl = '\n    <td bgcolor="%s">%s</td>'
@@ -1915,7 +1881,7 @@ class TrManager:
                # 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(r'(?P<mark>\[.*?\])')
                rexMark = re.compile('(?P<mark>\\[.*?\\])')
                le = []
                for maintainer in self.__maintainersDic[obj.classId]:
                    address = maintainer[1]
@@ -1954,7 +1920,7 @@ class TrManager:
            \normalsize
            \endlatexonly
            '''
        latexTableTpl = dedent(latexTableTpl)
        latexTableTpl = textwrap.dedent(latexTableTpl)
        latexLineTpl = '\n' + r'  %s & %s & {\tt\tiny %s} & %s \\'

        # Loop through transl objects in the order of sorted readable names
@@ -2013,14 +1979,21 @@ class TrManager:
        tplDic['informationTable'] = htmlTable + '\n' + latexTable

        # Insert the symbols into the document template and write it down.
        f = codecs.open(fDocName, 'w', 'utf-8')
        f = xopen(fDocName, 'w')
        f.write(doctpl % tplDic)
        f.close()

if __name__ == '__main__':

    # Create the manager, build the transl objects, and parse the related
    # sources.
    # The Python 2.6+ or 3.3+ is required.
    major, minor, patch = (int(e) for e in platform.python_version_tuple())
    print(major, minor, patch)
    if (major == 2 and minor < 6) or (major == 3 and minor < 0):
        print('Python 2.6+ or Python 3.0+ are required for the script')
        sys.exit(1)

    # The translator manager builds the transl objects, parses the related
    # sources, and keeps them in memory.
    trMan = TrManager()

    # Generate the language.doc.
+13 −11
Original line number Diff line number Diff line
@@ -92,8 +92,7 @@ def copyBinaries(dist_dir, subdir):
    # Source file should exist.
    sdir, fname = getThisScriptPathAndName()
    src = os.path.normpath(os.path.join(sdir, '..', 'bin', subdir, 'doxygen.exe'))
    assert os.path.isfile(src)

    if os.path.isfile(src):
        # Destination directory must not exist. It must be created first.
        dst_dir = os.path.normpath(os.path.join(dist_dir, 'bin', subdir))
        assert not os.path.isdir(dst_dir)
@@ -102,6 +101,9 @@ def copyBinaries(dist_dir, subdir):
        # Copy the file.
        print("Copying '{}'".format(src))
        shutil.copy2(src, dst_dir)
    else:
        print("The binary '" + src + "'")
        print('was not found. It will not be present in the distribution.')


def getBinariesZipBareName():