Cleanup for current pylint.

This commit is contained in:
Eric S. Raymond 2023-02-17 13:45:50 -05:00
parent a44ec19753
commit 60d7070506
3 changed files with 17 additions and 10 deletions

View file

@ -10,6 +10,9 @@ playermove().
Copyright (c) 2017 by Eric S. Raymond Copyright (c) 2017 by Eric S. Raymond
SPDX-License-Identifier: BSD-2-clause SPDX-License-Identifier: BSD-2-clause
""" """
# pylint: disable=consider-using-f-string
import sys, yaml import sys, yaml
YAML_NAME = "adventure.yaml" YAML_NAME = "adventure.yaml"
@ -524,7 +527,7 @@ def get_travel(travel):
return out return out
if __name__ == "__main__": if __name__ == "__main__":
with open(YAML_NAME, "r") as f: with open(YAML_NAME, "r", encoding='ascii', errors='surrogateescape') as f:
db = yaml.safe_load(f) db = yaml.safe_load(f)
locnames = [x[0] for x in db["locations"]] locnames = [x[0] for x in db["locations"]]
@ -536,10 +539,10 @@ if __name__ == "__main__":
db["objects"]) db["objects"])
ignore = "" ignore = ""
try: try:
with open(H_TEMPLATE_PATH, "r") as htf: with open(H_TEMPLATE_PATH, "r", encoding='ascii', errors='surrogateescape') as htf:
# read in dungeon.h template # read in dungeon.h template
h_template = DONOTEDIT_COMMENT + htf.read() h_template = DONOTEDIT_COMMENT + htf.read()
with open(C_TEMPLATE_PATH, "r") as ctf: with open(C_TEMPLATE_PATH, "r", encoding='ascii', errors='surrogateescape') as ctf:
# read in dungeon.c template # read in dungeon.c template
c_template = DONOTEDIT_COMMENT + ctf.read() c_template = DONOTEDIT_COMMENT + ctf.read()
except IOError as e: except IOError as e:
@ -587,10 +590,10 @@ if __name__ == "__main__":
state_definitions = statedefines state_definitions = statedefines
) )
with open(H_NAME, "w") as hf: with open(H_NAME, "w", encoding='ascii', errors='surrogateescape') as hf:
hf.write(h) hf.write(h)
with open(C_NAME, "w") as cf: with open(C_NAME, "w", encoding='ascii', errors='surrogateescape') as cf:
cf.write(c) cf.write(c)
# end # end

View file

@ -14,6 +14,8 @@ Make a DOT graph of Colossal Cave.
# Copyright (c) 2017 by Eric S. Raymond # Copyright (c) 2017 by Eric S. Raymond
# SPDX-License-Identifier: BSD-2-clause # SPDX-License-Identifier: BSD-2-clause
# pylint: disable=consider-using-f-string
import sys, getopt, yaml import sys, getopt, yaml
def allalike(loc): def allalike(loc):
@ -104,7 +106,7 @@ def reveal(objname):
return not obj.get("immovable") return not obj.get("immovable")
if __name__ == "__main__": if __name__ == "__main__":
with open("adventure.yaml", "r") as f: with open("adventure.yaml", "r", encoding='ascii', errors='surrogateescape') as f:
db = yaml.safe_load(f) db = yaml.safe_load(f)
location_lookup = dict(db["locations"]) location_lookup = dict(db["locations"])

View file

@ -12,6 +12,8 @@ even if the checkfile search doesn't find them. Typically this will because
they emit a templated message that can't be regression-tested by equality. they emit a templated message that can't be regression-tested by equality.
""" """
# pylint: disable=consider-using-f-string
import os import os
import sys import sys
import re import re
@ -197,7 +199,7 @@ def coverage_report(db, check_file_contents):
if __name__ == "__main__": if __name__ == "__main__":
# load DB # load DB
try: try:
with open(YAML_PATH, "r") as f: with open(YAML_PATH, "r", encoding='ascii', errors='surrogateescape') as f:
db = yaml.safe_load(f) db = yaml.safe_load(f)
except IOError as e: except IOError as e:
print('ERROR: could not load %s (%s)' % (YAML_PATH, e.strerror)) print('ERROR: could not load %s (%s)' % (YAML_PATH, e.strerror))
@ -207,7 +209,7 @@ if __name__ == "__main__":
check_file_contents = [] check_file_contents = []
for filename in os.listdir(TEST_DIR): for filename in os.listdir(TEST_DIR):
if filename.endswith(".chk"): if filename.endswith(".chk"):
with open(filename, "r") as f: with open(filename, "r", encoding='ascii', errors='surrogateescape') as f:
check_file_contents.append(f.read()) check_file_contents.append(f.read())
# run coverage analysis report on dungeon database # run coverage analysis report on dungeon database
@ -254,7 +256,7 @@ if __name__ == "__main__":
# render HTML report # render HTML report
try: try:
with open(HTML_TEMPLATE_PATH, "r") as f: with open(HTML_TEMPLATE_PATH, "r", encoding='ascii', errors='surrogateescape') as f:
# read in HTML template # read in HTML template
html_template = f.read() html_template = f.read()
except IOError as e: except IOError as e:
@ -263,7 +265,7 @@ if __name__ == "__main__":
# parse template with report and write it out # parse template with report and write it out
try: try:
with open(html_output_path, "w") as f: with open(html_output_path, "w", encoding='ascii', errors='surrogateescape') as f:
f.write(html_template.format(categories=categories_html, summary=summary_html)) f.write(html_template.format(categories=categories_html, summary=summary_html))
except IOError as e: except IOError as e:
print('ERROR: writing HTML report failed ({})'.format(e.strerror)) print('ERROR: writing HTML report failed ({})'.format(e.strerror))