[elbe-devel] [PATCH 17/37] Replace ambiguous variable name l

Benedikt Spranger b.spranger at linutronix.de
Wed Feb 7 15:28:44 CET 2024


From: Eduard Krein <eduard.krein at linutronix.de>

E.L.B.E. code related to collect and processing package licence files
often use l as variable for the actual proccessed license file.
Replace the ambiguous variable name l by the more expressive name lic.

Signed-off-by: Eduard Krein <eduard.krein at linutronix.de>
Signed-off-by: Benedikt Spranger <b.spranger at linutronix.de>
---
 elbepack/commands/parselicence.py | 36 +++++++++++++++----------------
 elbepack/commands/setsel.py       |  8 +++----
 elbepack/debinstaller.py          | 10 ++++-----
 elbepack/hdimg.py                 | 12 +++++------
 elbepack/licencexml.py            |  6 +++---
 elbepack/pkgutils.py              |  6 +++---
 elbepack/repomanager.py           |  6 +++---
 elbepack/updated.py               |  4 ++--
 8 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/elbepack/commands/parselicence.py b/elbepack/commands/parselicence.py
index 25626c33..4fbeee2d 100644
--- a/elbepack/commands/parselicence.py
+++ b/elbepack/commands/parselicence.py
@@ -48,13 +48,13 @@ class license_dep5_to_spdx (dict):
     def get_override(self, pkgname):
         return self.perpackage_override[pkgname]
 
-    def map_one_license(self, pkgname, l, errors):
+    def map_one_license(self, pkgname, lic, errors):
         if pkgname in self.perpackage_mapping:
-            if l in self.perpackage_mapping[pkgname]:
-                return self.perpackage_mapping[pkgname][l]
-        if l in self:
-            return self[l]
-        errors.append(f'no mapping for "{l}" for pkg "{pkgname}"')
+            if lic in self.perpackage_mapping[pkgname]:
+                return self.perpackage_mapping[pkgname][lic]
+        if lic in self:
+            return self[lic]
+        errors.append(f'no mapping for "{lic}" for pkg "{pkgname}"')
         return None
 
     def map_license_string(self, pkgname, l_string, errors):
@@ -82,9 +82,9 @@ class license_dep5_to_spdx (dict):
                 return self.perpackage_override[pkgname]
 
         retval = []
-        for l in licenses:
-            if l is not None:
-                retval.append(self.map_license_string(pkgname, l, errors))
+        for lic in licenses:
+            if lic is not None:
+                retval.append(self.map_license_string(pkgname, lic, errors))
             else:
                 retval.append('Empty license')
 
@@ -194,16 +194,16 @@ def run_command(argv):
             sp.clear()
             sp.et.text = '\n'
             lics = []
-            for l in pkg.node('debian_licenses'):
-                if l.et.text in lics:
+            for lic in pkg.node('debian_licenses'):
+                if lic.et.text in lics:
                     continue
-                lics.append(l.et.text)
+                lics.append(lic.et.text)
 
             mapped_lics = mapping.map_lic(pkg_name, lics, errors)
 
-            for l in mapped_lics:
+            for lic in mapped_lics:
                 ll = sp.append('license')
-                ll.et.text = l
+                ll.et.text = lic
 
             if not mapped_lics:
                 errors.append(f'empty mapped licenses in package "{pkg_name}"')
@@ -216,18 +216,18 @@ def run_command(argv):
                 sp = pkg.ensure_child('spdx_licenses')
                 sp.clear()
                 sp.et.text = '\n'
-                for l in mapping.get_override(pkg_name):
+                for lic in mapping.get_override(pkg_name):
                     ll = sp.append('license')
-                    ll.et.text = l
+                    ll.et.text = lic
 
         if opt.use_nomos:
             nomos_l = scan_nomos(pkg.text('text'))
             if nomos_l[0] != 'No_license_found':
                 nomos_node = pkg.append('nomos_licenses')
                 nomos_node.et.text = '\n'
-                for l in nomos_l:
+                for lic in nomos_l:
                     ll = nomos_node.append('license')
-                    ll.et.text = l
+                    ll.et.text = lic
 
         if errors:
             for e in errors:
diff --git a/elbepack/commands/setsel.py b/elbepack/commands/setsel.py
index 54c3580e..0c8e94b0 100644
--- a/elbepack/commands/setsel.py
+++ b/elbepack/commands/setsel.py
@@ -14,13 +14,13 @@ def parse_selections(fname):
 
     sels = []
 
-    for l in fp.readlines():
-        if not l:
+    for lic in fp.readlines():
+        if not lic:
             continue
-        if l[0] == '#':
+        if lic[0] == '#':
             continue
 
-        sp = l.split()
+        sp = lic.split()
 
         print(f"{sp[0]} {sp[1]}")
 
diff --git a/elbepack/debinstaller.py b/elbepack/debinstaller.py
index fb014207..cd189d0e 100644
--- a/elbepack/debinstaller.py
+++ b/elbepack/debinstaller.py
@@ -36,15 +36,15 @@ class ReleaseFile(HashValidator):
         current_header = ''
 
         with open(fname, 'r') as fp:
