about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xtools/git-blame-stats/git-blame-stats.py16
-rwxr-xr-xtools/ipconverter/ipconverter.py13
-rwxr-xr-xtools/seqstat/seqstat.py20
3 files changed, 28 insertions, 21 deletions
diff --git a/tools/git-blame-stats/git-blame-stats.py b/tools/git-blame-stats/git-blame-stats.py
index ee52ce4..3cc4f4a 100755
--- a/tools/git-blame-stats/git-blame-stats.py
+++ b/tools/git-blame-stats/git-blame-stats.py
@@ -2,7 +2,7 @@
 
 import argparse
 import subprocess
-import sys
+from typing import Any
 
 
 parser = argparse.ArgumentParser()
@@ -11,7 +11,7 @@ parser.add_argument(
 )
 args = parser.parse_args()
 
-authors = dict()
+authors: dict[str, Any] = dict()
 max_lenght_author = 0
 max_lenght_email = 0
 
@@ -50,9 +50,9 @@ files = get_files(args.rev)
 for filename in files:
     try:
         for block in line_info(filename.rstrip(), args.rev):
-            author = None
-            author_email = None
-            commit = None
+            author = ""
+            author_email = ""
+            commit = ""
             skip = False
             for i, val in enumerate(block):
                 if i == 0:
@@ -65,10 +65,10 @@ for filename in files:
                     author_email = " ".join(val.split()[1:])
                     continue
                 if val.startswith("\t") and val == "\t":
-                    skip == True
+                    skip = True
             if skip:
                 continue
-            if authors.get(author, None) == None:
+            if authors.get(author, None) is None:
                 authors[author] = {
                     "email": author_email,
                     "commits": set(),
@@ -82,7 +82,7 @@ for filename in files:
                 max_lenght_author = len(author)
             if len(author_email) > max_lenght_email:
                 max_lenght_email = len(author_email)
-    except Exception as e:
+    except Exception:
         continue
 
 for author, stats in authors.items():
diff --git a/tools/ipconverter/ipconverter.py b/tools/ipconverter/ipconverter.py
index fffc6fa..6b01d5d 100755
--- a/tools/ipconverter/ipconverter.py
+++ b/tools/ipconverter/ipconverter.py
@@ -3,8 +3,6 @@
 import argparse
 import ipaddress
 import sys
-import fileinput
-
 
 argp = argparse.ArgumentParser()
 argp.add_argument("infile", nargs="?", type=argparse.FileType("r"), default=sys.stdin)
@@ -12,14 +10,19 @@ args = argp.parse_args()
 
 # read the input, filter out commented lines and remove new line characters
 string_ips = [
-    ip for l in args.infile.readlines() if (ip := l.strip()) and not ip.startswith("#")
+    ip
+    for line in args.infile.readlines()
+    if (ip := line.strip()) and not ip.startswith("#")
 ]
 
 # convert entries to int if the string is a numeric value
 ips = list(map(lambda n: int(n) if n.isnumeric() else n, string_ips))
 
-# helper function to convert based on the name of the program
-conv = lambda n: int(n) if argp.prog == "ip2int" else str(n)
+
+def conv(n):
+    """helper function to convert based on the name of the program"""
+    return int(n) if argp.prog == "ip2int" else str(n)
+
 
 for ip in ips:
     try:
diff --git a/tools/seqstat/seqstat.py b/tools/seqstat/seqstat.py
index 8450ec8..55b6ecc 100755
--- a/tools/seqstat/seqstat.py
+++ b/tools/seqstat/seqstat.py
@@ -4,12 +4,6 @@ import argparse
 
 ticks = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"]
 
-parser = argparse.ArgumentParser()
-parser.add_argument(
-    "numbers", metavar="N", type=float, nargs="+", help="a number for the accumulator"
-)
-args = parser.parse_args()
-
 
 def histogram(sequence):
     min_val = min(sequence)
@@ -22,5 +16,15 @@ def histogram(sequence):
     return [ticks[int((int(i - min_val) << 8) / scale)] for i in sequence]
 
 
-h = histogram(args.numbers)
-print("".join(h))
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser()
+    parser.add_argument(
+        "numbers",
+        metavar="N",
+        type=float,
+        nargs="+",
+        help="a number for the accumulator",
+    )
+    args = parser.parse_args()
+    h = histogram(args.numbers)
+    print("".join(h))