Linux-Firmware Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: <linux-firmware@kernel.org>, Josh Boyer <jwboyer@kernel.org>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH 17/20] check_whence: reformat using python black
Date: Tue, 15 Aug 2023 13:00:15 -0500	[thread overview]
Message-ID: <20230815180018.25554-18-mario.limonciello@amd.com> (raw)
In-Reply-To: <20230815180018.25554-1-mario.limonciello@amd.com>

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 check_whence.py | 85 +++++++++++++++++++++++++++++--------------------
 1 file changed, 50 insertions(+), 35 deletions(-)

diff --git a/check_whence.py b/check_whence.py
index d45d90f8..bf14aed6 100755
--- a/check_whence.py
+++ b/check_whence.py
@@ -3,48 +3,53 @@
 import os, re, sys
 from io import open
 
+
 def list_whence():
-    with open('WHENCE', encoding='utf-8') as whence:
+    with open("WHENCE", encoding="utf-8") as whence:
         for line in whence:
             match = re.match(r'(?:File|Source):\s*"(.*)"', line)
             if match:
                 yield match.group(1)
                 continue
-            match = re.match(r'(?:File|Source):\s*(\S*)', line)
+            match = re.match(r"(?:File|Source):\s*(\S*)", line)
             if match:
                 yield match.group(1)
                 continue
-            match = re.match(r'Licen[cs]e: (?:.*\bSee (.*) for details\.?|(\S*))\n',
-                             line)
+            match = re.match(
+                r"Licen[cs]e: (?:.*\bSee (.*) for details\.?|(\S*))\n", line
+            )
             if match:
                 if match.group(1):
-                    for name in re.split(r', | and ', match.group(1)):
+                    for name in re.split(r", | and ", match.group(1)):
                         yield name
                     continue
                 if match.group(2):
                     # Just one word - may or may not be a filename
-                    if not re.search(r'unknown|distributable', match.group(2),
-                                     re.IGNORECASE):
+                    if not re.search(
+                        r"unknown|distributable", match.group(2), re.IGNORECASE
+                    ):
                         yield match.group(2)
                         continue
 
+
 def list_whence_files():
-    with open('WHENCE', encoding='utf-8') as whence:
+    with open("WHENCE", encoding="utf-8") as whence:
         for line in whence:
-            match = re.match(r'File:\s*(.*)', line)
+            match = re.match(r"File:\s*(.*)", line)
             if match:
-                yield match.group(1).replace("\ ", " ").replace("\"", "")
+                yield match.group(1).replace("\ ", " ").replace('"', "")
                 continue
 
+
 def list_links_list():
-    with open('WHENCE', encoding='utf-8') as whence:
+    with open("WHENCE", encoding="utf-8") as whence:
         for line in whence:
-            match = re.match(r'Link:\s*(.*)', line)
+            match = re.match(r"Link:\s*(.*)", line)
             if match:
                 linkname, target = match.group(1).split("->")
 
-                linkname = linkname.strip().replace("\ ", " ").replace("\"", "")
-                target = target.strip().replace("\ ", " ").replace("\"", "")
+                linkname = linkname.strip().replace("\ ", " ").replace('"', "")
+                target = target.strip().replace("\ ", " ").replace('"', "")
 
                 # Link target is relative to the link
                 target = os.path.join(os.path.dirname(linkname), target)
@@ -53,42 +58,49 @@ def list_links_list():
                 yield (linkname, target)
                 continue
 
+
 def list_git():
-    with os.popen('git ls-files') as git_files:
+    with os.popen("git ls-files") as git_files:
         for line in git_files:
-            yield line.rstrip('\n')
+            yield line.rstrip("\n")
+
 
 def main():
     ret = 0
     whence_list = list(list_whence())
     whence_files = list(list_whence_files())
     links_list = list(list_links_list())
-    known_files = set(name for name in whence_list if not name.endswith('/')) | \
-                  set(['check_whence.py', 'configure', 'Makefile',
-                       'README', 'copy-firmware.sh', 'WHENCE'])
-    known_prefixes = set(name for name in whence_list if name.endswith('/'))
+    known_files = set(name for name in whence_list if not name.endswith("/")) | set(
+        [
+            "check_whence.py",
+            "configure",
+            "Makefile",
+            "README",
+            "copy-firmware.sh",
+            "WHENCE",
+        ]
+    )
+    known_prefixes = set(name for name in whence_list if name.endswith("/"))
     git_files = set(list_git())
 
-    for name in set(name for name in whence_files if name.endswith('/')):
-        sys.stderr.write('E: %s listed in WHENCE as File, but is directory\n' %
-                         name)
+    for name in set(name for name in whence_files if name.endswith("/")):
+        sys.stderr.write("E: %s listed in WHENCE as File, but is directory\n" % name)
         ret = 1
 
     for name in set(fw for fw in whence_files if whence_files.count(fw) > 1):
