>From 586000e597d4ef7cba8de869a15ad5c922a2010c Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 7 Aug 2022 20:04:56 +0200 Subject: [PATCH 14/19] gnulib-tool.py: Improve field naming. * pygnulib/GLModuleSystem.py (GLModule): Rename field 'module' to 'path'. Fix a typo in a TypeError message. --- ChangeLog | 4 ++++ pygnulib/GLModuleSystem.py | 38 ++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index fceb1538a8..36962c2dd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2022-08-07 Bruno Haible + gnulib-tool.py: Improve field naming. + * pygnulib/GLModuleSystem.py (GLModule): Rename field 'module' to + 'path'. Fix a typo in a TypeError message. + gnulib-tool.py: Simplify. * pygnulib/GLModuleSystem.py (GLModule): Convert Windows newlines right after reading the module description, not in every accessor. diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index b736bf2ed1..ec2ff0c35c 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -186,11 +186,11 @@ Include:|Link:|License:|Maintainer:)' + 'Files|Depends-on|configure\\.ac-early|configure\\.ac|' + 'Makefile\\.am|Include|Link|License|Maintainer):$') - def __init__(self, config, module, patched=False): - '''GLModule.__init__(config, module[, patched]) -> GLModule + def __init__(self, config, path, patched=False): + '''GLModule.__init__(config, path[, patched]) -> GLModule - Create new GLModule instance. Arguments are module and patched, where - module is a string representing the path to the module and patched is a + Create new GLModule instance. Arguments are path and patched, where + path is a string representing the path to the module and patched is a bool indicating that module was created after applying patch.''' self.args = dict() self.cache = dict() @@ -198,25 +198,25 @@ Include:|Link:|License:|Maintainer:)' if type(config) is not GLConfig: raise TypeError('config must be a GLConfig, not %s' % type(config).__name__) - if type(module) is not str: - raise TypeError('module must be a string, not %s' - % type(module).__name__) + if type(path) is not str: + raise TypeError('path must be a string, not %s' + % type(path).__name__) if type(patched) is not bool: raise TypeError('patched must be a bool, not %s' - % type(module).__name__) - self.module = module + % type(patched).__name__) + self.path = path self.patched = patched self.config = config self.filesystem = GLFileSystem(self.config) self.modulesystem = GLModuleSystem(self.config) - with codecs.open(module, 'rb', 'UTF-8') as file: + with codecs.open(path, 'rb', 'UTF-8') as file: self.content = file.read().replace('\r\n', '\n') def __eq__(self, module): '''x.__eq__(y) <==> x==y''' result = bool() if type(module) is GLModule: - if self.module == module.module: + if self.path == module.path: result = True return result @@ -224,7 +224,7 @@ Include:|Link:|License:|Maintainer:)' '''x.__ne__(y) <==> x!=y''' result = bool() if type(module) is GLModule: - if self.module != module.module: + if self.path != module.path: result = True return result @@ -232,7 +232,7 @@ Include:|Link:|License:|Maintainer:)' '''x.__ge__(y) <==> x>=y''' result = bool() if type(module) is GLModule: - if self.module >= module.module: + if self.path >= module.path: result = True return result @@ -240,22 +240,20 @@ Include:|Link:|License:|Maintainer:)' '''x.__gt__(y) <==> x>y''' result = bool() if type(module) is GLModule: - if self.module > module.module: + if self.path > module.path: result = True return result def __hash__(self): '''x.__hash__() <==> hash(x)''' - module = hash(self.module) - patched = hash(self.patched) - result = module ^ patched + result = hash(self.path) ^ hash(self.patched) return result def __le__(self, module): '''x.__le__(y) <==> x<=y''' result = bool() if type(module) is GLModule: - if self.module <= module.module: + if self.path <= module.path: result = True return result @@ -263,7 +261,7 @@ Include:|Link:|License:|Maintainer:)' '''x.__lt__(y) <==> x