Copyright (c) 2017 by Eric S. Raymond
SPDX-License-Identifier: BSD-2-clause
"""
+
+# pylint: disable=consider-using-f-string,line-too-long,invalid-name,missing-function-docstring,too-many-branches,global-statement,multiple-imports,too-many-locals,too-many-statements,too-many-nested-blocks,no-else-return,raise-missing-from,redefined-outer-name
+
import sys, yaml
YAML_NAME = "adventure.yaml"
H_TEMPLATE_PATH = "templates/dungeon.h.tpl"
C_TEMPLATE_PATH = "templates/dungeon.c.tpl"
-DONOTEDIT_COMMENT = "/* Generated from adventure.yaml - do not hand-hack! */\n\n"
+DONOTEDIT_COMMENT = "/* Generated from adventure.yaml - do not hand-hack! */\n/* SPDX-License-Identifier: BSD-2-clause */\n\n"
statedefines = ""
return out
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)
locnames = [x[0] for x in db["locations"]]
db["objects"])
ignore = ""
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
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
c_template = DONOTEDIT_COMMENT + ctf.read()
except IOError as e:
state_definitions = statedefines
)
- with open(H_NAME, "w") as hf:
+ with open(H_NAME, "w", encoding='ascii', errors='surrogateescape') as hf:
hf.write(h)
- with open(C_NAME, "w") as cf:
+ with open(C_NAME, "w", encoding='ascii', errors='surrogateescape') as cf:
cf.write(c)
# end