bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* gnulib-tool.py: Simplify imports
@ 2024-04-01 23:04 Bruno Haible
  0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2024-04-01 23:04 UTC (permalink / raw
  To: bug-gnulib

In Eclipse, I am seeing error markers for imports, hinting that not following
the recommended Python program structure not only forces us to set PYTHONPATH,
but also causes trouble in IDEs. While attempting to fix this, I encountered
two problem with imports:
  - The classes.py file makes the imports more complicated than necessary.
  - GLConfig.py and GLFileSystem.py have circular dependencies.

This patch fixes both issues.


2024-04-01  Bruno Haible  <bruno@clisp.org>

	gnulib-tool.py: Simplify imports.
	* pygnulib/enums.py: New file, extracted from pygnulib/GLFileSystem.py.
	* pygnulib/classes.py: Remove file.
	* pygnulib/GLFileSystem.py: Remove class CopyAction. Update imports.
	* pygnulib/GLTestDir.py: Update imports.
	* pygnulib/GLConfig.py: Update imports and remove 'classes.' prefix.
	* pygnulib/main.py: Likewise.

diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index 662814b6be..80719d35f2 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -23,7 +23,7 @@ import copy
 import tempfile
 from . import constants
 from .GLError import GLError
-from pygnulib import classes
+from pygnulib.enums import CopyAction
 
 
 #===============================================================================
@@ -82,8 +82,8 @@ class GLConfig(object):
                  podomain: str | None = None,
                  witness_c_macro: str | None = None,
                  vc_files: bool | None = None,
-                 copymode: classes.CopyAction | None = None,
-                 lcopymode: classes.CopyAction | None = None,
+                 copymode: CopyAction | None = None,
+                 lcopymode: CopyAction | None = None,
                  configure_ac: str | None = None,
                  ac_version: float | int | None = None,
                  libtests: bool | None = None,
@@ -206,13 +206,13 @@ class GLConfig(object):
         self.resetCopyMode()
         if copymode == None:
             # Default to copying.
-            copymode = classes.CopyAction.Copy
+            copymode = CopyAction.Copy
         self.setCopyMode(copymode)
         # lcopymode (--local-symlink and --local-hardlink)
         self.resetLCopyMode()
         if lcopymode == None:
             # Default to copying.
-            lcopymode = classes.CopyAction.Copy
+            lcopymode = CopyAction.Copy
         self.setLCopyMode(lcopymode)
         # configure_ac
         self.resetAutoconfFile()
@@ -248,7 +248,7 @@ class GLConfig(object):
         '''x.__repr__() <==> repr(x)'''
         return '<pygnulib.GLConfig>'
 
-    def __getitem__(self, y: str) -> str | float | int | bool | classes.CopyAction | list[str] | None:
+    def __getitem__(self, y: str) -> str | float | int | bool | CopyAction | list[str] | None:
         '''x.__getitem__(y) <==> x[y]'''
         if y in self.table:
             result = self.table[y]
@@ -262,7 +262,7 @@ class GLConfig(object):
         else:  # if y not in self.table
             raise KeyError('GLConfig does not contain key: %s' % repr(y))
 
-    def dictionary(self) -> dict[str, str | float | int | bool | classes.CopyAction | list[str] | None]:
+    def dictionary(self) -> dict[str, str | float | int | bool | CopyAction | list[str] | None]:
         '''Return the configuration as a dict object.'''
         return dict(self.table)
 
@@ -304,7 +304,7 @@ class GLConfig(object):
         else:  # if key not in self.table
             raise KeyError('GLConfig does not contain key: %s' % repr(key))
 
-    def default(self, key: str) -> str | float | int | bool | classes.CopyAction | list[str] | None:
+    def default(self, key: str) -> str | float | int | bool | CopyAction | list[str] | None:
         '''Return default value for the given key.'''
         if key in self.table:
             if key == 'libname':
@@ -325,7 +325,7 @@ class GLConfig(object):
                          'libtests', 'dryrun']:
                 return False
             elif key in ['copymode', 'lcopymode']:
-                return classes.CopyAction.Copy
+                return CopyAction.Copy
             elif key in ['lgpl', 'vc_files']:
                 return None
             elif key == 'errors':
@@ -335,7 +335,7 @@ class GLConfig(object):
         else:  # if key not in self.table
             raise KeyError('GLConfig does not contain key: %s' % repr(key))
 
