Collin Funk <collin.fu...@gmail.com> writes:
> +    def getShellId(self) -> str:
> +        if re.match(self.shell_id_pattern, self.name):
> +            return self.name
> +        return 
> hashlib.md5(f'{self.name}\n'.encode(ENCS['default'])).hexdigest()
> +

Oops, I forgot to write a docstring...

I've pushed this patch fixing it.

Also, I've added a comment about the '\n' following the module name. One
might be tempted to remove it. However, when using
--conditional-dependencies that would cause gnulib-tool.sh and
gnulib-tool.py to produce different output.

Collin

>From 001302d065dd00a90f33a296bd613c1a93b197bb Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Tue, 28 May 2024 23:26:19 -0700
Subject: [PATCH] gnulib-tool.py: Add missing docstring.

* pygnulib/GLModuleSystem.py (GLModule.getShellId): Add docstring
forgotten in the previous commit.
---
 ChangeLog                  | 4 ++++
 pygnulib/GLModuleSystem.py | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 9be0407793..9c22b7fb38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2024-05-28  Collin Funk  <collin.fu...@gmail.com>
 
+	gnulib-tool.py: Add missing docstring.
+	* pygnulib/GLModuleSystem.py (GLModule.getShellId): Add docstring
+	forgotten in the previous commit.
+
 	gnulib-tool.py: Simplify creation of module shell ids.
 	* pygnulib/GLModuleSystem.py (GLModule.shell_id_chars): Remove class
 	variable.
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 63d4f4a73e..f1774f64fc 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -379,8 +379,11 @@ def getLinkDirectiveRecursively(self) -> str:
         return lines_to_multiline(directives)
 
     def getShellId(self) -> str:
+        '''Return an unique id suitable for use in shell scripts. If the
+        module name is not a valid shell identifier use its MD5 digest.'''
         if re.match(self.shell_id_pattern, self.name):
             return self.name
+        # Newline character needed for compatibility with gnulib-tool.sh.
         return hashlib.md5(f'{self.name}\n'.encode(ENCS['default'])).hexdigest()
 
     def getShellFunc(self) -> str:
-- 
2.45.1

Reply via email to