[Buildroot] [git commit] utils/scanpypi: support alternative Homepage format

Yann E. MORIN yann.morin.1998 at free.fr
Sun Mar 13 18:24:23 UTC 2022


commit: https://git.buildroot.net/buildroot/commit/?id=2b09e05b5831541e19eb8a6cbaf216bfe08f6c8f
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Some packages only have a home page properly set inside project_urls.

Squelch flake8's E127, because a visual indent here is really nicer.

Signed-off-by: James Hilliard <james.hilliard1 at gmail.com>
[yann.morin.1998 at free.fr: simplify getting home_page fallbacks]
Signed-off-by: Yann E. MORIN <yann.morin.1998 at free.fr>
---
 utils/scanpypi | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/utils/scanpypi b/utils/scanpypi
index 17d8a0017a..cc13701c0e 100755
--- a/utils/scanpypi
+++ b/utils/scanpypi
@@ -609,7 +609,8 @@ class BuildrootPackage():
 
         lines.append('\thelp\n')
 
-        help_lines = textwrap.wrap(self.metadata['info']['summary'], 62,
+        md_info = self.metadata['info']
+        help_lines = textwrap.wrap(md_info['summary'], 62,
                                    initial_indent='\t  ',
                                    subsequent_indent='\t  ')
 
@@ -617,11 +618,15 @@ class BuildrootPackage():
         if help_lines[-1][-1] != '.':
             help_lines[-1] += '.'
 
-        # \t + two spaces is 3 char long
-        help_lines.append('')
-        help_lines.append('\t  ' + self.metadata['info']['home_page'])
-        help_lines = [x + '\n' for x in help_lines]
-        lines += help_lines
+        home_page = md_info.get('home_page', None) or \
+                    md_info.get('project_urls', {}).get('Homepage', None)  # noqa: E127
+
+        if home_page:
+            # \t + two spaces is 3 char long
+            help_lines.append('')
+            help_lines.append('\t  ' + home_page)
+            help_lines = [x + '\n' for x in help_lines]
+            lines += help_lines
 
         with open(path_to_config, 'w') as config_file:
             config_file.writelines(lines)



More information about the buildroot mailing list