-            for l in fp.readlines():
-                m = header_re.match(l)
+            for lic in fp.readlines():
+                m = header_re.match(lic)
                 if m:
                     # line contains an rfc822 Header,
                     # remember it.
                     current_header = m.group(1)
                     continue
 
-                m = hash_re.match(l)
+                m = hash_re.match(lic)
                 if m:
                     # line contains a hash entry.
                     # check filename, whether we are interested in it
@@ -62,8 +62,8 @@ class SHA256SUMSFile(HashValidator):
         hash_re = re.compile(r'([0-9a-f]+)\s+(\S+)')
 
         with open(fname, 'r') as fp:
-            for l in fp.readlines():
-                m = hash_re.match(l)
+            for lic in fp.readlines():
+                m = hash_re.match(lic)
                 if m:
                     # line contains a hash entry.
                     # check filename, whether we are interested in it
diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
index ef2e8e3a..a7641473 100644
--- a/elbepack/hdimg.py
+++ b/elbepack/hdimg.py
@@ -584,13 +584,13 @@ def do_hdimg(xml, target, rfs, grub_version, grub_fw_type=None):
 
     # now move all mountpoints into own directories
     # begin from deepest mountpoints
-    for l in reversed(fslist):
-        do(f'mkdir -p "{os.path.join(fspath, l.id)}"')
-        do(f'mkdir -p "{rfs.fname("")}{l.mountpoint}"')
-        if rfs.listdir(l.mountpoint):
+    for lic in reversed(fslist):
+        do(f'mkdir -p "{os.path.join(fspath, lic.id)}"')
+        do(f'mkdir -p "{rfs.fname("")}{lic.mountpoint}"')
+        if rfs.listdir(lic.mountpoint):
             do(
-               f'mv "{rfs.fname(l.mountpoint)}"/* '
-               f'"{os.path.join(fspath, l.id)}"',
+               f'mv "{rfs.fname(lic.mountpoint)}"/* '
+               f'"{os.path.join(fspath, lic.id)}"',
                allow_fail=True)
 
     try:
diff --git a/elbepack/licencexml.py b/elbepack/licencexml.py
index 24cb1e9b..48528c80 100644
--- a/elbepack/licencexml.py
+++ b/elbepack/licencexml.py
@@ -21,10 +21,10 @@ remove_re = re.compile('[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F]')
 def do_heuristics(fp):
     c = Copyright()
     num_licenses = 0
-    for l in fp.readlines():
-        if l.startswith("License:"):
+    for lic in fp.readlines():
+        if lic.startswith("License:"):
             num_licenses += 1
-            _, v = l.split(":", 1)
+            _, v = lic.split(":", 1)
             data = {"License": v.strip()}
             lic_para = LicenseParagraph(data)
             c.add_license_paragraph(lic_para)
diff --git a/elbepack/pkgutils.py b/elbepack/pkgutils.py
index f5058a66..522b54f5 100644
--- a/elbepack/pkgutils.py
+++ b/elbepack/pkgutils.py
@@ -95,9 +95,9 @@ def extract_pkg_changelog(fname, extra_pkg=None):
     dch_dir = f"/usr/share/doc/{pkgname}"
 
     if fs.islink(dch_dir) and not extra_pkg:
-        l = fs.readlink(dch_dir)
-        print(dch_dir, l)
-        raise ChangelogNeedsDependency(l)
+        lic = fs.readlink(dch_dir)
+        print(dch_dir, lic)
+        raise ChangelogNeedsDependency(lic)
 
     dch_bin = f"/usr/share/doc/{pkgname}/changelog.Debian.{pkgarch}.gz"
     dch_src = f"/usr/share/doc/{pkgname}/changelog.Debian.gz"
diff --git a/elbepack/repomanager.py b/elbepack/repomanager.py
index fd784f0f..73085ce4 100644
--- a/elbepack/repomanager.py
+++ b/elbepack/repomanager.py
@@ -80,9 +80,9 @@ class RepoBase:
         # generate a new key and generate repository config
         if self.fs.isdir("/"):
             repo_conf = self.fs.read_file("conf/distributions")
-            for l in repo_conf.splitlines():
-                if l.startswith("SignWith"):
-                    self.keyid = l.split()[1]
+            for lic in repo_conf.splitlines():
+                if lic.startswith("SignWith"):
+                    self.keyid = lic.split()[1]
                     unlock_key(self.keyid)
         else:
             self.keyid = generate_elbe_internal_key()
diff --git a/elbepack/updated.py b/elbepack/updated.py
index 38d41d5b..a7c067f2 100644
--- a/elbepack/updated.py
+++ b/elbepack/updated.py
@@ -115,8 +115,8 @@ class UpdateService (ServiceBase):
 
         lists = os.listdir("/etc/apt/sources.list.d")
 
-        for l in lists:
-            snapshots += l[:len(l) - 5] + ","
+        for lic in lists:
+            snapshots += lic[:len(lic) - 5] + ","
 
         return snapshots
 
-- 
2.43.0



More information about the elbe-devel mailing list