Fix python linter

This commit is contained in:
Riccardo Schirone 2021-08-30 12:31:05 +02:00 committed by Riccardo Schirone
parent a5333f2a44
commit 9c05850d85
6 changed files with 18 additions and 12 deletions

View file

@ -819,10 +819,12 @@ cf_text = CMDDESCS_C_TEMPLATE.format(
helps="\n".join(helps),
init_code="\n".join(init_code),
)
with open(os.path.join(args.output_dir, "cmd_descs.c"), "w") as f:
with open(os.path.join(args.output_dir, "cmd_descs.c"), "w", encoding="utf8") as f:
f.write(cf_text)
if args.src_output_dir:
with open(os.path.join(args.src_output_dir, "cmd_descs.c"), "w") as f:
with open(
os.path.join(args.src_output_dir, "cmd_descs.c"), "w", encoding="utf8"
) as f:
f.write(cf_text)
handlers_decls = filter(
@ -833,8 +835,10 @@ handlers_decls = filter(
hf_text = CMDDESCS_H_TEMPLATE.format(
handlers_declarations="\n".join([handler2decl(t, h) for t, h in handlers_decls]),
)
with open(os.path.join(args.output_dir, "cmd_descs.h"), "w") as f:
with open(os.path.join(args.output_dir, "cmd_descs.h"), "w", encoding="utf8") as f:
f.write(hf_text)
if args.src_output_dir:
with open(os.path.join(args.src_output_dir, "cmd_descs.h"), "w") as f:
with open(
os.path.join(args.src_output_dir, "cmd_descs.h"), "w", encoding="utf8"
) as f:
f.write(hf_text)

View file

@ -18,7 +18,7 @@ meson_root = os.environ["MESON_SOURCE_ROOT"]
subproject_filename = os.path.join(meson_root, "subprojects", subproject + ".wrap")
try:
with open(subproject_filename, "r") as f:
with open(subproject_filename, "r", encoding="utf8") as f:
is_wrap_git = False
revision = None
@ -43,7 +43,9 @@ try:
subproject_dir = os.path.join(meson_root, "subprojects", directory)
subproject_git_dir = os.path.join(subproject_dir, ".git")
if os.path.isdir(subproject_dir) and os.path.isdir(subproject_git_dir):
with open(os.path.join(subproject_git_dir, "HEAD"), "r") as f:
with open(
os.path.join(subproject_git_dir, "HEAD"), "r", encoding="utf8"
) as f:
head = f.read().strip()
if head != revision:
sys.exit(1)

View file

@ -9,6 +9,6 @@ import os
from sys import argv
for fname in argv[1:]:
with open(fname) as f:
with open(fname, encoding="utf8") as f:
text = " ".join(f.read().splitlines())
print("ft %s %s" % (os.path.basename(fname), text))

View file

@ -8,8 +8,8 @@
import re
import sys
with open(sys.argv[1]) as inf:
with open(sys.argv[2], "w") as outf:
with open(sys.argv[1], encoding="utf8") as inf:
with open(sys.argv[2], "w", encoding="utf8") as outf:
for line in inf:
if not line.startswith("_") and "=" in line:
arr = re.split("=|,", line)

View file

@ -12,7 +12,7 @@ meson_file = "meson.build"
if len(sys.argv) > 1:
meson_file = os.path.join(sys.argv[1], meson_file)
with open(meson_file, "r") as f:
with open(meson_file, "r", encoding="utf8") as f:
# Read only first 10 lines of the meson file, looking for 'version: ' string
for i in range(10):
fields = [x.strip() for x in f.readline().strip().split(":")]

View file

@ -5,7 +5,7 @@
import copy
import sys
with open("/usr/include/sys/syscall.h", "r") as f:
with open("/usr/include/sys/syscall.h", "r", encoding="utf8") as f:
rec = {"name": None, "args": None}
recs = {}
@ -37,7 +37,7 @@ with open("/usr/include/sys/syscall.h", "r") as f:
recs[int(callnum)] = copy.copy(rec)
rec = {"name": None, "args": None}
with open("openbsd.c", "w") as out:
with open("openbsd.c", "w", encoding="utf8") as out:
out.write('#include "r_syscall.h"\n\n/* syscall-openbsd */\n')
out.write("RSyscallItem syscalls_openbsd_x86[] = {\n")