-    def isdefault(self, key: str, value: str | float | int | bool | classes.CopyAction | list[str] | None) -> bool:
+    def isdefault(self, key: str, value: str | float | int | bool | CopyAction | list[str] | None) -> bool:
         '''Check whether the value for the given key is a default value.'''
         if key in self.table:
             default = self.default(key)
@@ -347,7 +347,7 @@ class GLConfig(object):
         '''Return list of keys.'''
         return list(self.table.keys())
 
-    def values(self) -> list[str | float | int | bool | classes.CopyAction | list[str] | None]:
+    def values(self) -> list[str | float | int | bool | CopyAction | list[str] | None]:
         '''Return list of values.'''
         return list(self.table.values())
 
@@ -1065,13 +1065,13 @@ class GLConfig(object):
         self.table['ac_version'] = 2.64
 
     # Define copymode methods.
-    def checkCopyMode(self) -> classes.CopyAction:
+    def checkCopyMode(self) -> CopyAction:
         '''Check if pygnulib will copy files, create symlinks, or create hard links.'''
         return self.table['copymode']
 
-    def setCopyMode(self, value: classes.CopyAction) -> None:
+    def setCopyMode(self, value: CopyAction) -> None:
         '''Change the method used for copying / linking files.'''
-        if type(value) is classes.CopyAction:
+        if type(value) is CopyAction:
             self.table['copymode'] = value
         else:  # if type(value) is not CopyAction
             raise TypeError('value must be a CopyAction, not %s'
@@ -1079,18 +1079,18 @@ class GLConfig(object):
 
     def resetCopyMode(self) -> None:
         '''Reset the method used for creating files to copying instead of linking.'''
-        self.table['copymode'] = classes.CopyAction.Copy
+        self.table['copymode'] = CopyAction.Copy
 
     # Define lcopymode methods.
-    def checkLCopyMode(self) -> classes.CopyAction:
+    def checkLCopyMode(self) -> CopyAction:
         '''Check if pygnulib will copy files, create symlinks, or create hard links,
         only for files from the local override directories.'''
         return self.table['lcopymode']
 
-    def setLCopyMode(self, value: classes.CopyAction) -> None:
+    def setLCopyMode(self, value: CopyAction) -> None:
         '''Change the method used for copying / linking files, only for files from
         the local override directories.'''
-        if type(value) is classes.CopyAction:
+        if type(value) is CopyAction:
             self.table['lcopymode'] = value
         else:  # if type(value) is not CopyAction
             raise TypeError('value must be a CopyAction, not %s'
@@ -1099,7 +1099,7 @@ class GLConfig(object):
     def resetLCopyMode(self) -> None:
         '''Reset the method used for creating files to copying instead of linking,
         only for files from the local override directories.'''
-        self.table['lcopymode'] = classes.CopyAction.Copy
+        self.table['lcopymode'] = CopyAction.Copy
 
     # Define verbosity methods.
     def getVerbosity(self) -> int:
diff --git a/pygnulib/GLFileSystem.py b/pygnulib/GLFileSystem.py
index e06eab316a..4709b0b092 100644
--- a/pygnulib/GLFileSystem.py
+++ b/pygnulib/GLFileSystem.py
@@ -25,6 +25,7 @@ import filecmp
 import subprocess as sp
 from enum import Enum
 from . import constants
+from pygnulib.enums import CopyAction
 from .GLError import GLError
 from .GLConfig import GLConfig
 
@@ -53,15 +54,6 @@ isfile = os.path.isfile
 islink = os.path.islink
 
 
-#===============================================================================
-# Define CopyAction class
-#===============================================================================
-class CopyAction(Enum):
-    Copy = 0
-    Symlink = 1
-    Hardlink = 2
-
-
 #===============================================================================
 # Define GLFileSystem class
 #===============================================================================
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index 2a39eb3c5d..f0fe993c58 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -26,11 +26,11 @@ import subprocess as sp
 import shutil
 from pathlib import Path
 from . import constants
+from .enums import CopyAction
 from .GLError import GLError
 from .GLConfig import GLConfig
 from .GLModuleSystem import GLModuleTable
 from .GLModuleSystem import GLModuleSystem
-from .GLFileSystem import CopyAction
 from .GLFileSystem import GLFileSystem
 from .GLFileSystem import GLFileAssistant
 from .GLMakefileTable import GLMakefileTable
diff --git a/pygnulib/classes.py b/pygnulib/classes.py
deleted file mode 100644
index 537872a37b..0000000000
--- a/pygnulib/classes.py
+++ /dev/null
@@ -1,90 +0,0 @@
-# Copyright (C) 2002-2024 Free Software Foundation, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <https://www.gnu.org/licenses/>.
-
-'''An easy access to pygnulib classes.'''
-
-#===============================================================================
-# Define global imports
-#===============================================================================
-__all__ = list()
-
-try:
-    # Constants
-    from . import constants
-
-    # Main classes
-    from .GLConfig import GLConfig
-    from .GLError import GLError
-    from .GLInfo import GLInfo
-
-    # File system
-    from .GLFileSystem import CopyAction
-    from .GLFileSystem import GLFileSystem
-    from .GLFileSystem import GLFileAssistant
-
-    # Module system
-    from .GLModuleSystem import GLModule
-    from .GLModuleSystem import GLModuleSystem
-    from .GLModuleSystem import GLModuleTable
-
-    # Different modes
-    from .GLImport import GLImport
-    from .GLEmiter import GLEmiter
-    from .GLTestDir import GLTestDir
-    from .GLTestDir import GLMegaTestDir
-
-    # Other modules
-    from .GLMakefileTable import GLMakefileTable
-except ValueError as error:
-    # Constants
-    import constants
-
-    # Main classes
-    from GLConfig import GLConfig
-    from GLError import GLError
-    from GLInfo import GLInfo
-
-    # File system
-    from GLFileSystem import CopyAction
-    from GLFileSystem import GLFileSystem
-    from GLFileSystem import GLFileAssistant
-
-    # Module system
-    from GLModuleSystem import GLModule
-    from GLModuleSystem import GLModuleSystem
-    from GLModuleSystem import GLModuleTable
-
-    # Different modes
-    from GLImport import GLImport
-    from GLEmiter import GLEmiter
-    from GLTestDir import GLTestDir
-    from GLTestDir import GLMegaTestDir
-
-    # Other modules
-    from GLMakefileTable import GLMakefileTable
-
-# Append modules to namespace.
-__all__ += ['GLConfig', 'GLError', 'GLInfo']
-__all__ += ['CopyAction', 'GLFileSystem', 'GLFileAssistant']
-__all__ += ['GLModule', 'GLModuleSystem', 'GLModuleTable']
-__all__ += ['GLImport', 'GLEmiter', 'GLTestDir']
-__all__ += ['GLMakefileTable']
-
-#===============================================================================
-# Define module information
-#===============================================================================
-__author__ = constants.__author__
-__license__ = constants.__license__
-__copyright__ = constants.__copyright__
diff --git a/pygnulib/enums.py b/pygnulib/enums.py
new file mode 100644
index 0000000000..2319d690c5
--- /dev/null
+++ b/pygnulib/enums.py
@@ -0,0 +1,31 @@
+# Copyright (C) 2002-2024 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+from __future__ import annotations
+
+#===============================================================================
+# Define global imports
+#===============================================================================
+from enum import Enum
+
+
+#===============================================================================
+# Define CopyAction class
+#===============================================================================
+class CopyAction(Enum):
+    Copy = 0
+    Symlink = 1
+    Hardlink = 2
+
diff --git a/pygnulib/main.py b/pygnulib/main.py
index 55d635d074..31bb434b3a 100644
--- a/pygnulib/main.py
+++ b/pygnulib/main.py
@@ -82,7 +82,16 @@ import subprocess as sp
 import shlex
 from tempfile import mktemp
 from pygnulib import constants
-from pygnulib import classes
+from pygnulib.enums import CopyAction
+from pygnulib.GLConfig import GLConfig
+from pygnulib.GLError import GLError
+from pygnulib.GLFileSystem import GLFileSystem
+from pygnulib.GLFileSystem import GLFileAssistant
+from pygnulib.GLImport import GLImport
+from pygnulib.GLInfo import GLInfo
+from pygnulib.GLModuleSystem import GLModuleSystem
+from pygnulib.GLTestDir import GLTestDir
+from pygnulib.GLTestDir import GLMegaTestDir
 
 
 #===============================================================================
@@ -107,7 +116,7 @@ isfile = os.path.isfile
 # Define main part
 #===============================================================================
 def main() -> None:
-    info = classes.GLInfo()
+    info = GLInfo()
     parser = argparse.ArgumentParser(
         prog=constants.APP['name'],
         usage='gnulib-tool.py --help',
@@ -462,22 +471,22 @@ def main() -> None:
     parser.add_argument('-s', '-S', '--symbolic', '--symlink', '--more-symlinks',
                         dest='copymode',
                         default=None,
-                        action='store_const', const=classes.CopyAction.Symlink)
+                        action='store_const', const=CopyAction.Symlink)
     # local-symlink
     parser.add_argument('--local-symlink',
                         dest='lcopymode',
                         default=None,
-                        action='store_const', const=classes.CopyAction.Symlink)
+                        action='store_const', const=CopyAction.Symlink)
     # hardlink
     parser.add_argument('-h', '-H', '--hardlink', '--more-hardlinks',
                         dest='copymode',
                         default=None,
-                        action='store_const', const=classes.CopyAction.Hardlink)
+                        action='store_const', const=CopyAction.Hardlink)
     # local-hardlink
     parser.add_argument('--local-hardlink',
                         dest='lcopymode',
                         default=None,
-                        action='store_const', const=classes.CopyAction.Hardlink)
+                        action='store_const', const=CopyAction.Hardlink)
     # Undocumented option. Only used for the gnulib-tool test suite.
     parser.add_argument('--gnulib-dir',
                         dest='gnulib_dir',
@@ -802,7 +811,7 @@ def main() -> None:
     docbase = None
 
     # Create pygnulib configuration.
-    config = classes.GLConfig(
+    config = GLConfig(
         destdir=destdir,
         localpath=localpath,
         m4base=m4base,
@@ -837,14 +846,14 @@ def main() -> None:
 
     # Work in the given mode.
     if mode == 'list':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         listing = modulesystem.list()
         result = lines_to_multiline(listing)
         os.rmdir(config['tempdir'])
         print(result, end='')
 
     elif mode == 'find':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for filename in files:
             if (isfile(joinpath(DIRS['root'], filename))
                     or (localpath != None
@@ -902,7 +911,7 @@ def main() -> None:
         elif isfile(joinpath(destdir, 'configure.in')):
             configure_ac = joinpath(destdir, 'configure.in')
         else:
-            raise classes.GLError(3, joinpath(destdir, 'configure.ac'))
+            raise GLError(3, joinpath(destdir, 'configure.ac'))
 
         # Save the Autoconf file path for the rest of the import.
         config.setAutoconfFile(configure_ac)
@@ -937,7 +946,7 @@ def main() -> None:
             config.setMacroPrefix(macro_prefix)
 
             # Perform GLImport actions.
-            importer = classes.GLImport(config, mode)
+            importer = GLImport(config, mode)
             filetable, transformers = importer.prepare()
             importer.execute(filetable, transformers)
 
@@ -961,7 +970,7 @@ def main() -> None:
                     config.setTestsBase(testsbase)
                     config.setMacroPrefix(macro_prefix)
                 # Perform GLImport actions.
-                importer = classes.GLImport(config, mode)
+                importer = GLImport(config, mode)
                 filetable, transformers = importer.prepare()
                 importer.execute(filetable, transformers)
             else:  # if not m4base
@@ -1027,7 +1036,7 @@ def main() -> None:
                     config.setTestsBase(testsbase)
                     config.setMacroPrefix(macro_prefix)
                     # Perform GLImport actions.
-                    importer = classes.GLImport(config, mode)
+                    importer = GLImport(config, mode)
                     filetable, transformers = importer.prepare()
                     importer.execute(filetable, transformers)
                 elif len(m4dirs) == 1:
@@ -1036,7 +1045,7 @@ def main() -> None:
                     m4base = m4dirs[-1]
                     config.setM4Base(m4base)
                     # Perform GLImport actions.
-                    importer = classes.GLImport(config, mode)
+                    importer = GLImport(config, mode)
                     filetable, transformers = importer.prepare()
                     importer.execute(filetable, transformers)
                 else:  # if len(m4dirs) > 1
@@ -1044,7 +1053,7 @@ def main() -> None:
                     for m4base in m4dirs:
                         config.setM4Base(m4base)
                         # Perform GLImport actions.
-                        importer = classes.GLImport(config, mode)
+                        importer = GLImport(config, mode)
                         filetable, transformers = importer.prepare()
                         importer.execute(filetable, transformers)
 
@@ -1058,7 +1067,7 @@ def main() -> None:
         if not auxdir:
             auxdir = 'build-aux'
         config.setAuxDir(auxdir)
-        testdir = classes.GLTestDir(config, destdir)
+        testdir = GLTestDir(config, destdir)
         testdir.execute()
 
     elif mode == 'create-megatestdir':
@@ -1071,7 +1080,7 @@ def main() -> None:
         if not auxdir:
             auxdir = 'build-aux'
         config.setAuxDir(auxdir)
-        testdir = classes.GLMegaTestDir(config, destdir)
+        testdir = GLMegaTestDir(config, destdir)
         testdir.execute()
 
     elif mode == 'test':
@@ -1080,7 +1089,7 @@ def main() -> None:
         if not auxdir:
             auxdir = 'build-aux'
         config.setAuxDir(auxdir)
-        testdir = classes.GLTestDir(config, destdir)
+        testdir = GLTestDir(config, destdir)
         testdir.execute()
         constants.force_output()
         os.chdir(destdir)
@@ -1113,7 +1122,7 @@ def main() -> None:
         if not auxdir:
             auxdir = 'build-aux'
         config.setAuxDir(auxdir)
-        testdir = classes.GLMegaTestDir(config, destdir)
+        testdir = GLMegaTestDir(config, destdir)
         testdir.execute()
         constants.force_output()
         os.chdir(destdir)
@@ -1138,42 +1147,42 @@ def main() -> None:
         sp.call(['rm', '-rf', destdir], shell=False)
 
     elif mode == 'extract-description':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
                 sys.stdout.write(module.getDescription())
 
     elif mode == 'extract-comment':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
                 sys.stdout.write(module.getComment())
 
     elif mode == 'extract-status':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
                 sys.stdout.write(module.getStatus())
 
     elif mode == 'extract-notice':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
                 sys.stdout.write(module.getNotice())
 
     elif mode == 'extract-applicability':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
                 print(module.getApplicability())
 
     elif mode == 'extract-filelist':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
@@ -1190,7 +1199,7 @@ def main() -> None:
             message += '%s: *** Stop.\n' % constants.APP['name']
             sys.stderr.write(message)
             sys.exit(1)
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
@@ -1203,35 +1212,35 @@ def main() -> None:
             message += '%s: *** Stop.\n' % constants.APP['name']
             sys.stderr.write(message)
             sys.exit(1)
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
                 sys.stdout.write(module.getDependenciesRecursively())
 
     elif mode == 'extract-autoconf-snippet':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
                 sys.stdout.write(module.getAutoconfSnippet())
 
     elif mode == 'extract-automake-snippet':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
                 sys.stdout.write(module.getAutomakeSnippet())
 
     elif mode == 'extract-include-directive':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
                 sys.stdout.write(module.getInclude())
 
     elif mode == 'extract-link-directive':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
@@ -1244,28 +1253,28 @@ def main() -> None:
             message += '%s: *** Stop.\n' % constants.APP['name']
             sys.stderr.write(message)
             sys.exit(1)
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
                 sys.stdout.write(module.getLinkDirectiveRecursively())
 
     elif mode == 'extract-license':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
                 print(module.getLicense())
 
     elif mode == 'extract-maintainer':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module:
                 sys.stdout.write(module.getMaintainer())
 
     elif mode == 'extract-tests-module':
-        modulesystem = classes.GLModuleSystem(config)
+        modulesystem = GLModuleSystem(config)
         for name in modules:
             module = modulesystem.find(name)
             if module and modulesystem.exists(module.getTestsName()):
@@ -1294,7 +1303,7 @@ def main() -> None:
         config.setM4Base(m4base)
         config.setDocBase(docbase)
         config.setTestsBase(testsbase)
-        filesystem = classes.GLFileSystem(config)
+        filesystem = GLFileSystem(config)
         lookedup, flag = filesystem.lookup(srcpath)
         if isdir(dest):
             destdir = dest
@@ -1324,7 +1333,7 @@ def main() -> None:
                 except FileExistsError:
                     pass
         # Copy the file.
-        assistant = classes.GLFileAssistant(config)
+        assistant = GLFileAssistant(config)
         tmpfile = assistant.tmpfilename(destpath)
         copyfile(lookedup, tmpfile)
         ensure_writable(tmpfile)
@@ -1350,7 +1359,7 @@ def main() -> None:
         sys.stderr.write(message)
         sys.exit(1)
 
-    if copymode == classes.CopyAction.Hardlink or lcopymode == classes.CopyAction.Hardlink:
+    if copymode == CopyAction.Hardlink or lcopymode == CopyAction.Hardlink:
         # Setting hard links modifies the ctime of files in the gnulib checkout.
         # This disturbs the result of the next "gitk" invocation.
         # Workaround: Let git scan the files. This can be done through
@@ -1367,7 +1376,7 @@ def main() -> None:
 if __name__ == '__main__':
     try:  # Try to execute
         main()
-    except classes.GLError as error:
+    except GLError as error:
         errmode = 0  # gnulib-style errors
         errno = error.errno
         errinfo = error.errinfo





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-01 23:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-01 23:04 gnulib-tool.py: Simplify imports Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).