]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Assume Python 3.
authorBruno Haible <bruno@clisp.org>
Sat, 30 Jul 2022 09:45:36 +0000 (11:45 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 31 Jul 2022 05:07:32 +0000 (07:07 +0200)
* gnulib-tool.py: Don't set PYTHON3, string. Use str instead of string.
* pygnulib/*.py: Likewise.

12 files changed:
ChangeLog
gnulib-tool.py
pygnulib/GLConfig.py
pygnulib/GLEmiter.py
pygnulib/GLError.py
pygnulib/GLFileSystem.py
pygnulib/GLImport.py
pygnulib/GLInfo.py
pygnulib/GLMakefileTable.py
pygnulib/GLModuleSystem.py
pygnulib/GLTestDir.py
pygnulib/constants.py

index 9459fa6e7cfbdc34a18887131af28c7de43f5f6b..bb5f09a1c4f0ea61be063793970d8998ad6f8aca 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2022-07-30  Bruno Haible  <bruno@clisp.org>
 
+       gnulib-tool.py: Assume Python 3.
+       * gnulib-tool.py: Don't set PYTHON3, string. Use str instead of string.
+       * pygnulib/*.py: Likewise.
+
        gnulib-tool.py: Modernize coding style.
        * pygnulib/*.py: Remove parentheses around raise value expressions.
 
index 860487a934027808b8e81b72a0089bc3976a7a69..ae4a839da9aeea5512374496d7deae945d6a3e2d 100755 (executable)
@@ -47,7 +47,6 @@ from pygnulib import classes
 #===============================================================================
 # Define global constants
 #===============================================================================
-PYTHON3 = constants.PYTHON3
 APP = constants.APP
 DIRS = constants.DIRS
 ENCS = constants.ENCS
@@ -57,7 +56,6 @@ TESTS = constants.TESTS
 compiler = constants.compiler
 joinpath = constants.joinpath
 cleaner = constants.cleaner
-string = constants.string
 isabs = os.path.isabs
 isdir = os.path.isdir
 isfile = os.path.isfile
@@ -801,7 +799,7 @@ def main():
             print('\n'.join(files))
 
     elif mode == 'extract-dependencies':
-        result = string()
+        result = ''
         if avoids:
             message = '%s: *** ' % constants.APP['name']
             message += 'cannot combine --avoid and --extract-dependencies\n'
@@ -891,7 +889,7 @@ def main():
         filesystem = classes.GLFileSystem(config)
         lookedup, flag = filesystem.lookup(srcpath)
         if isdir(dest):
-            destdir = string(dest)
+            destdir = str(dest)
             if srcpath.startswith('build-aux/'):
                 destpath = constants.substart(
                     'build-aux/', '%s/' % auxdir, srcpath)
@@ -960,7 +958,7 @@ if __name__ == '__main__':
         if errmode == 0:
             message = '%s: *** ' % constants.APP['name']
             if errinfo == None:
-                errinfo = string()
+                errinfo = ''
             if errno == 1:
                 message += 'file %s not found' % errinfo
             elif errno == 2:
@@ -990,7 +988,7 @@ if __name__ == '__main__':
                 message = 'gnulib-tool: option --conditional-dependencies is not '
                 message += 'supported with --with-tests\n'
             elif errno == 11:
-                incompatibilities = string()
+                incompatibilities = ''
                 message += 'incompatible license on modules:%s' % constants.NL
                 for pair in errinfo:
                     incompatibilities += pair[0]
index acd6be20409cb3ebff47c555455b20c1f8ab784e..8f6ca80be4db1b43eab437d375170f2e765414d9 100644 (file)
@@ -38,7 +38,6 @@ __copyright__ = constants.__copyright__
 #===============================================================================
 # Define global constants
 #===============================================================================
-PYTHON3 = constants.PYTHON3
 NoneType = type(None)
 APP = constants.APP
 DIRS = constants.DIRS
@@ -50,7 +49,6 @@ compiler = constants.compiler
 joinpath = constants.joinpath
 cleaner = constants.cleaner
 relpath = constants.relativize
-string = constants.string
 isabs = os.path.isabs
 isdir = os.path.isdir
 isfile = os.path.isfile
@@ -346,11 +344,11 @@ class GLConfig(object):
         '''Return default value for the given key.'''
         if key in self.table:
             if key == 'libname':
-                return string('libgnu')
+                return 'libgnu'
             elif key == 'macro_prefix':
-                return string('gl')
+                return 'gl'
             elif key == 'include_guard_prefix':
-                return string('GL')
+                return 'GL'
             elif key == 'ac_version':
                 return 2.59
             elif key == 'verbosity':
@@ -367,7 +365,7 @@ class GLConfig(object):
             elif key == 'errors':
                 return True
             else:  # otherwise
-                return string()
+                return ''
         else:  # if key not in self.table
             raise KeyError('GLConfig does not contain key: %s' % repr(key))
 
@@ -396,19 +394,19 @@ class GLConfig(object):
     def setDestDir(self, destdir):
         '''Specify the target directory. For --import, this specifies where your
         configure.ac can be found. Defaults to current directory.'''
-        if type(destdir) is bytes or type(destdir) is string:
+        if type(destdir) is bytes or type(destdir) is str:
             if type(destdir) is bytes:
-                destdir = string(destdir, ENCS['system'])
+                destdir = str(destdir, ENCS['system'])
             if destdir:
                 self.table['destdir'] = os.path.normpath(destdir)
-        else:  # if destdir has not bytes/string type
+        else:  # if destdir has not bytes/str type
             raise TypeError('destdir must be a string, not %s' %
                             type(destdir).__name__)
 
     def resetDestDir(self):
         '''Reset the target directory. For --import, this specifies where your
         configure.ac can be found. Defaults to current directory.'''
-        self.table['destdir'] = string()
+        self.table['destdir'] = ''
 
     # Define localdir methods.
     def getLocalDir(self):
@@ -419,19 +417,19 @@ class GLConfig(object):
     def setLocalDir(self, localdir):
         '''Specify a local override directory where to look up files before looking
         in gnulib's directory.'''
-        if type(localdir) is bytes or type(localdir) is string:
+        if type(localdir) is bytes or type(localdir) is str:
             if type(localdir) is bytes:
-                localdir = string(localdir, ENCS['system'])
+                localdir = str(localdir, ENCS['system'])
             if localdir:
                 self.table['localdir'] = localdir
-        else:  # if localdir has not bytes/string type
+        else:  # if localdir has not bytes/str type
             raise TypeError('localdir must be a string, not %s' %
                             type(localdir).__name__)
 
     def resetLocalDir(self):
         '''Reset a local override directory where to look up files before looking
         in gnulib's directory.'''
-        self.table['localdir'] = string()
+        self.table['localdir'] = ''
 
     # Define auxdir methods.
     def getAuxDir(self):
@@ -444,19 +442,19 @@ class GLConfig(object):
     def setAuxDir(self, auxdir):
         '''Specify directory relative to --dir where auxiliary build tools are
         placed. Default comes from configure.ac or configure.in.'''
-        if type(auxdir) is bytes or type(auxdir) is string:
+        if type(auxdir) is bytes or type(auxdir) is str:
             if type(auxdir) is bytes:
-                auxdir = string(auxdir, ENCS['system'])
+                auxdir = str(auxdir, ENCS['system'])
             if auxdir:
                 self.table['auxdir'] = auxdir
-        else:  # if type of auxdir is not bytes or string
+        else:  # if type of auxdir is not bytes or str
             raise TypeError('auxdir must be a string, not %s' %
                             type(auxdir).__name__)
 
     def resetAuxDir(self):
         '''Reset directory relative to --dir where auxiliary build tools are
         placed. Default comes from configure.ac or configure.in.'''
-        self.table['auxdir'] = string()
+        self.table['auxdir'] = ''
 
     # Define sourcebase methods.
     def getSourceBase(self):
@@ -465,18 +463,18 @@ class GLConfig(object):
 
     def setSourceBase(self, sourcebase):
         '''Specify directory relative to destdir where source code is placed.'''
-        if type(sourcebase) is bytes or type(sourcebase) is string:
+        if type(sourcebase) is bytes or type(sourcebase) is str:
             if type(sourcebase) is bytes:
-                sourcebase = string(sourcebase, ENCS['system'])
+                sourcebase = str(sourcebase, ENCS['system'])
             if sourcebase:
                 self.table['sourcebase'] = sourcebase
-        else:  # if type of sourcebase is not bytes or string
+        else:  # if type of sourcebase is not bytes or str
             raise TypeError('sourcebase must be a string, not %s' %
                             type(sourcebase).__name__)
 
     def resetSourceBase(self):
         '''Return directory relative to destdir where source code is placed.'''
-        self.table['sourcebase'] = string()
+        self.table['sourcebase'] = ''
 
     # Define m4base methods.
     def getM4Base(self):
@@ -485,18 +483,18 @@ class GLConfig(object):
 
     def setM4Base(self, m4base):
         '''Specify directory relative to destdir where *.m4 macros are placed.'''
-        if type(m4base) is bytes or type(m4base) is string:
+        if type(m4base) is bytes or type(m4base) is str:
             if type(m4base) is bytes:
-                m4base = string(m4base, ENCS['system'])
+                m4base = str(m4base, ENCS['system'])
             if m4base:
                 self.table['m4base'] = m4base
-        else:  # if type of m4base is not bytes or string
+        else:  # if type of m4base is not bytes or str
             raise TypeError('m4base must be a string, not %s' %
                             type(m4base).__name__)
 
     def resetM4Base(self):
         '''Reset directory relative to destdir where *.m4 macros are placed.'''
-        self.table['m4base'] = string()
+        self.table['m4base'] = ''
 
     # Define pobase methods.
     def getPoBase(self):
@@ -505,18 +503,18 @@ class GLConfig(object):
 
     def setPoBase(self, pobase):
         '''Specify directory relative to destdir where *.po files are placed.'''
-        if type(pobase) is bytes or type(pobase) is string:
+        if type(pobase) is bytes or type(pobase) is str:
             if type(pobase) is bytes:
-                pobase = string(pobase, ENCS['system'])
+                pobase = str(pobase, ENCS['system'])
             if pobase:
                 self.table['pobase'] = pobase
-        else:  # if type of pobase is not bytes or string
+        else:  # if type of pobase is not bytes or str
             raise TypeError('pobase must be a string, not %s' %
                             type(pobase).__name__)
 
     def resetPoBase(self):
         '''Reset directory relative to destdir where *.po files are placed.'''
-        self.table['pobase'] = string()
+        self.table['pobase'] = ''
 
     # Define docbase methods.
     def getDocBase(self):
@@ -527,19 +525,19 @@ class GLConfig(object):
     def setDocBase(self, docbase):
         '''Specify directory relative to destdir where doc files are placed.
         Default value for this variable is 'doc').'''
-        if type(docbase) is bytes or type(docbase) is string:
+        if type(docbase) is bytes or type(docbase) is str:
             if type(docbase) is bytes:
-                docbase = string(docbase, ENCS['system'])
+                docbase = str(docbase, ENCS['system'])
             if docbase:
                 self.table['docbase'] = docbase
-        else:  # if type of docbase is not bytes or string
+        else:  # if type of docbase is not bytes or str
             raise TypeError('docbase must be a string, not %s' %
                             type(docbase).__name__)
 
     def resetDocBase(self):
         '''Reset directory relative to destdir where doc files are placed.
         Default value for this variable is 'doc').'''
-        self.table['docbase'] = string()
+        self.table['docbase'] = ''
 
     # Define testsbase methods.
     def getTestsBase(self):
@@ -550,40 +548,40 @@ class GLConfig(object):
     def setTestsBase(self, testsbase):
         '''Specify directory relative to destdir where unit tests are placed.
         Default value for this variable is 'tests').'''
-        if type(testsbase) is bytes or type(testsbase) is string:
+        if type(testsbase) is bytes or type(testsbase) is str:
             if type(testsbase) is bytes:
-                testsbase = string(testsbase, ENCS['system'])
+                testsbase = str(testsbase, ENCS['system'])
             if testsbase:
                 self.table['testsbase'] = testsbase
-        else:  # if type of testsbase is not bytes or string
+        else:  # if type of testsbase is not bytes or str
             raise TypeError('testsbase must be a string, not %s' %
                             type(testsbase).__name__)
 
     def resetTestsBase(self):
         '''Reset directory relative to destdir where unit tests are placed.
         Default value for this variable is 'tests').'''
-        self.table['testsbase'] = string()
+        self.table['testsbase'] = ''
 
     # Define modules methods.
     def addModule(self, module):
         '''Add the module to the modules list.'''
-        if type(module) is bytes or type(module) is string:
+        if type(module) is bytes or type(module) is str:
             if type(module) is bytes:
                 module = module.decode(ENCS['default'])
             if module not in self.table['modules']:
                 self.table['modules'] += [module]
-        else:  # if module has not bytes or string type
+        else:  # if module has not bytes or str type
             raise TypeError('module must be a string, not %s' %
                             type(module).__name__)
 
     def removeModule(self, module):
         '''Remove the module from the modules list.'''
-        if type(module) is bytes or type(module) is string:
+        if type(module) is bytes or type(module) is str:
             if type(module) is bytes:
                 module = module.decode(ENCS['default'])
             if module in self.table['modules']:
                 self.table['modules'].remove(module)
-        else:  # if module has not bytes or string type
+        else:  # if module has not bytes or str type
             raise TypeError('module must be a string, not %s' %
                             type(module).__name__)
 
@@ -617,23 +615,23 @@ class GLConfig(object):
     def addAvoid(self, module):
         '''Avoid including the given module. Useful if you have code that provides
         equivalent functionality.'''
-        if type(module) is bytes or type(module) is string:
+        if type(module) is bytes or type(module) is str:
             if type(module) is bytes:
                 module = module.decode(ENCS['default'])
             if module not in self.table['avoids']:
                 self.table['avoids'].append(module)
-        else:  # if module has not bytes or string type
+        else:  # if module has not bytes or str type
             raise TypeError('avoid must be a string, not %s' %
                             type(module).__name__)
 
     def removeAvoid(self, module):
         '''Remove the given module from the list of avoided modules.'''
-        if type(module) is bytes or type(module) is string:
+        if type(module) is bytes or type(module) is str:
             if type(module) is bytes:
                 module = module.decode(ENCS['default'])
             if module in self.table['avoids']:
                 self.table['avoids'].remove(module)
-        else:  # if module has not bytes or string type
+        else:  # if module has not bytes or str type
             raise TypeError('avoid must be a string, not %s' %
                             type(module).__name__)
 
@@ -666,23 +664,23 @@ class GLConfig(object):
     # Define files methods.
     def addFile(self, file):
         '''Add file to the list of files.'''
-        if type(file) is bytes or type(file) is string:
+        if type(file) is bytes or type(file) is str:
             if type(file) is bytes:
                 file = file.decode(ENCS['default'])
             if file not in self.table['files']:
                 self.table['files'].append(file)
-        else:  # if file has not bytes or string type
+        else:  # if file has not bytes or str type
             raise TypeError('file must be a string, not %s' %
                             type(file).__name__)
 
     def removeFile(self, file):
         '''Remove the given file from the list of files.'''
-        if type(file) is bytes or type(file) is string:
+        if type(file) is bytes or type(file) is str:
             if type(file) is bytes:
                 file = file.decode(ENCS['default'])
             if file in self.table['files']:
                 self.table['files'].remove(file)
-        else:  # if file has not bytes or string type
+        else:  # if file has not bytes or str type
             raise TypeError('file must be a string, not %s' %
                             type(file).__name__)
 
@@ -767,18 +765,18 @@ class GLConfig(object):
 
     def setLibName(self, libname):
         '''Specify the library name.'''
-        if type(libname) is bytes or type(libname) is string:
+        if type(libname) is bytes or type(libname) is str:
             if type(libname) is bytes:
-                libname = string(libname, ENCS['system'])
+                libname = str(libname, ENCS['system'])
             if libname:
                 self.table['libname'] = libname
-        else:  # if type of libname is not bytes or string
+        else:  # if type of libname is not bytes or str
             raise TypeError('libname must be a string, not %s' %
                             type(module).__name__)
 
     def resetLibName(self):
         '''Reset the library name to 'libgnu'.'''
-        self.table['libname'] = string('libgnu')
+        self.table['libname'] = 'libgnu'
 
     # Define libtool methods.
     def checkLibtool(self):
@@ -850,12 +848,12 @@ class GLConfig(object):
     def setMacroPrefix(self, macro_prefix):
         '''Specify the prefix of the macros 'gl_EARLY' and 'gl_INIT'.
         Default macro_prefix is 'gl'.'''
-        if type(macro_prefix) is bytes or type(macro_prefix) is string:
+        if type(macro_prefix) is bytes or type(macro_prefix) is str:
             if type(macro_prefix) is bytes:
-                macro_prefix = string(macro_prefix, ENCS['system'])
+                macro_prefix = str(macro_prefix, ENCS['system'])
             if macro_prefix:
                 self.table['macro_prefix'] = macro_prefix
-        else:  # if type of macro_prefix is not bytes or string
+        else:  # if type of macro_prefix is not bytes or str
             raise TypeError('macro_prefix must be a string, not %s' %
                             type(macro_prefix).__name__)
         if macro_prefix == 'gl':
@@ -869,8 +867,8 @@ class GLConfig(object):
     def resetMacroPrefix(self):
         '''Reset the prefix of the macros 'gl_EARLY' and 'gl_INIT'.
         Default macro_prefix is 'gl'.'''
-        self.table['macro_prefix'] = string('gl')
-        include_guard_prefix = string('GL')
+        self.table['macro_prefix'] = 'gl'
+        include_guard_prefix = 'GL'
         if type(include_guard_prefix) is bytes:
             include_guard_prefix = include_guard_prefix.decode(ENCS['default'])
         self.table['include_guard_prefix'] = include_guard_prefix
@@ -884,19 +882,19 @@ class GLConfig(object):
     def setMakefile(self, makefile):
         '''Specify the name of makefile in automake syntax in the source-base and
         tests-base directories. Default is 'Makefile.am'.'''
-        if type(makefile) is bytes or type(makefile) is string:
+        if type(makefile) is bytes or type(makefile) is str:
             if type(makefile) is bytes:
-                makefile = string(makefile, ENCS['system'])
+                makefile = str(makefile, ENCS['system'])
             if makefile:
                 self.table['makefile'] = makefile
-        else:  # if type of makefile is not bytes or string
+        else:  # if type of makefile is not bytes or str
             raise TypeError('makefile must be a string, not %s' %
                             type(makefile).__name__)
 
     def resetMakefile(self):
         '''Reset the name of makefile in automake syntax in the source-base and
         tests-base directories. Default is 'Makefile.am'.'''
-        self.table['makefile'] = string()
+        self.table['makefile'] = ''
 
     # Define podomain methods.
     def getPoDomain(self):
@@ -907,19 +905,19 @@ class GLConfig(object):
     def setPoDomain(self, podomain):
         '''Specify the prefix of the i18n domain. Usually use the package name.
         A suffix '-gnulib' is appended.'''
-        if type(podomain) is bytes or type(podomain) is string:
+        if type(podomain) is bytes or type(podomain) is str:
             if type(podomain) is bytes:
-                podomain = string(podomain, ENCS['system'])
+                podomain = str(podomain, ENCS['system'])
             if podomain:
                 self.table['podomain'] = podomain
-        else:  # if type of podomain is not bytes or string
+        else:  # if type of podomain is not bytes or str
             raise TypeError('podomain must be a string, not %s' %
                             type(podomain).__name__)
 
     def resetPoDomain(self):
         '''Reset the prefix of the i18n domain. Usually use the package name.
         A suffix '-gnulib' is appended.'''
-        self.table['podomain'] = string()
+        self.table['podomain'] = ''
 
     # Define witness_c_macro methods.
     def getWitnessCMacro(self):
@@ -930,19 +928,19 @@ class GLConfig(object):
     def setWitnessCMacro(self, witness_c_macro):
         '''Specify the C macro that is defined when the sources in this directory
         are compiled or used.'''
-        if type(witness_c_macro) is bytes or type(witness_c_macro) is string:
+        if type(witness_c_macro) is bytes or type(witness_c_macro) is str:
             if type(witness_c_macro) is bytes:
-                witness_c_macro = string(witness_c_macro, ENCS['system'])
+                witness_c_macro = str(witness_c_macro, ENCS['system'])
             if witness_c_macro:
                 self.table['witness_c_macro'] = witness_c_macro
-        else:  # if type of witness_c_macro is not bytes or string
+        else:  # if type of witness_c_macro is not bytes or str
             raise TypeError('witness_c_macro must be a string, not %s' %
                             type(witness_c_macro).__name__)
 
     def resetWitnessCMacro(self):
         '''Return the C macro that is defined when the sources in this directory
         are compiled or used.'''
-        self.table['witness_c_macro'] = string()
+        self.table['witness_c_macro'] = ''
 
     # Define vc_files methods.
     def checkVCFiles(self):
@@ -985,19 +983,19 @@ class GLConfig(object):
 
     def setAutoconfFile(self, configure_ac):
         '''Specify path of autoconf file relative to destdir.'''
-        if type(configure_ac) is bytes or type(configure_ac) is string:
+        if type(configure_ac) is bytes or type(configure_ac) is str:
             if type(configure_ac) is bytes:
-                configure_ac = string(configure_ac, ENCS['system'])
+                configure_ac = str(configure_ac, ENCS['system'])
             if configure_ac:
                 self.table['configure_ac'] = \
                     relpath(self.table['destdir'], configure_ac)
-        else:  # if type of configure_ac is not bytes or string
+        else:  # if type of configure_ac is not bytes or str
             raise TypeError('configure_ac must be a string, not %s' %
                             type(configure_ac).__name__)
 
     def resetAutoconfFile(self):
         '''Reset path of autoconf file relative to destdir.'''
-        configure_ac = string()
+        configure_ac = ''
         if isfile(joinpath(self.table['destdir'], 'configure.ac')):
             configure_ac = joinpath(self.table['destdir'], 'configure.ac')
         elif isfile(joinpath(self.table['destdir'], 'configure.in')):
index 28c4943e614164d873ff1dbb02ea45adc1c06dce..64b58eb92a4aa4b1d0e7f395799b43e0971b4610 100644 (file)
@@ -44,7 +44,6 @@ __copyright__ = constants.__copyright__
 #===============================================================================
 # Define global constants
 #===============================================================================
-PYTHON3 = constants.PYTHON3
 NoneType = type(None)
 APP = constants.APP
 DIRS = constants.DIRS
@@ -55,7 +54,6 @@ TESTS = constants.TESTS
 compiler = constants.compiler
 joinpath = constants.joinpath
 cleaner = constants.cleaner
-string = constants.string
 isabs = os.path.isabs
 isdir = os.path.isdir
 isfile = os.path.isfile
@@ -85,11 +83,10 @@ class GLEmiter(object):
         return result
 
     def copyright_notice(self):
-        '''GLEmiter.copyright_notice() -> string
+        '''GLEmiter.copyright_notice() -> str
 
         Emit a header for a generated file.'''
-        emit = string()
-        emit += "# %s" % self.info.copyright()
+        emit = "# %s" % self.info.copyright()
         emit += """
 #
 # This file is free software; you can redistribute it and/or modify
@@ -119,7 +116,7 @@ class GLEmiter(object):
                         disable_libtool, disable_gettext, replace_auxdir, indentation):
         '''GLEmiter.autoconfSnippet(module, toplevel,
           disable_libtool, disable_gettext, replace_auxdir,
-          indentation) -> string
+          indentation) -> str
 
         Emit the autoconf snippet of a module.
         GLConfig: include_guard_prefix.
@@ -135,7 +132,7 @@ class GLEmiter(object):
         replace_auxdir is a bool variable; it tells whether to replace
           'build-aux' directory in AC_CONFIG_FILES.
         indentation is a string which contain spaces to prepend on each line.'''
-        emit = string()
+        emit = ''
         if type(module) is not GLModule:
             raise TypeError('module must be a GLModule, not %s' %
                             type(module).__name__)
@@ -151,10 +148,10 @@ class GLEmiter(object):
         if type(disable_gettext) is not bool:
             raise TypeError('disable_gettext must be a bool, not %s' %
                             type(disable_gettext).__name__)
-        if type(indentation) is bytes or type(indentation) is string:
+        if type(indentation) is bytes or type(indentation) is str:
             if type(indentation) is bytes:
                 indentation = indentation.decode(ENCS['default'])
-        else:  # if indentation has not bytes or string type
+        else:  # if indentation has not bytes or str type
             raise TypeError('indentation must be a string, not %s' %
                             type(indentation).__name__)
         if not indentation.isspace():
@@ -219,7 +216,7 @@ add AM_GNU_GETTEXT([external]) or similar to configure.ac.')
                          verifier, toplevel, disable_libtool, disable_gettext, replace_auxdir):
         '''GLEmiter.autoconfSnippets(modules, fileassistant,
           verifier, toplevel, disable_libtool, disable_gettext,
-          replace_auxdir) -> string
+          replace_auxdir) -> str
 
         Collect and emit the autoconf snippets of a set of modules.
         GLConfig: conddeps.
@@ -244,7 +241,7 @@ add AM_GNU_GETTEXT([external]) or similar to configure.ac.')
           AM_GNU_GETTEXT invocations.
         replace_auxdir is a bool variable; it tells whether to replace
           'build-aux' directory in AC_CONFIG_FILES.'''
-        emit = string()
+        emit = ''
         for module in modules:
             if type(module) is not GLModule:
                 raise TypeError('each module must be a GLModule instance')
@@ -374,7 +371,7 @@ add AM_GNU_GETTEXT([external]) or similar to configure.ac.')
         return emit
 
     def preEarlyMacros(self, require, indentation, modules):
-        '''GLEmiter.preEarlyMacros(require, indentation, modules) -> string
+        '''GLEmiter.preEarlyMacros(require, indentation, modules) -> str
 
         Collect and emit the pre-early section.
 
@@ -382,8 +379,7 @@ add AM_GNU_GETTEXT([external]) or similar to configure.ac.')
         indentation parameter is a string.
         modules argument represents list of modules; every module in this list must
           be a GLModule instance.'''
-        emit = string()
-        emit += '\n' + indentation + '# Pre-early section.\n'
+        emit = '\n' + indentation + '# Pre-early section.\n'
         # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB.
         # Doing AC_REQUIRE in configure-ac.early is not early enough.
         if any(str(module) == 'extensions' for module in modules):
@@ -399,14 +395,14 @@ add AM_GNU_GETTEXT([external]) or similar to configure.ac.')
         return emit
 
     def po_Makevars(self):
-        '''GLEmiter.po_Makevars() -> string
+        '''GLEmiter.po_Makevars() -> str
 
         Emit the contents of po/ makefile parameterization.
         GLConfig: pobase, podomain.'''
-        emit = string()
+        emit = ''
         pobase = self.config['pobase']
         podomain = self.config['podomain']
-        top_subdir = string()
+        top_subdir = ''
         source = '%s/' % os.path.normpath(pobase)
         if os.path.sep in source:
             for directory in source.split(os.path.sep):
@@ -466,11 +462,11 @@ USE_MSGCTXT = no\n"""
         return constants.nlconvert(emit)
 
     def po_POTFILES_in(self, files):
-        '''GLEmiter.po_POTFILES_in(files) -> string
+        '''GLEmiter.po_POTFILES_in(files) -> str
 
         Emit the file list to be passed to xgettext.
         GLConfig: sourcebase.'''
-        emit = string()
+        emit = ''
         sourcebase = self.config['sourcebase']
         sourcebase = '%s%s' % (self.sourcebase, os.path.sep)
         if type(sourcebase) is bytes:
@@ -487,14 +483,14 @@ USE_MSGCTXT = no\n"""
         return constants.nlconvert(emit)
 
     def initmacro_start(self, macro_prefix_arg):
-        '''GLEmiter.initmacro_start(macro_prefix_arg) -> string
+        '''GLEmiter.initmacro_start(macro_prefix_arg) -> str
 
         Emit the first few statements of the gl_INIT macro.'''
-        emit = string()
-        if type(macro_prefix_arg) is bytes or type(macro_prefix_arg) is string:
+        emit = ''
+        if type(macro_prefix_arg) is bytes or type(macro_prefix_arg) is str:
             if type(macro_prefix_arg) is bytes:
                 macro_prefix_arg = macro_prefix_arg.decode(ENCS['default'])
-        else:  # if macro_prefix_arg has not bytes or string type
+        else:  # if macro_prefix_arg has not bytes or str type
             raise TypeError('macro_prefix_arg must be a string, not %s' %
                             type(macro_prefix_arg).__name__)
         module_indicator_prefix = self.config.getModuleIndicatorPrefix()
@@ -539,14 +535,14 @@ USE_MSGCTXT = no\n"""
         return constants.nlconvert(emit)
 
     def initmacro_end(self, macro_prefix_arg):
-        '''GLEmiter.initmacro_end(macro_prefix_arg) -> string
+        '''GLEmiter.initmacro_end(macro_prefix_arg) -> str
 
         Emit the last few statements of the gl_INIT macro.'''
-        emit = string()
-        if type(macro_prefix_arg) is bytes or type(macro_prefix_arg) is string:
+        emit = ''
+        if type(macro_prefix_arg) is bytes or type(macro_prefix_arg) is str:
             if type(macro_prefix_arg) is bytes:
                 macro_prefix_arg = macro_prefix_arg.decode(ENCS['default'])
-        else:  # if macro_prefix_arg has not bytes or string type
+        else:  # if macro_prefix_arg has not bytes or str type
             raise TypeError('macro_prefix_arg must be a string, not %s' %
                             type(macro_prefix_arg).__name__)
         # Check the presence of files that are mentioned as AC_LIBSOURCES
@@ -594,21 +590,21 @@ found])])
         return constants.nlconvert(emit)
 
     def initmacro_done(self, macro_prefix_arg, sourcebase_arg):
-        '''GLEmiter.initmacro_done(macro_prefix_arg, sourcebase_arg) -> string
+        '''GLEmiter.initmacro_done(macro_prefix_arg, sourcebase_arg) -> str
 
         Emit a few statements after the gl_INIT macro.
         GLConfig: sourcebase.'''
-        emit = string()
-        if type(macro_prefix_arg) is bytes or type(macro_prefix_arg) is string:
+        emit = ''
+        if type(macro_prefix_arg) is bytes or type(macro_prefix_arg) is str:
             if type(macro_prefix_arg) is bytes:
                 macro_prefix_arg = macro_prefix_arg.decode(ENCS['default'])
-        else:  # if macro_prefix_arg has not bytes or string type
+        else:  # if macro_prefix_arg has not bytes or str type
             raise TypeError('macro_prefix_arg must be a string, not %s' %
                             type(macro_prefix_arg).__name__)
-        if type(sourcebase_arg) is bytes or type(sourcebase_arg) is string:
+        if type(sourcebase_arg) is bytes or type(sourcebase_arg) is str:
             if type(sourcebase_arg) is bytes:
                 sourcebase_arg = sourcebase_arg.decode(ENCS['default'])
-        else:  # if sourcebase_arg has not bytes or string type
+        else:  # if sourcebase_arg has not bytes or str type
             raise TypeError('sourcebase_arg must be a string, not %s' %
                             type(sourcebase_arg).__name__)
         emit += """\
@@ -648,9 +644,9 @@ AC_DEFUN([%V1%_LIBSOURCES], [
     def lib_Makefile_am(self, destfile, modules,
                         moduletable, makefiletable, actioncmd, for_test):
         '''GLEmiter.lib_Makefile_am(destfile, modules, moduletable, makefiletable,
-             actioncmd, for_test) -> tuple of string and bool
+             actioncmd, for_test) -> tuple of str and bool
 
-        Emit the contents of the library Makefile. Returns string and a bool
+        Emit the contents of the library Makefile. Returns str and a bool
         variable which shows if subdirectories are used.
         GLConfig: localdir, sourcebase, libname, pobase, auxdir, makefile, libtool,
         macro_prefix, podomain, conddeps, witness_c_macro.
@@ -663,10 +659,10 @@ AC_DEFUN([%V1%_LIBSOURCES], [
           an empty string e.g. when user wants to generate files for GLTestDir.
         for_test is a bool variable; it must be set to True if creating a package
           for testing, False otherwise.'''
-        if type(destfile) is bytes or type(destfile) is string:
+        if type(destfile) is bytes or type(destfile) is str:
             if type(destfile) is bytes:
                 destfile = destfile.decode(ENCS['default'])
-        else:  # if destfile has not bytes or string type
+        else:  # if destfile has not bytes or str type
             raise TypeError('destfile must be a string, not %s' %
                             type(destfile).__name__)
         for module in modules:
@@ -678,16 +674,16 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         if type(makefiletable) is not GLMakefileTable:
             raise TypeError('makefiletable must be a GLMakefileTable, not %s' %
                             type(makefiletable).__name__)
-        if type(actioncmd) is bytes or type(actioncmd) is string:
+        if type(actioncmd) is bytes or type(actioncmd) is str:
             if type(actioncmd) is bytes:
                 actioncmd = actioncmd.decode(ENCS['default'])
-        else:  # if actioncmd has not bytes or string type
+        else:  # if actioncmd has not bytes or str type
             raise TypeError('actioncmd must be a string, not %s' %
                             type(actioncmd).__name__)
         if type(for_test) is not bool:
             raise TypeError('for_test must be a bool, not %s' %
                             type(for_test).__name__)
-        emit = string()
+        emit = ''
         localdir = self.config['localdir']
         sourcebase = self.config['sourcebase']
         modcache = self.config['modcache']
@@ -737,7 +733,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         uses_subdirs = False
 
         # Modify allsnippets variable.
-        allsnippets = string()
+        allsnippets = ''
         for module in modules:
             if not module.isTests():
                 # Get conditional snippet, edit it and save to amsnippet1.
@@ -804,11 +800,11 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                             uses_subdirs = True
                             break
         if not makefile:
-            subdir_options = string()
+            subdir_options = ''
             # If there are source files in subdirectories, prevent collision of the
             # object files (example: hash.c and libxml/hash.c).
             if uses_subdirs:
-                subdir_options = string(' subdir-objects')
+                subdir_options = ' subdir-objects'
             emit += 'AUTOMAKE_OPTIONS = 1.9.6 gnits%s\n' % subdir_options
         emit += '\n'
         if not makefile:
@@ -853,8 +849,8 @@ AC_DEFUN([%V1%_LIBSOURCES], [
 
         # Define two parts of cppflags variable.
         emit += '\n'
-        cppflags_part1 = string()
-        cppflags_part2 = string()
+        cppflags_part1 = ''
+        cppflags_part2 = ''
         if witness_c_macro:
             cppflags_part1 = ' -D%s=1' % witness_c_macro
         if for_test:
@@ -942,7 +938,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         '''GLEmiter.tests_Makefile_am(destfile, modules, makefiletable,
              witness_c_macro, for_test) -> tuple of string and bool
 
-        Emit the contents of the tests Makefile. Returns string and a bool variable
+        Emit the contents of the tests Makefile. Returns str and a bool variable
         which shows if subdirectories are used.
         GLConfig: localdir, modules, libname, auxdir, makefile, libtool,
         sourcebase, m4base, testsbase, macro_prefix, witness_c_macro,
@@ -957,10 +953,10 @@ AC_DEFUN([%V1%_LIBSOURCES], [
           an empty string e.g. when user wants to generate files for GLTestDir.
         for_test is a bool variable; it must be set to True if creating a package
           for testing, False otherwise.'''
-        if type(destfile) is bytes or type(destfile) is string:
+        if type(destfile) is bytes or type(destfile) is str:
             if type(destfile) is bytes:
                 destfile = destfile.decode(ENCS['default'])
-        else:  # if destfile has not bytes or string type
+        else:  # if destfile has not bytes or str type
             raise TypeError('destfile must be a string, not %s' %
                             type(destfile).__name__)
         for module in modules:
@@ -969,16 +965,16 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         if type(makefiletable) is not GLMakefileTable:
             raise TypeError('makefiletable must be a GLMakefileTable, not %s' %
                             type(makefiletable).__name__)
-        if type(witness_macro) is bytes or type(witness_macro) is string:
+        if type(witness_macro) is bytes or type(witness_macro) is str:
             if type(witness_macro) is bytes:
                 witness_macro = witness_macro.decode(ENCS['default'])
-        else:  # if witness_macro has not bytes or string type
+        else:  # if witness_macro has not bytes or str type
             raise TypeError('witness_macro must be a string, not %s' %
                             type(witness_macro).__name__)
         if type(for_test) is not bool:
             raise TypeError('for_test must be a bool, not %s' %
                             type(for_test).__name__)
-        emit = string()
+        emit = ''
         localdir = self.config['localdir']
         auxdir = self.config['auxdir']
         sourcebase = self.config['sourcebase']
@@ -1018,7 +1014,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
 
         # Calculate testsbase_inverse
         counter = int()
-        testsbase_inverse = string()
+        testsbase_inverse = ''
         while counter < len(testsbase.split('/')):
             testsbase_inverse += '../'
             counter += 1
@@ -1030,8 +1026,8 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         emit += '%s\n' % self.copyright_notice()
 
         uses_subdirs = False
-        main_snippets = string()
-        longrun_snippets = string()
+        main_snippets = ''
+        longrun_snippets = ''
         for module in modules:
             if for_test and not single_configure:
                 flag = module.isTests()
@@ -1099,9 +1095,9 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         # Generate dependencies here, since it eases the debugging of test failures.
         # If there are source files in subdirectories, prevent collision of the
         # object files (example: hash.c and libxml/hash.c).
-        subdir_options = string()
+        subdir_options = ''
         if uses_subdirs:
-            subdir_options = string(' subdir-objects')
+            subdir_options = ' subdir-objects'
         emit += 'AUTOMAKE_OPTIONS = 1.9.6 foreign%s\n\n' % subdir_options
         if for_test and not single_configure:
             emit += 'ACLOCAL_AMFLAGS = -I %s/%s\n\n' % (
index 66838e56e60398afbaa11ee0860d1a877c6ea3f9..5c1f9a72c367455eb053c1fc0fd8b6d54566d3f2 100644 (file)
@@ -35,7 +35,6 @@ __copyright__ = constants.__copyright__
 #===============================================================================
 # Define global constants
 #===============================================================================
-PYTHON3 = constants.PYTHON3
 NoneType = type(None)
 APP = constants.APP
 DIRS = constants.DIRS
@@ -46,7 +45,6 @@ TESTS = constants.TESTS
 compiler = constants.compiler
 joinpath = constants.joinpath
 cleaner = constants.cleaner
-string = constants.string
 isabs = os.path.isabs
 isdir = os.path.isdir
 isfile = os.path.isfile
@@ -118,10 +116,5 @@ class GLError(Exception):
                 "module lacks a license: %s" % repr(errinfo),
                 "error when running subprocess: %s" % repr(errinfo),
             ]  # Complete list of errors
-        if not PYTHON3:
-            self.message = (b'[Errno %d] %s' %
-                            (self.errno, errors[self.errno - 1].encode(ENCS['default'])))
-        else:  # if PYTHON3
-            self.message = ('[Errno %d] %s' %
-                            (self.errno, errors[self.errno - 1]))
+        self.message = '[Errno %d] %s' % (self.errno, errors[self.errno - 1])
         return self.message
index b41c029cd1eec8172a47fb8eee42b9b75847f958..0aaf0e59655e9b4eb0d6666b83b5a01906d2d6a9 100644 (file)
@@ -39,7 +39,6 @@ __copyright__ = constants.__copyright__
 #===============================================================================
 # Define global constants
 #===============================================================================
-PYTHON3 = constants.PYTHON3
 NoneType = type(None)
 APP = constants.APP
 DIRS = constants.DIRS
@@ -50,7 +49,6 @@ TESTS = constants.TESTS
 compiler = constants.compiler
 joinpath = constants.joinpath
 cleaner = constants.cleaner
-string = constants.string
 isabs = os.path.isabs
 isdir = os.path.isdir
 isfile = os.path.isfile
@@ -88,10 +86,10 @@ class GLFileSystem(object):
         GLError telling that file was not found. Function also returns flag which
         indicates whether file is a temporary file.
         GLConfig: localdir.'''
-        if type(name) is bytes or type(name) is string:
+        if type(name) is bytes or type(name) is str:
             if type(name) is bytes:
                 name = name.decode(ENCS['default'])
-        else:  # if name has not bytes or string type
+        else:  # if name has not bytes or str type
             raise TypeError(
                 'name must be a string, not %s' % type(module).__name__)
         # If name exists in localdir, then we use it
@@ -143,10 +141,10 @@ class GLFileAssistant(object):
                 transformers[key] = 's,x,x,'
             else:  # if key in transformers
                 value = transformers[key]
-                if type(value) is bytes or type(value) is string:
+                if type(value) is bytes or type(value) is str:
                     if type(value) is bytes:
                         transformers[key] = value.decode(ENCS['default'])
-                else:  # if value has not bytes or string type
+                else:  # if value has not bytes or str type
                     raise TypeError('transformers[%s] must be a string, not %s' %
                                     (key, type(value).__name__))
         self.original = None
@@ -163,13 +161,13 @@ class GLFileAssistant(object):
         return result
 
     def tmpfilename(self, path):
-        '''GLFileAssistant.tmpfilename() -> string
+        '''GLFileAssistant.tmpfilename() -> str
 
         Return the name of a temporary file (file is relative to destdir).'''
-        if type(path) is bytes or type(path) is string:
+        if type(path) is bytes or type(path) is str:
             if type(path) is bytes:
                 path = path.decode(ENCS['default'])
-        else:  # if path has not bytes or string type
+        else:  # if path has not bytes or str type
             raise TypeError(
                 'path must be a string, not %s' % (type(path).__name__))
         if not self.config['dryrun']:
@@ -195,10 +193,10 @@ class GLFileAssistant(object):
         '''GLFileAssistant.setOriginal(original)
 
         Set the name of the original file which will be used.'''
-        if type(original) is bytes or type(original) is string:
+        if type(original) is bytes or type(original) is str:
             if type(original) is bytes:
                 original = original.decode(ENCS['default'])
-        else:  # if original has not bytes or string type
+        else:  # if original has not bytes or str type
             raise TypeError(
                 'original must be a string, not %s' % (type(original).__name__))
         self.original = original
@@ -207,10 +205,10 @@ class GLFileAssistant(object):
         '''GLFileAssistant.setRewritten(rewritten)
 
         Set the name of the rewritten file which will be used.'''
-        if type(rewritten) is bytes or type(rewritten) is string:
+        if type(rewritten) is bytes or type(rewritten) is str:
             if type(rewritten) is bytes:
                 rewritten = rewritten.decode(ENCS['default'])
-        else:  # if rewritten has not bytes or string type
+        else:  # if rewritten has not bytes or str type
             raise TypeError(
                 'rewritten must be a string, not %s' % type(rewritten).__name__)
         self.rewritten = rewritten
@@ -278,17 +276,17 @@ class GLFileAssistant(object):
             raise TypeError('original must be set before applying the method')
         elif rewritten == None:
             raise TypeError('rewritten must be set before applying the method')
-        if type(lookedup) is bytes or type(lookedup) is string:
+        if type(lookedup) is bytes or type(lookedup) is str:
             if type(lookedup) is bytes:
                 lookedup = lookedup.decode(ENCS['default'])
-        else:  # if lookedup has not bytes or string type
+        else:  # if lookedup has not bytes or str type
             raise TypeError('lookedup must be a string, not %s' %
                             type(lookedup).__name__)
         if type(already_present) is not bool:
             raise TypeError('already_present must be a bool, not %s' %
                             type(already_present).__name__)
         basename = rewritten
-        backupname = string('%s~' % basename)
+        backupname = '%s~' % basename
         basepath = joinpath(destdir, basename)
         backuppath = joinpath(destdir, backupname)
         if not filecmp.cmp(basepath, tmpfile):
@@ -355,7 +353,7 @@ class GLFileAssistant(object):
             raise GLError(15, lookedup)
         # Don't process binary files with sed.
         if not (original.endswith(".class") or original.endswith(".mo")):
-            transformer = string()
+            transformer = ''
             if original.startswith('lib/'):
                 if sed_transform_main_lib_file:
                     transformer = sed_transform_main_lib_file
index ca7a00d5de448a8bdae4c96b3e380c4d75baef7b..0a58a0833b9bf8622e204f84d30319c7a552d308 100644 (file)
@@ -47,7 +47,6 @@ __copyright__ = constants.__copyright__
 #===============================================================================
 # Define global constants
 #===============================================================================
-PYTHON3 = constants.PYTHON3
 NoneType = type(None)
 APP = constants.APP
 DIRS = constants.DIRS
@@ -59,7 +58,6 @@ compiler = constants.compiler
 joinpath = constants.joinpath
 cleaner = constants.cleaner
 relpath = constants.relativize
-string = constants.string
 isabs = os.path.isabs
 isdir = os.path.isdir
 isfile = os.path.isfile
@@ -303,7 +301,7 @@ class GLImport(object):
                 for file in files
             ]  # Finish to convert bytes to string
         for file in files:
-            if type(file) is not string:
+            if type(file) is not str:
                 raise TypeError('each file must be a string instance')
         files = sorted(set(files))
         files = ['%s%s' % (file, os.path.sep) for file in files]
@@ -350,7 +348,7 @@ class GLImport(object):
                 for file in files
             ]  # Finish to convert bytes to string
         for file in files:
-            if type(file) is not string:
+            if type(file) is not str:
                 raise TypeError('each file must be a string instance')
         files = sorted(set(files))
         auxdir = self.config['auxdir']
@@ -463,12 +461,12 @@ class GLImport(object):
         return actioncmd
 
     def gnulib_cache(self):
-        '''GLImport.gnulib_cache() -> string
+        '''GLImport.gnulib_cache() -> str
 
         Emit the contents of generated $m4base/gnulib-cache.m4 file.
         GLConfig: destdir, localdir, tests, sourcebase, m4base, pobase, docbase,
         testsbase, conddeps, libtool, macro_prefix, podomain, vc_files.'''
-        emit = string()
+        emit = ''
         moduletable = self.moduletable
         actioncmd = self.actioncmd()
         destdir = self.config['destdir']
@@ -550,12 +548,12 @@ gnulib-tool.m4 macro invocations:\n''' % actioncmd
         return constants.nlconvert(emit)
 
     def gnulib_comp(self, files):
-        '''GLImport.gnulib_comp(files) -> string
+        '''GLImport.gnulib_comp(files) -> str
 
         Emit the contents of generated $m4base/gnulib-comp.m4 file.
         GLConfig: destdir, localdir, tests, sourcebase, m4base, pobase, docbase,
         testsbase, conddeps, libtool, macro_prefix, podomain, vc_files.'''
-        emit = string()
+        emit = ''
         assistant = self.assistant
         moduletable = self.moduletable
         destdir = self.config['destdir']
@@ -714,7 +712,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         '''GLImport._update_ignorelist_(directory, ignore, dirs_added, dirs_removed)
 
         Update .gitignore or .cvsignore files.'''
-        result = string()
+        result = ''
         destdir = self.config['destdir']
         if ignore == '.gitignore':
             anchor = '/'
@@ -739,7 +737,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
                         print('Updating %s (backup in %s)' %
                               (srcpath, backupname))
                         shutil.copy2(srcpath, backupname)
-                        result = string()
+                        result = ''
                         with codecs.open(srcpath, 'ab', 'UTF-8') as file:
                             file.write(destdata)
                     else:  # if self.config['dryrun']
@@ -848,7 +846,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         # Check license incompatibilities.
         listing = list()
         compatibilities = dict()
-        incompatibilities = string()
+        incompatibilities = ''
         compatibilities['all'] = ['GPLv2+ build tool', 'GPLed build tool',
                                   'public domain', 'unlimited',
                                   'unmodifiable license text']
@@ -884,7 +882,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
       s/GNU Library General/GNU General/g
       s/Library General Public License/General Public License/g
       s/version 2\\(.1\\)\\{0,1\\}\\([ ,]\\)/version 3\\2/g'''
-        sed_transform_lib_file = string()
+        sed_transform_lib_file = ''
         if 'config-h' in [str(module) for module in main_modules]:
             sed_transform_lib_file += '''
         s/^#ifdef[\t ]*HAVE_CONFIG_H[\t ]*$/#if 1/
@@ -909,7 +907,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
                 sed_transform_main_lib_file += lgpl2gpl
 
         # Determine script to apply to auxiliary files that go into $auxdir/.
-        sed_transform_build_aux_file = string()
+        sed_transform_build_aux_file = ''
         if copyrights:
             sed_transform_build_aux_file += lgpl2gpl
 
@@ -922,7 +920,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         main_filelist, tests_filelist = \
             self.moduletable.filelist_separately(main_modules, tests_modules)
         filelist = sorted(
-            set(main_filelist + tests_filelist), key=string.lower)
+            set(main_filelist + tests_filelist), key=str.lower)
         if not filelist:
             raise GLError(12, None)
 
@@ -946,10 +944,10 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
 
         # Construct tables and transformers.
         transformers = dict()
-        transformers['lib'] = string(sed_transform_lib_file)
-        transformers['aux'] = string(sed_transform_build_aux_file)
-        transformers['main'] = string(sed_transform_main_lib_file)
-        transformers['tests'] = string(sed_transform_testsrelated_lib_file)
+        transformers['lib'] = sed_transform_lib_file
+        transformers['aux'] = sed_transform_build_aux_file
+        transformers['main'] = sed_transform_main_lib_file
+        transformers['tests'] = sed_transform_testsrelated_lib_file
         old_table = list()
         new_table = list()
         for src in old_files:
@@ -1043,7 +1041,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
             path = joinpath(destdir, file)
             if isfile(path) or os.path.islink(path):
                 if not self.config['dryrun']:
-                    backup = string('%s~' % path)
+                    backup = '%s~' % path
                     print('Removing file %s (backup in )' % (path, backup))
                     try:  # Try to move file
                         if os.path.exists(backup):
@@ -1088,7 +1086,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
 
         # Determine makefile name.
         if not makefile:
-            makefile_am = string('Makefile.am')
+            makefile_am = 'Makefile.am'
         else:  # if makefile
             makefile_am = makefile
 
@@ -1226,7 +1224,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
             basename = joinpath(pobase, 'LINGUAS')
             if not self.config['dryrun']:
                 tmpfile = self.assistant.tmpfilename(basename)
-                data = string('# Set of available languages.\n')
+                data = '# Set of available languages.\n'
                 files = [constants.subend('.po', '', file)
                          for file in os.listdir(joinpath(destdir, pobase))]
                 files = [file.decode(ENCS['default']) if type(file) is bytes
@@ -1336,7 +1334,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         for file in filetable['removed']:
             directory, basename = os.path.split(file)
             ignorelist += [tuple([directory, '|R|', basename])]
-        last_dir = string()
+        last_dir = ''
         last_dirs_added = list()
         last_dirs_removed = list()
         for row in ignorelist:
index d21e09f43dfd9c55306ce5a543a316071cb64a2a..347d7a4cc9e28333d0e4b2f4c1011e9be1ce75f0 100644 (file)
@@ -36,7 +36,6 @@ __copyright__ = constants.__copyright__
 #===============================================================================
 # Define global constants
 #===============================================================================
-PYTHON3 = constants.PYTHON3
 NoneType = type(None)
 APP = constants.APP
 DIRS = constants.DIRS
@@ -47,7 +46,6 @@ TESTS = constants.TESTS
 compiler = constants.compiler
 joinpath = constants.joinpath
 cleaner = constants.cleaner
-string = constants.string
 isabs = os.path.isabs
 isdir = os.path.isdir
 isfile = os.path.isfile
@@ -77,7 +75,7 @@ class GLInfo(object):
     def authors(self):
         '''Return formatted string which contains authors.
         The special __author__ variable is used (type is list).'''
-        result = string()
+        result = ''
         for item in __author__:
             if item == __author__[-2]:
                 result += '%s ' % item
@@ -106,7 +104,7 @@ class GLInfo(object):
         '''Return formatted string which contains date and time in GMT format.'''
         if isdir(DIRS['git']):
             counter = int()  # Create counter
-            result = string()  # Create string
+            result = ''  # Create string
             args = ['git', 'log']
             result = sp.check_output(args).decode("UTF-8")
             # Get date as "Fri Mar 21 07:16:51 2008 -0600" from string
@@ -118,7 +116,7 @@ class GLInfo(object):
             # Use GNU date to compute the time in GMT
             args = ['date', '-d', result, '-u', '+%Y-%m-%d %H:%M:%S']
             proc = sp.check_output(args)
-            result = string(proc, "UTF-8")
+            result = str(proc, "UTF-8")
             result = result.rstrip(os.linesep)
             return result
 
@@ -309,5 +307,5 @@ Report bugs to <bug-gnulib@gnu.org>.'''
             result = sp.check_output(args).decode("UTF-8")
             result = result.strip()
             if result == 'UNKNOWN':
-                result = string()
+                result = ''
             return result
index 64fca0ff53bf171cb12bb95b52a17d949418828b..c535180f1fbd822dfd8eacca7758ca8cf8940a6d 100644 (file)
@@ -39,7 +39,6 @@ __copyright__ = constants.__copyright__
 #===============================================================================
 # Define global constants
 #===============================================================================
-PYTHON3 = constants.PYTHON3
 NoneType = type(None)
 APP = constants.APP
 DIRS = constants.DIRS
@@ -50,7 +49,6 @@ TESTS = constants.TESTS
 compiler = constants.compiler
 joinpath = constants.joinpath
 cleaner = constants.cleaner
-string = constants.string
 isabs = os.path.isabs
 isdir = os.path.isdir
 isfile = os.path.isfile
@@ -89,22 +87,22 @@ class GLMakefileTable(object):
 
         This method is used to remember that ${dir}Makefile.am needs to be edited
         to that ${var} mentions ${val}.'''
-        if type(dir) is bytes or type(dir) is string:
+        if type(dir) is bytes or type(dir) is str:
             if type(dir) is bytes:
                 dir = dir.decode(ENCS['default'])
-        else:  # if dir has not bytes or string type
+        else:  # if dir has not bytes or str type
             raise TypeError(
                 'dir must be a string, not %s' % (type(dir).__name__))
-        if type(var) is bytes or type(var) is string:
+        if type(var) is bytes or type(var) is str:
             if type(var) is bytes:
                 var = var.decode(ENCS['default'])
-        else:  # if var has not bytes or string type
+        else:  # if var has not bytes or str type
             raise TypeError(
                 'var must be a string, not %s' % (type(var).__name__))
-        if type(val) is bytes or type(val) is string:
+        if type(val) is bytes or type(val) is str:
             if type(val) is bytes:
                 val = val.decode(ENCS['default'])
-        else:  # if val has not bytes or string type
+        else:  # if val has not bytes or str type
             raise TypeError(
                 'val must be a string, not %s' % (type(val).__name__))
         dictionary = {'dir': dir, 'var': var, 'val': val}
@@ -121,13 +119,13 @@ class GLMakefileTable(object):
         testsbase = self.config['testsbase']
         makefile = self.config['makefile']
         inctests = self.config.checkTestFlag(TESTS['tests'])
-        dir1 = string('%s%s' % (m4base, os.path.sep))
-        mfd = string('Makefile.am')
+        dir1 = '%s%s' % (m4base, os.path.sep)
+        mfd = 'Makefile.am'
         if not makefile:
-            mfx = string('Makefile.am')
+            mfx = 'Makefile.am'
         else:  # if makefile
             mfx = makefile
-        dir2 = string()
+        dir2 = ''
         while dir1 and \
             (joinpath(self.config['destdir'], dir1, mfd)
              or joinpath(dir1, mfd) == joinpath(sourcebase, mfx)
index 728f9f56101b001a4fae5a1d3e622049f863e13b..150499eca182b2103d1ac0711034ef75fe78e067 100644 (file)
@@ -39,7 +39,6 @@ __copyright__ = constants.__copyright__
 #===============================================================================
 # Define global constants
 #===============================================================================
-PYTHON3 = constants.PYTHON3
 NoneType = type(None)
 APP = constants.APP
 DIRS = constants.DIRS
@@ -50,7 +49,6 @@ TESTS = constants.TESTS
 compiler = constants.compiler
 joinpath = constants.joinpath
 cleaner = constants.cleaner
-string = constants.string
 isabs = os.path.isabs
 isdir = os.path.isdir
 isfile = os.path.isfile
@@ -89,10 +87,10 @@ class GLModuleSystem(object):
 
         Check whether the given module exists.
         GLConfig: localdir.'''
-        if type(module) is bytes or string:
+        if type(module) is bytes or str:
             if type(module) is bytes:
                 module = module.decode(ENCS['default'])
-        else:  # if module has not bytes or string type
+        else:  # if module has not bytes or str type
             raise TypeError(
                 'module must be a string, not %s' % type(module).__name__)
         result = bool()
@@ -113,10 +111,10 @@ class GLModuleSystem(object):
         '''GLModuleSystem.find(module) -> GLModule
 
         Find the given module.'''
-        if type(module) is bytes or string:
+        if type(module) is bytes or str:
             if type(module) is bytes:
                 module = module.decode(ENCS['default'])
-        else:  # if module has not bytes or string type
+        else:  # if module has not bytes or str type
             raise TypeError(
                 'module must be a string, not %s' % type(module).__name__)
         if self.exists(module):
@@ -136,7 +134,7 @@ class GLModuleSystem(object):
         Return the available module names as tuple. We could use a combination
         of os.walk() function and re module. However, it takes too much time to
         complete, so this version uses subprocess to run shell commands.'''
-        result = string()
+        result = ''
         listing = list()
         localdir = self.config['localdir']
         find_args = ['find', 'modules', '-type', 'f', '-print']
@@ -203,14 +201,14 @@ class GLModule(object):
         bool indicating that module was created after applying patch.'''
         self.args = dict()
         self.cache = dict()
-        self.content = string()
+        self.content = ''
         if type(config) is not GLConfig:
             raise TypeError('config must be a GLConfig, not %s' %
                             type(config).__name__)
-        if type(module) is bytes or type(module) is string:
+        if type(module) is bytes or type(module) is str:
             if type(module) is bytes:
                 module = module.decode(ENCS['default'])
-        else:  # if module has not bytes or string type
+        else:  # if module has not bytes or str type
             raise TypeError('module must be a string, not %s' %
                             type(module).__name__)
         if type(patched) is not bool:
@@ -294,7 +292,7 @@ Include:|Link:|License:|Maintainer:)'
         return result
 
     def getName(self):
-        '''GLModule.getName() -> string
+        '''GLModule.getName() -> str
 
         Return the name of the module.'''
         pattern = compiler(joinpath('modules', '(.*?)$'))
@@ -334,7 +332,7 @@ Include:|Link:|License:|Maintainer:)'
         return result
 
     def getShellFunc(self):
-        '''GLModule.getShellFunc() -> string
+        '''GLModule.getShellFunc() -> str
 
         Computes the shell function name that will contain the m4 macros for the
         module.'''
@@ -348,7 +346,7 @@ Include:|Link:|License:|Maintainer:)'
             module = str(self)
         else:  # if not isalnum
             module = '%s\n' % str(self)
-            if type(module) is string:
+            if type(module) is str:
                 module = module.encode(ENCS['default'])
             module = hashlib.md5(module).hexdigest()
         result = 'func_%s_gnulib_m4code_%s' % (macro_prefix, module)
@@ -357,7 +355,7 @@ Include:|Link:|License:|Maintainer:)'
         return result
 
     def getShellVar(self):
-        '''GLModule.getShellVar() -> string
+        '''GLModule.getShellVar() -> str
 
         Compute the shell variable name the will be set to true once the m4 macros
         for the module have been executed.'''
@@ -371,7 +369,7 @@ Include:|Link:|License:|Maintainer:)'
             module = str(self)
         else:  # if not isalnum
             module = '%s\n' % str(self)
-            if type(module) is string:
+            if type(module) is str:
                 module = module.encode(ENCS['default'])
             module = hashlib.md5(module).hexdigest()
         result = '%s_gnulib_enabled_%s' % (macro_prefix, module)
@@ -380,7 +378,7 @@ Include:|Link:|License:|Maintainer:)'
         return result
 
     def getConditionalName(self):
-        '''GLModule.getConditionalName() -> string
+        '''GLModule.getConditionalName() -> str
 
         Return the automake conditional name.
         GLConfig: macro_prefix.'''
@@ -401,20 +399,20 @@ Include:|Link:|License:|Maintainer:)'
         return result
 
     def getDescription(self):
-        '''GLModule.getDescription() -> string
+        '''GLModule.getDescription() -> str
 
         Return description of the module.'''
         section = 'Description:'
         if 'description' not in self.cache:
             if section not in self.content:
-                result = string()
+                result = ''
             else:  # if section in self.content
                 pattern = '^%s[\t ]*(.*?)%s' % (section, self.regex)
                 pattern = compiler(pattern, re.S | re.M)
                 result = pattern.findall(self.content)
                 if type(result) is list:
                     if not result:
-                        result = string()
+                        result = ''
                     else:  # if result
                         result = result[-1]
             result = result.strip()
@@ -422,20 +420,20 @@ Include:|Link:|License:|Maintainer:)'
         return self.cache['description']
 
     def getComment(self):
-        '''GLModule.getComment() -> string
+        '''GLModule.getComment() -> str
 
         Return comment to module.'''
         section = 'Comment:'
         if 'comment' not in self.cache:
             if section not in self.content:
-                result = string()
+                result = ''
             else:  # if section in self.content
                 pattern = '^%s[\t ]*(.*?)%s' % (section, self.regex)
                 pattern = compiler(pattern, re.S | re.M)
                 result = pattern.findall(self.content)
                 if type(result) is list:
                     if not result:
-                        result = string()
+                        result = ''
                     else:  # if result
                         result = result[-1]
             result = result.strip()
@@ -443,13 +441,13 @@ Include:|Link:|License:|Maintainer:)'
         return self.cache['comment']
 
     def getStatus(self):
-        '''GLModule.getStatus() -> string
+        '''GLModule.getStatus() -> str
 
         Return module status.'''
         section = 'Status:'
         if 'status' not in self.cache:
             if section not in self.content:
-                result = string()
+                result = ''
             else:  # if section in self.content
                 snippet = self.content.split(section)[-1]
                 snippet = snippet.replace('\r\n', '\n')
@@ -469,13 +467,13 @@ Include:|Link:|License:|Maintainer:)'
         return list(self.cache['status'])
 
     def getNotice(self):
-        '''GLModule.getNotice() -> string
+        '''GLModule.getNotice() -> str
 
         Return notice to module.'''
         section = 'Notice:'
         if 'notice' not in self.cache:
             if section not in self.content:
-                result = string()
+                result = ''
             else:  # if section in self.content
                 snippet = self.content.split(section)[-1]
                 snippet = snippet.replace('\r\n', '\n')
@@ -495,13 +493,13 @@ Include:|Link:|License:|Maintainer:)'
         return self.cache['notice']
 
     def getApplicability(self):
-        '''GLModule.getApplicability() -> string
+        '''GLModule.getApplicability() -> str
 
         Return applicability of module.'''
         section = 'Applicability:'
         if 'applicability' not in self.cache:
             if section not in self.content:
-                result = string()
+                result = ''
             else:  # if section in self.content
                 snippet = self.content.split(section)[-1]
                 snippet = snippet.replace('\r\n', '\n')
@@ -606,13 +604,13 @@ Include:|Link:|License:|Maintainer:)'
         return list(self.cache['dependencies'])
 
     def getAutoconfSnippet_Early(self):
-        '''GLModule.getAutoconfSnippet_Early() -> string
+        '''GLModule.getAutoconfSnippet_Early() -> str
 
         Return autoconf-early snippet.'''
         section = 'configure.ac-early:'
         if 'autoconf-early' not in self.cache:
             if section not in self.content:
-                result = string()
+                result = ''
             else:  # if section in self.content
                 snippet = self.content.split(section)[-1]
                 snippet = snippet.replace('\r\n', '\n')
@@ -632,13 +630,13 @@ Include:|Link:|License:|Maintainer:)'
         return self.cache['autoconf-early']
 
     def getAutoconfSnippet(self):
-        '''GLModule.getAutoconfSnippet() -> string
+        '''GLModule.getAutoconfSnippet() -> str
 
         Return autoconf snippet.'''
         section = 'configure.ac:'
         if 'autoconf' not in self.cache:
             if section not in self.content:
-                result = string()
+                result = ''
             else:  # if section in self.content
                 snippet = self.content.split(section)[-1]
                 snippet = snippet.replace('\r\n', '\n')
@@ -658,11 +656,11 @@ Include:|Link:|License:|Maintainer:)'
         return self.cache['autoconf']
 
     def getAutomakeSnippet(self):
-        '''getAutomakeSnippet() -> string
+        '''getAutomakeSnippet() -> str
 
         Get automake snippet.
         GLConfig: auxdir, ac_version.'''
-        result = string()  # Define stack variable
+        result = ''
         conditional = self.getAutomakeSnippet_Conditional()
         if conditional.strip():
             result += self.getAutomakeSnippet_Conditional()
@@ -672,13 +670,13 @@ Include:|Link:|License:|Maintainer:)'
         return result
 
     def getAutomakeSnippet_Conditional(self):
-        '''GLModule.getAutomakeSnippet_Conditional() -> string
+        '''GLModule.getAutomakeSnippet_Conditional() -> str
 
         Return conditional automake snippet.'''
         section = 'Makefile.am:'
         if 'makefile-conditional' not in self.cache:
             if section not in self.content:
-                result = string()
+                result = ''
             else:  # if section in self.content
                 snippet = self.content.split(section)[-1]
                 snippet = snippet.replace('\r\n', '\n')
@@ -698,13 +696,13 @@ Include:|Link:|License:|Maintainer:)'
         return self.cache['makefile-conditional']
 
     def getAutomakeSnippet_Unconditional(self):
-        '''GLModule.getAutomakeSnippet_Unconditional() -> string
+        '''GLModule.getAutomakeSnippet_Unconditional() -> str
 
         Return unconditional automake snippet.
         GLConfig: auxdir, ac_version.'''
         auxdir = self.config['auxdir']
         ac_version = self.config['ac_version']
-        result = string()
+        result = ''
         if 'makefile-unconditional' not in self.cache:
             if self.isTests():
                 files = self.getFiles()
@@ -712,8 +710,7 @@ Include:|Link:|License:|Maintainer:)'
                                               'tests/', '', 'tests/', '').split(constants.NL)
                 extra_files = sorted(set(extra_files))
                 if extra_files:
-                    result += string('EXTRA_DIST += %s' %
-                                     ' '.join(extra_files))
+                    result += 'EXTRA_DIST += %s' % ' '.join(extra_files)
                     result += constants.NL * 2
             else:  # if not tests module
                 # TODO: unconditional automake snippet for nontests modules
@@ -734,8 +731,7 @@ Include:|Link:|License:|Maintainer:)'
                     f for f in lib_files if f not in mentioned_files]
                 extra_files = sorted(set(extra_files))
                 if extra_files != [''] and extra_files:
-                    result += string('EXTRA_DIST += %s' %
-                                     ' '.join(extra_files))
+                    result += 'EXTRA_DIST += %s' % ' '.join(extra_files)
                     result += '\n\n'
                 # Synthesize also an EXTRA_lib_SOURCES augmentation
                 if str(self) != 'relocatable-prog-wrapper' and str(self) != 'pt_chown':
@@ -743,8 +739,7 @@ Include:|Link:|License:|Maintainer:)'
                                                   '', '.c', '', '').split(constants.NL)
                     extra_files = sorted(set(extra_files))
                     if extra_files != ['']:
-                        result += string('EXTRA_lib_SOURCES += %s' %
-                                         ' '.join(extra_files))
+                        result += 'EXTRA_lib_SOURCES += %s' % ' '.join(extra_files)
                         result += '\n\n'
                 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux
                 buildaux_files = filter_filelist(constants.NL, all_files,
@@ -754,7 +749,7 @@ Include:|Link:|License:|Maintainer:)'
                     buildaux_files = ''.join(buildaux_files)
                     buildaux_files = joinpath(
                         '$(top_srcdir)', auxdir, buildaux_files)
-                    result += string('EXTRA_DIST += %s' % buildaux_files)
+                    result += 'EXTRA_DIST += %s' % buildaux_files
                     result += '\n\n'
                 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
                 top_files = filter_filelist(constants.NL, all_files,
@@ -763,20 +758,20 @@ Include:|Link:|License:|Maintainer:)'
                 if top_files != ['']:
                     top_files = ''.join(top_files)
                     top_files = joinpath('$(top_srcdir)', top_files)
-                    result += string('EXTRA_DIST += %s' % top_files)
+                    result += 'EXTRA_DIST += %s' % top_files
                     result += '\n\n'
             result = constants.nlconvert(result)
             self.cache['makefile-unconditional'] = result
         return self.cache['makefile-unconditional']
 
     def getInclude(self):
-        '''GLModule.getInclude() -> string
+        '''GLModule.getInclude() -> str
 
         Return include directive.'''
         section = 'Include:'
         if 'include' not in self.cache:
             if section not in self.content:
-                result = string()
+                result = ''
             else:  # if section in self.content
                 snippet = self.content.split(section)[-1]
                 snippet = snippet.replace('\r\n', '\n')
@@ -799,7 +794,7 @@ Include:|Link:|License:|Maintainer:)'
         return self.cache['include']
 
     def getLink(self):
-        '''GLModule.getLink() -> string
+        '''GLModule.getLink() -> str
 
         Return link directive.'''
         section = 'Link:'
@@ -824,14 +819,14 @@ Include:|Link:|License:|Maintainer:)'
         return self.cache['link']
 
     def getLicense(self):
-        '''GLModule.getLicense(self) -> string
+        '''GLModule.getLicense(self) -> str
 
         Get license and warn user if module lacks a license.'''
         license = self.getLicense_Raw()
         if not self.isTests():
             if not license:
                 if self.config['errors']:
-                    raise GLError(18, string(self))
+                    raise GLError(18, str(self))
                 else:  # if not self.config['errors']
                     sys.stderr.write('gnulib-tool: warning: ')
                     sys.stderr.write('module %s lacks a license\n' % str(self))
@@ -840,20 +835,20 @@ Include:|Link:|License:|Maintainer:)'
         return license
 
     def getLicense_Raw(self):
-        '''GLModule.getLicense_Raw() -> string
+        '''GLModule.getLicense_Raw() -> str
 
         Return module license.'''
         section = 'License:'
         if 'license' not in self.cache:
             if section not in self.content:
-                result = string()
+                result = ''
             else:  # if section in self.content
                 pattern = '^%s[\t ]*(.*?)%s' % (section, self.regex)
                 pattern = compiler(pattern, re.S | re.M)
                 result = pattern.findall(self.content)
                 if type(result) is list:
                     if not result:
-                        result = string()
+                        result = ''
                     else:  # if result
                         result = result[-1]
             result = result.strip()
@@ -861,13 +856,13 @@ Include:|Link:|License:|Maintainer:)'
         return self.cache['license']
 
     def getMaintainer(self):
-        '''GLModule.getMaintainer() -> string
+        '''GLModule.getMaintainer() -> str
 
         Return maintainer directive.'''
         section = 'Maintainer:'
         if 'maintainer' not in self.cache:
             if section not in self.content:
-                result = string()
+                result = ''
             else:  # if section in self.content
                 snippet = self.content.split(section)[-1]
                 snippet = snippet.replace('\r\n', '\n')
@@ -955,11 +950,11 @@ class GLModuleTable(object):
         if type(module) is not GLModule:
             raise TypeError('module must be a GLModule, not %s' %
                             type(module).__name__)
-        if type(condition) is bytes or type(condition) is string \
+        if type(condition) is bytes or type(condition) is str \
                 or condition == True:
             if type(condition) is bytes:
                 condition = condition.decode(ENCS['default'])
-        else:  # if condition has not bytes or string type or is not True
+        else:  # if condition has not bytes or str type or is not True
             raise TypeError('condition must be a string or True, not %s' %
                             type(condition).__name__)
         if not str(module) in self.unconditionals:
@@ -991,7 +986,7 @@ class GLModuleTable(object):
         return result
 
     def getCondition(self, parent, module):
-        '''GLModuleTable.getCondition(module) -> string or True
+        '''GLModuleTable.getCondition(module) -> str or True
 
         Return condition from parent to module. Condition can be string or True.
         If module is not in the list of conddeps, method returns None.'''
index 0a631ebdc31f6e8cf1b0a97a8d97b1e446c31816..b8a7df43ce249b8bee27eb7f4640f578bd753ad5 100644 (file)
@@ -47,7 +47,6 @@ __copyright__ = constants.__copyright__
 #===============================================================================
 # Define global constants
 #===============================================================================
-PYTHON3 = constants.PYTHON3
 NoneType = type(None)
 APP = constants.APP
 DIRS = constants.DIRS
@@ -59,7 +58,6 @@ compiler = constants.compiler
 joinpath = constants.joinpath
 cleaner = constants.cleaner
 relpath = constants.relativize
-string = constants.string
 isabs = os.path.isabs
 isdir = os.path.isdir
 isfile = os.path.isfile
@@ -80,7 +78,7 @@ class GLTestDir(object):
         if type(config) is not GLConfig:
             raise TypeError('config must be a GLConfig, not %s' %
                             type(config).__name__)
-        if type(testdir) is bytes or type(testdir) is string:
+        if type(testdir) is bytes or type(testdir) is str:
             if type(testdir) is bytes:
                 testdir = testdir.decode(ENCS['default'])
         self.config = config
@@ -123,7 +121,7 @@ class GLTestDir(object):
                 for file in files
             ]  # Finish to convert bytes to string
         for file in files:
-            if type(file) is not string:
+            if type(file) is not str:
                 raise TypeError('each file must be a string instance')
         files = sorted(set(files))
         auxdir = self.config['auxdir']
@@ -378,8 +376,7 @@ class GLTestDir(object):
         if not isdir(directory):
             os.mkdir(directory)
         destfile = joinpath(directory, 'Makefile.am')
-        emit = string()
-        emit += '## Process this file with automake to produce Makefile.in.\n\n'
+        emit = '## Process this file with automake to produce Makefile.in.\n\n'
         emit += 'EXTRA_DIST =\n'
         for file in filelist:
             if file.startswith('m4/'):
@@ -419,11 +416,11 @@ class GLTestDir(object):
                 with codecs.open(destfile, 'wb', 'UTF-8') as file:
                     file.write(emit)
                 # Viewed from the $testsbase subdirectory, $auxdir is different.
-                emit = string()
+                emit = ''
                 saved_auxdir = self.config['auxdir']
                 testsbase = '%s/' % os.path.normpath(testsbase)
                 counter = int()
-                auxdir = string()
+                auxdir = ''
                 finish = (len(testsbase.split('/')) - 1)
                 while counter < finish:
                     auxdir += '../'
@@ -531,8 +528,7 @@ class GLTestDir(object):
             testsbase_appened = True
 
         # Create Makefile.am.
-        emit = string()
-        emit += '## Process this file with automake to produce Makefile.in.\n\n'
+        emit = '## Process this file with automake to produce Makefile.in.\n\n'
         emit += 'AUTOMAKE_OPTIONS = 1.9.6 foreign\n\n'
         emit += 'SUBDIRS = %s\n\n' % ' '.join(subdirs)
         emit += 'ACLOCAL_AMFLAGS = -I %s\n' % m4base
@@ -544,8 +540,7 @@ class GLTestDir(object):
             file.write(emit)
 
         # Create configure.ac
-        emit = string()
-        emit += '# Process this file with autoconf '
+        emit = '# Process this file with autoconf '
         emit += 'to produce a configure script.\n'
         emit += 'AC_INIT([dummy], [0])\n'
         if auxdir != '.':
@@ -862,7 +857,7 @@ class GLMegaTestDir(object):
         if type(config) is not GLConfig:
             raise TypeError('config must be a GLConfig, not %s' %
                             type(config).__name__)
-        if type(megatestdir) is bytes or type(megatestdir) is string:
+        if type(megatestdir) is bytes or type(megatestdir) is str:
             if type(megatestdir) is bytes:
                 megatestdir = megatestdir.decode(ENCS['default'])
         self.config = config
@@ -905,7 +900,7 @@ class GLMegaTestDir(object):
         megasubdirs += ['ALL']
 
         # Create autobuild.
-        emit = string()
+        emit = ''
         repdict = dict()
         repdict['Jan'] = repdict['January'] = '01'
         repdict['Feb'] = repdict['February'] = '02'
@@ -959,8 +954,7 @@ class GLMegaTestDir(object):
             file.write(emit)
 
         # Create Makefile.am.
-        emit = string()
-        emit += '## Process this file with automake to produce Makefile.in.\n\n'
+        emit = '## Process this file with automake to produce Makefile.in.\n\n'
         emit += 'AUTOMAKE_OPTIONS = 1.9.6 foreign\n\n'
         emit += 'SUBDIRS = %s\n\n' % ' '.join(megasubdirs)
         emit += 'EXTRA_DIST = do-autobuild\n'
@@ -971,8 +965,7 @@ class GLMegaTestDir(object):
         with codecs.open(path, 'wb', 'UTF-8') as file:
             file.write(emit)
 
-        emit = string()
-        emit += '# Process this file with autoconf '
+        emit = '# Process this file with autoconf '
         emit += 'to produce a configure script.\n'
         emit += 'AC_INIT([dummy], [0])\n\n'
         if auxdir != '.':
index f41c12ffd344c24ff47495ea81e21866d339403d..8c3dfa4bd9651ab8e71989e1747a81403897365f 100644 (file)
@@ -43,27 +43,6 @@ __license__ = 'GNU GPLv3+'
 __copyright__ = '2002-2017 Free Software Foundation, Inc.'
 
 
-#===============================================================================
-# Backward compatibility
-#===============================================================================
-# Check for Python version
-if sys.version_info.major == 2:
-    PYTHON3 = False
-else:
-    PYTHON3 = True
-
-# Create string compatibility
-if not PYTHON3:
-    string = unicode
-else:  # if PYTHON3
-    string = str
-
-# Current working directory
-if not PYTHON3:
-    os.getcwdb = os.getcwd
-    os.getcwd = os.getcwdu
-
-
 #===============================================================================
 # Define global constants
 #===============================================================================
@@ -99,9 +78,9 @@ if not APP['name']:
     APP['name'] = 'gnulib-tool.py'
 APP['path'] = os.path.realpath(sys.argv[0])
 if type(APP['name']) is bytes:
-    APP['name'] = string(APP['name'], ENCS['system'])
+    APP['name'] = str(APP['name'], ENCS['system'])
 if type(APP['path']) is bytes:
-    APP['path'] = string(APP['path'], ENCS['system'])
+    APP['path'] = str(APP['path'], ENCS['system'])
 
 # Set DIRS dictionary
 DIRS['root'] = os.path.dirname(APP['path'])
@@ -265,16 +244,13 @@ def execute(args, verbose):
 
 def compiler(pattern, flags=0):
     '''Compile regex pattern depending on version of Python.'''
-    if not PYTHON3:
-        pattern = re.compile(pattern, re.UNICODE | flags)
-    else:  # if PYTHON3
-        pattern = re.compile(pattern, flags)
+    pattern = re.compile(pattern, flags)
     return pattern
 
 
 def cleaner(sequence):
     '''Clean string or list of strings after using regex.'''
-    if type(sequence) is string:
+    if type(sequence) is str:
         sequence = sequence.replace('[', '')
         sequence = sequence.replace(']', '')
     elif type(sequence) is list:
@@ -289,7 +265,7 @@ def cleaner(sequence):
 
 
 def joinpath(head, *tail):
-    '''joinpath(head, *tail) -> string
+    '''joinpath(head, *tail) -> str
 
     Join two or more pathname components, inserting '/' as needed. If any
     component is an absolute path, all previous path components will be
@@ -344,26 +320,23 @@ def relativize(dir1, dir2):
 def link_relative(src, dest):
     '''Like ln -s, except that src is given relative to the current directory
     (or absolute), not given relative to the directory of dest.'''
-    if type(src) is bytes or type(src) is string:
+    if type(src) is bytes or type(src) is str:
         if type(src) is bytes:
             src = src.decode(ENCS['default'])
-    else:  # if src has not bytes or string type
+    else:  # if src has not bytes or str type
         raise TypeError(
             'src must be a string, not %s' % (type(src).__name__))
-    if type(dest) is bytes or type(dest) is string:
+    if type(dest) is bytes or type(dest) is str:
         if type(dest) is bytes:
             dest = dest.decode(ENCS['default'])
-    else:  # if dest has not bytes or string type
+    else:  # if dest has not bytes or str type
         raise TypeError(
             'dest must be a string, not %s' % (type(dest).__name__))
     if src.startswith('/') or (len(src) >= 2 and src[1] == ':'):
         os.symlink(src, dest)
     else:  # if src is not absolute
         if dest.startswith('/') or (len(dest) >= 2 and dest[1] == ':'):
-            if not constants.PYTHON3:
-                cwd = os.getcwdu()
-            else:  # if constants.PYTHON3
-                cwd = os.getcwd()
+            cwd = os.getcwd()
             os.symlink(joinpath(cwd, src), dest)
         else:  # if dest is not absolute
             destdir = os.path.dirname(dest)
@@ -389,7 +362,7 @@ def link_if_changed(src, dest):
 
 def filter_filelist(separator, filelist,
                     prefix, suffix, removed_prefix, removed_suffix,
-                    added_prefix=string(), added_suffix=string()):
+                    added_prefix='', added_suffix=''):
     '''filter_filelist(*args) -> list
 
     Filter the given list of files. Filtering: Only the elements starting with