-        sys.stderr.write('E: %s listed in WHENCE twice\n' % name)
+        sys.stderr.write("E: %s listed in WHENCE twice\n" % name)
         ret = 1
 
     for name in set(link for link in whence_files if os.path.islink(link)):
-        sys.stderr.write('E: %s listed in WHENCE as File, but is a symlink\n' %
-                         name)
+        sys.stderr.write("E: %s listed in WHENCE as File, but is a symlink\n" % name)
         ret = 1
 
     for name in set(link[0] for link in links_list if os.path.islink(link[0])):
-        sys.stderr.write('E: %s listed in WHENCE as Link, is in tree\n' % name)
+        sys.stderr.write("E: %s listed in WHENCE as Link, is in tree\n" % name)
         ret = 1
 
     for name in sorted(list(known_files - git_files)):
-        sys.stderr.write('E: %s listed in WHENCE does not exist\n' % name)
+        sys.stderr.write("E: %s listed in WHENCE does not exist\n" % name)
         ret = 1
 
     # A link can point to another link, or to a file...
@@ -99,20 +111,22 @@ def main():
         dirname = target
         while True:
             dirname = os.path.dirname(dirname)
-            if dirname == '':
+            if dirname == "":
                 break
             valid_targets.add(dirname)
 
     for name, target in sorted(links_list):
         if target not in valid_targets:
-            sys.stderr.write('E: target %s of link %s in WHENCE'
-                             ' does not exist\n' % (target, name))
+            sys.stderr.write(
+                "E: target %s of link %s in WHENCE" " does not exist\n" % (target, name)
+            )
             ret = 1
 
     for name in sorted(list(git_files - known_files)):
         # Ignore subdirectory changelogs and GPG detached signatures
-        if (name.endswith('/ChangeLog') or
-            (name.endswith('.asc') and name[:-4] in known_files)):
+        if name.endswith("/ChangeLog") or (
+            name.endswith(".asc") and name[:-4] in known_files
+        ):
             continue
 
         # Ignore unknown files in known directories
@@ -120,9 +134,10 @@ def main():
             if name.startswith(prefix):
                 break
         else:
-            sys.stderr.write('E: %s not listed in WHENCE\n' % name)
+            sys.stderr.write("E: %s not listed in WHENCE\n" % name)
             ret = 1
     return ret
 
-if __name__ == '__main__':
+
+if __name__ == "__main__":
     sys.exit(main())
-- 
2.25.1


  parent reply	other threads:[~2023-08-15 18:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-15 17:59 [PATCH 00/20] Add preparations to be able to run in a CI/CD system Mario Limonciello
2023-08-15 17:59 ` [PATCH 01/20] ath11k: update typographical errors in the Notice.txt files Mario Limonciello
2023-08-15 18:00 ` [PATCH 02/20] ath10k: correct " Mario Limonciello
2023-08-15 18:00 ` [PATCH 03/20] i915: correct typographical errors caught by codespell Mario Limonciello
2023-08-15 18:00 ` [PATCH 04/20] adsp_sst: " Mario Limonciello
2023-08-15 18:00 ` [PATCH 05/20] agere: correct typographical errors in LICENSE " Mario Limonciello
2023-08-15 18:00 ` [PATCH 06/20] qca: correct typographical errors in NOTICE.txt " Mario Limonciello
2023-08-15 18:00 ` [PATCH 07/20] usbdux: correct typographical errors " Mario Limonciello
2023-08-15 18:00 ` [PATCH 08/20] dsp56k: correct typographical error " Mario Limonciello
2023-08-15 18:00 ` [PATCH 09/20] cxgb4: correct typographical errors " Mario Limonciello
2023-08-15 18:00 ` [PATCH 10/20] cavium_liquidio: fix " Mario Limonciello
2023-08-15 18:00 ` [PATCH 11/20] kaweth: correct " Mario Limonciello
2023-08-15 18:00 ` [PATCH 12/20] xc5000c: " Mario Limonciello
2023-08-15 18:00 ` [PATCH 13/20] qcom: " Mario Limonciello
2023-08-15 18:00 ` [PATCH 14/20] keyspan_pda: " Mario Limonciello
2023-08-15 18:00 ` [PATCH 15/20] carl9170fw: " Mario Limonciello
2023-08-15 18:00 ` [PATCH 16/20] WHENCE: " Mario Limonciello
2023-08-15 18:00 ` Mario Limonciello [this message]
2023-08-15 18:00 ` [PATCH 18/20] Add CI/CD with ci-fairy Mario Limonciello
2023-08-15 18:00 ` [PATCH 19/20] Wire up pre-commit to `make check` Mario Limonciello
2023-08-15 18:00 ` [PATCH 20/20] Rewrite README in markdown Mario Limonciello
2023-08-25 17:22 ` [PATCH 00/20] Add preparations to be able to run in a CI/CD system Dmitry Baryshkov
2023-08-28 11:15   ` Josh Boyer
2023-08-30 15:51     ` Mario Limonciello

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230815180018.25554-18-mario.limonciello@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=jwboyer@kernel.org \
    --cc=linux-firmware@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox