summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2024-06-07 10:43:43 +0200
committerAndrei Pavel <andrei@isc.org>2024-06-20 17:52:09 +0200
commit9c35a4db68bea17f6d9f028d01722d61c461ef59 (patch)
tree45a8f4d2a4f60847b26b083e49bd0dccb8ed11c4 /tools
parent[#3287] fix pycodestyle warnings (diff)
downloadkea-9c35a4db68bea17f6d9f028d01722d61c461ef59.tar.xz
kea-9c35a4db68bea17f6d9f028d01722d61c461ef59.zip
[#3287] fix pylint warnings
- C0115: Missing class docstring (missing-class-docstring) - C0123: Use isinstance() rather than type() for a typecheck. (unidiomatic-typecheck) - C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) - C0206: Consider iterating with .items() (consider-using-dict-items) - C0411: standard import "..." should be placed before "..." (wrong-import-order) - C0415: Import outside toplevel (...) (import-outside-toplevel) - C1802: Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty (use-implicit-booleaness-not-len) - E0001: Parsing failed: 'invalid syntax (<unknown>, line 2313)' (syntax-error) - E0401: Unable to import '...' (import-error) - E0602: Undefined variable 'l' (undefined-variable) - R0205: Class 'VagrantEnv' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance) - E1101: Instance of 'NSECBASE' has no 'dump_fixedpart' member (no-member) - E1123: Unexpected keyword argument 'capture' in method call (unexpected-keyword-arg) - R0902: Too many instance attributes (too-many-instance-attributes) - R0913: Too many arguments (too-many-arguments) - R0916: Too many boolean expressions in if statement (6/5) (too-many-boolean-expressions) - R1717: Consider using a dictionary comprehension (consider-using-dict-comprehension) - R1722: Consider using 'sys.exit' instead (consider-using-sys-exit) - R1732: Consider using 'with' for resource-allocating operations (consider-using-with) - R1735: Consider using '{}' instead of a call to 'dict'. (use-dict-literal) - W0102: Dangerous default value sys.argv[1:] (builtins.list) as argument (dangerous-default-value) - W0102: Dangerous default value {} as argument (dangerous-default-value) - W0106: Expression "[f.write('%02x' % x) for x in bin_address]" is assigned to nothing (expression-not-assigned) - W0107: Unnecessary pass statement (unnecessary-pass) - W0201: Attribute 'config' defined outside __init__ (attribute-defined-outside-init) - W0404: Reimport '...' (imported line ...) (reimported) - W0611: Unused import ... (unused-import) - W0612: Unused variable '...' (unused-variable) - W0613: Unused argument '...' (unused-argument) - W0621: Redefining name '...' from outer scope (line 1471) (redefined-outer-name) - W0622: Redefining built-in '...' (redefined-builtin) - W0707: Consider explicitly re-raising using 'raise ... from ...' (raise-missing-from) - W0718: Catching too general exception Exception (broad-exception-caught) - W1202: Use lazy % formatting in logging functions (logging-format-interpolation) - W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation) - W1308: Duplicate string formatting argument 'connection_type', consider passing as named argument (duplicate-string-formatting-argument) - W1401: Anomalous backslash in string: '\/'. String constant might be missing an r prefix. (anomalous-backslash-in-string) - W1406: The u prefix for strings is no longer necessary in Python >=3.0 (redundant-u-string-prefix) - W1514: Using open without explicitly specifying an encoding (unspecified-encoding) - W4901: Deprecated module 'optparse' (deprecated-module) - W4904: Using deprecated class SafeConfigParser of module configparser (deprecated-class)
Diffstat (limited to 'tools')
-rwxr-xr-xtools/git-obsolete-branch.py54
-rwxr-xr-xtools/kea-breeder/kb.py29
-rw-r--r--tools/reorder_message_file.py3
3 files changed, 39 insertions, 47 deletions
diff --git a/tools/git-obsolete-branch.py b/tools/git-obsolete-branch.py
index 2639b21a7d..d1485aa1cb 100755
--- a/tools/git-obsolete-branch.py
+++ b/tools/git-obsolete-branch.py
@@ -15,7 +15,7 @@
# git pull
# git remote prune origin
#
-# This script requires python 2.7 or 3.
+# This script requires python 3.
#
# I have limited experience in Python. If things are done in a strange or
# uncommon way, there are no obscure reasons to do it that way, just plain
@@ -23,9 +23,7 @@
#
# tomek
-import string
-import sys
-from optparse import OptionParser
+import argparse
# [B404:blacklist] Consider possible security implications associated with subprocess module.
import subprocess # nosec B404
@@ -157,39 +155,31 @@ def check_output(cmd):
return subprocess.check_output(cmd) # nosec B603
-def parse_args(args=sys.argv[1:], Parser=OptionParser):
-
- parser = Parser(description="This script prints out merged and/or unmerged"
- " branches of a GIT tree.")
-
- parser.add_option("-c", "--csv", action="store_true",
- default=False, help="generates CSV output")
- parser.add_option("-u", "--unmerged", action="store_true",
- default=False, help="lists unmerged branches")
- parser.add_option("-m", "--skip-merged", action="store_true",
- default=False, help="omits listing merged branches")
- parser.add_option("-s", "--stats", action="store_true",
- default=False, help="prints also statistics")
-
- (options, args) = parser.parse_args(args)
+def parse_args():
+ parser = argparse.ArgumentParser(
+ description="This script prints out merged and/or unmerged branches of a GIT tree.",
+ usage="""%prog
+ Lists all obsolete (fully merged into master) branches.
+""")
- if args:
- parser.print_help()
- sys.exit(1)
+ parser.add_argument("-c", "--csv", action="store_true",
+ default=False, help="generates CSV output")
+ parser.add_argument("-u", "--unmerged", action="store_true",
+ default=False, help="lists unmerged branches")
+ parser.add_argument("-m", "--skip-merged", action="store_true",
+ default=False, help="omits listing merged branches")
+ parser.add_argument("-s", "--stats", action="store_true",
+ default=False, help="prints also statistics")
- return options
+ return parser.parse_args()
def main():
- usage = """%prog
- Lists all obsolete (fully merged into master) branches.
- """
-
- options = parse_args()
- csv = options.csv
- merged = not options.skip_merged
- unmerged = options.unmerged
- stats = options.stats
+ args = parse_args()
+ csv = args.csv
+ merged = not args.skip_merged
+ unmerged = args.unmerged
+ stats = args.stats
if csv:
print("branch name,status,date,last commit(mail),last commit(name)")
diff --git a/tools/kea-breeder/kb.py b/tools/kea-breeder/kb.py
index 3122b0f720..4ee8d5c5d2 100755
--- a/tools/kea-breeder/kb.py
+++ b/tools/kea-breeder/kb.py
@@ -1,14 +1,14 @@
#!/usr/bin/env python3
import argparse
-from termcolor import colored, cprint
-from io import StringIO
import json
import os
import re
-import sqlalchemy as db
-from sqlalchemy.sql import select
import sys
+from io import StringIO
+
+import sqlalchemy as db # pylint: disable=import-error
+from termcolor import cprint # pylint: disable=import-error
def convert_to_db(entity_name, make_singular=True):
@@ -86,6 +86,7 @@ class State:
class ConfigFile:
def __init__(self, filename):
+ self.config = {}
self.filename = filename
def load(self):
@@ -93,7 +94,7 @@ class ConfigFile:
print('The all keys file %s does not exist.' % self.filename)
sys.exit(1)
- with open(self.filename) as f:
+ with open(self.filename, encoding='utf-8') as f:
self.config = json.load(f)
f.close()
@@ -232,17 +233,17 @@ def main():
sys.exit(1)
sanitized_contents = ''
- f = open(args.all_keys_file)
- for line in f:
- sanitized_line = line.strip()
- if not sanitized_line:
- continue
+ with open(args.all_keys_file, encoding='utf-8') as f:
+ for line in f:
+ sanitized_line = line.strip()
+ if not sanitized_line:
+ continue
- if sanitized_line.find('//') != -1 or sanitized_line.find('#') != -1:
- continue
+ if sanitized_line.find('//') != -1 or sanitized_line.find('#') != -1:
+ continue
- sanitized_line = sanitized_line.replace(': .', ': 0.')
- sanitized_contents = sanitized_contents + sanitized_line
+ sanitized_line = sanitized_line.replace(': .', ': 0.')
+ sanitized_contents = sanitized_contents + sanitized_line
f.close()
diff --git a/tools/reorder_message_file.py b/tools/reorder_message_file.py
index 9483a58d96..368282dd13 100644
--- a/tools/reorder_message_file.py
+++ b/tools/reorder_message_file.py
@@ -160,7 +160,8 @@ def process_file(filename):
Parameters:
filename Name of the message file to process
"""
- lines = open(filename).read().splitlines()
+ with open(filename, encoding='utf-8') as f:
+ lines = f.read().splitlines()
# Search for the first line starting with the percent character. Everything
# before it is considered the file header and is copied to the output with