]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Improve field naming.
authorBruno Haible <bruno@clisp.org>
Sun, 7 Aug 2022 18:04:56 +0000 (20:04 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 7 Aug 2022 21:04:28 +0000 (23:04 +0200)
* pygnulib/GLModuleSystem.py (GLModule): Rename field 'module' to
'path'. Fix a typo in a TypeError message.

ChangeLog
pygnulib/GLModuleSystem.py

index fceb1538a835bd9490520c636faea5e261323f57..36962c2dd277a15a04d08be73d8bb2cc2a3379e9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2022-08-07  Bruno Haible  <bruno@clisp.org>
 
+       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.
index b736bf2ed134fcd938bf58b58f00511bbc82b618..ec2ff0c35c52f7fe7cf14aac7091a724ac21e1fe 100644 (file)
@@ -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<y'''
         result = bool()
         if type(module) is GLModule:
-            if self.module < module.module:
+            if self.path < module.path:
                 result = True
         return result
 
@@ -282,7 +280,7 @@ Include:|Link:|License:|Maintainer:)'
 
         Return the name of the module.'''
         pattern = re.compile(joinpath('modules', '(.*)$'))
-        result = pattern.findall(self.module)[0]
+        result = pattern.findall(self.path)[0]
         return result
 
     def isPatched(self):