diff options
author | rillig <rillig@pkgsrc.org> | 2022-08-26 20:11:35 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2022-08-26 20:11:35 +0000 |
commit | f04be7e32f5fe737594a650edb25f563a1819800 (patch) | |
tree | f417655ebf1ecebae0fb5593df8e908cdad0dd1f /pkgtools | |
parent | 3e984cb9aaa53008e128b594ecbd1354f1692e52 (diff) | |
download | pkgsrc-f04be7e32f5fe737594a650edb25f563a1819800.tar.gz |
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.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/url2pkg/files/url2pkg.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/pkgtools/url2pkg/files/url2pkg.py b/pkgtools/url2pkg/files/url2pkg.py index 9cf59bfc208..74964accda7 100644 --- a/pkgtools/url2pkg/files/url2pkg.py +++ b/pkgtools/url2pkg/files/url2pkg.py @@ -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() + if comment == '' and license_name.endswith('| file LICENSE'): + comment = f'\t# OR file LICENSE' + license_name = license_name[:-len('| file LICENSE')].rstrip() - suffix('| file LICENSE', 'OR file LICENSE') - suffix('+ file LICENSE', '+ file LICENSE') + 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'), |