1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 12:27:34 +00:00

Meta: Resolve some pylint violations in Python lint scripts

Resolves:

* all: consider-using-sys-exit
* all: wrong-import-order
* all: TODO: Require that a few keys are set? (fixme)
* some: missing-function-docstring
* some: line-too-long
This commit is contained in:
Brendan Coles 2021-04-02 09:26:37 +00:00 committed by Andreas Kling
parent e875513ff7
commit 666aeecaa2
4 changed files with 140 additions and 54 deletions

View file

@ -2,20 +2,42 @@
import os
import re
import sys
# Matches e.g. "| [`bash`]..." and captures "bash" in group 1
PORT_TABLE_REGEX = re.compile(r'^\| \[`([^`]+)`\][^`]+$', re.MULTILINE)
PORT_TABLE_FILE = 'AvailablePorts.md'
IGNORE_FILES = {'.gitignore', '.port_include.sh', PORT_TABLE_FILE, 'build_all.sh', 'build_installed.sh', 'ReadMe.md'}
IGNORE_FILES = {
'.gitignore',
'.port_include.sh',
PORT_TABLE_FILE,
'build_all.sh',
'build_installed.sh',
'ReadMe.md'
}
def read_port_table(filename):
"""Open a file and find all PORT_TABLE_REGEX matches.
Args:
filename (str): file name
Returns:
set: all PORT_TABLE_REGEX matches
"""
with open(filename, 'r') as fp:
return set(PORT_TABLE_REGEX.findall(fp.read()))
def read_port_dirs():
"""Check Ports directory for unexpected files and check each port has a package.sh file.
Returns:
list: all ports (set), errors encountered (bool)
"""
ports = set()
all_good = True
for entry in os.listdir():
@ -35,6 +57,8 @@ def read_port_dirs():
def run():
"""Check Ports directory contents for errors."""
from_table = read_port_table(PORT_TABLE_FILE)
from_fs, all_good = read_port_dirs()
@ -51,12 +75,11 @@ def run():
print(' {}'.format(port))
if not all_good:
exit(1)
sys.exit(1)
print('No issues found.')
if __name__ == '__main__':
os.chdir(os.path.dirname(__file__) + "/../Ports")
# Ignore argv
run()