pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/pkgtools/url2pkg/files



Module Name:    pkgsrc
Committed By:   rillig
Date:           Fri Aug 26 20:11:35 UTC 2022

Modified Files:
        pkgsrc/pkgtools/url2pkg/files: url2pkg.py

Log Message:
pkgtools/url2pkg: clean up Globals.pkgsrc_license

Having a nested function accessing nonlocal variables was more
complicated to understand than the straight-forward copy-and-paste code.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 pkgsrc/pkgtools/url2pkg/files/url2pkg.py

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/url2pkg/files/url2pkg.py
diff -u pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.44 pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.45
--- pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.44       Sat Jul 16 09:16:50 2022
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg.py    Fri Aug 26 20:11:35 2022
@@ -1,5 +1,5 @@
 #! @PYTHONBIN@
-# $NetBSD: url2pkg.py,v 1.44 2022/07/16 09:16:50 rillig Exp $
+# $NetBSD: url2pkg.py,v 1.45 2022/08/26 20:11:35 rillig Exp $
 
 # Copyright (c) 2019 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -123,14 +123,13 @@ class Globals:
     def pkgsrc_license(self, license_name: str) -> str:
         comment = ''
 
-        def suffix(suf: str, comm: str):
-            nonlocal license_name, comment
-            if comment == '' and license_name.endswith(suf):
-                comment = f'\t# {comm}'
-                license_name = license_name[:-len(suf)].rstrip()
-
-        suffix('| file LICENSE', 'OR file LICENSE')
-        suffix('+ file LICENSE', '+ file LICENSE')
+        if comment == '' and license_name.endswith('| file LICENSE'):
+            comment = f'\t# OR file LICENSE'
+            license_name = license_name[:-len('| file LICENSE')].rstrip()
+
+        if comment == '' and license_name.endswith('+ file LICENSE'):
+            comment = f'\t# + file LICENSE'
+            license_name = license_name[:-len('+ file LICENSE')].rstrip()
 
         known_licenses = (
             ('2-clause-bsd', 'BSD-2', 'bsd2', 'BSD_2_clause'),



Home | Main Index | Thread Index | Old Index