From ecdab13fca9f61cdfa832005c9324414621b4069 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Wed, 1 May 2024 02:21:43 -0700 Subject: [PATCH] gnulib-tool.py: Fix mistake in previous commit. * pygnulib/GLModuleSystem.py (GLModuleSystem.exists) (GLModuleSystem.find): Rename 'module' argument to 'module_name' so it is clear they are not a GLModule object. Treat them as such. --- ChangeLog | 7 +++++++ pygnulib/GLModuleSystem.py | 34 +++++++++++++++++----------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 917761a7d2..fee17c01ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-05-01 Collin Funk + + gnulib-tool.py: Fix mistake in previous commit. + * pygnulib/GLModuleSystem.py (GLModuleSystem.exists) + (GLModuleSystem.find): Rename 'module' argument to 'module_name' so it + is clear they are not a GLModule object. Treat them as such. + 2024-05-01 Collin Funk gnulib-tool.py: Use the GLModule's name variable directly. diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index 2bfd5b252f..2cb5d1d468 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -65,43 +65,43 @@ class GLModuleSystem: result = '' % hex(id(self)) return result - def exists(self, module: str) -> bool: + def exists(self, module_name: str) -> bool: '''Check whether the given module exists. GLConfig: localpath.''' - if type(module) is not str: - raise TypeError('module must be a string, not %s' - % type(module).__name__) + if type(module_name) is not str: + raise TypeError('module_name must be a string, not %s' + % type(module_name).__name__) localpath = self.config['localpath'] result = False badnames = ['ChangeLog', 'COPYING', 'README', 'TEMPLATE', 'TEMPLATE-EXTENDED', 'TEMPLATE-TESTS'] - if module not in badnames: - result = os.path.isfile(joinpath(DIRS['modules'], module)) + if module_name not in badnames: + result = os.path.isfile(joinpath(DIRS['modules'], module_name)) if not result: for localdir in localpath: if (os.path.isdir(joinpath(localdir, 'modules')) - and os.path.isfile(joinpath(localdir, 'modules', module))): + and os.path.isfile(joinpath(localdir, 'modules', module_name))): result = True break return result - def find(self, module: str) -> GLModule | None: + def find(self, module_name: str) -> GLModule | None: '''Return the GLModule object given the module name, or None if the module description file with that name does not exist. - - module, The name of the module.''' - if type(module) is not str: - raise TypeError('module must be a string, not %s' - % type(module).__name__) - if self.exists(module): - path, istemp = self.filesystem.lookup(joinpath('modules', module)) - result = GLModule(self.config, module, path, istemp) + - module_name, The name of the module.''' + if type(module_name) is not str: + raise TypeError('module_name must be a string, not %s' + % type(module_name).__name__) + if self.exists(module_name): + path, istemp = self.filesystem.lookup(joinpath('modules', module_name)) + result = GLModule(self.config, module_name, path, istemp) return result else: # if not self.exists(module) if self.config['errors']: - raise GLError(3, module) + raise GLError(3, module_name) else: # if not self.config['errors'] sys.stderr.write('gnulib-tool: warning: ') - sys.stderr.write("module %s doesn't exist\n" % module.name) + sys.stderr.write("module %s doesn't exist\n" % module_name) def file_is_module(self, filename: str) -> bool: '''Given the name of a file in the modules/ directory, return true -- 2.39.5