print(f"checking {source}...")
- with open(source, "rt", encoding="utf-8") as f:
- original = f.read()
+ original = Path(source).read_text(encoding="utf-8")
# ask `clang-format` to style the file
reformatted = subprocess.check_output(["clang-format", "--style=file", "--",
log.info(f"SHA256 summing {path}")
check = Path(f"{path}.sha256")
- with open(check, "wt", encoding="utf-8") as f:
- with open(path, "rb") as data:
- f.write(f"{hashlib.sha256(data.read()).hexdigest()} {path}\n")
+ data = path.read_bytes()
+ check.write_text(f"{hashlib.sha256(data).hexdigest()} {path}\n",
+ encoding="utf-8")
return check
def is_macos_artifact(path: Path) -> bool:
# retrieve version name left by prior CI tasks
log.info("reading GRAPHVIZ_VERSION")
- with open("GRAPHVIZ_VERSION", "rt", encoding="utf-8") as f:
- gv_version = f.read().strip()
+ gv_version = Path("GRAPHVIZ_VERSION").read_text(encoding="utf-8").strip()
log.info(f"GRAPHVIZ_VERSION == {gv_version}")
# if we were not passed an explicit version, use the one from the
with tempfile.TemporaryDirectory() as tmp:
# write a dummy config.h to allow standalone compilation
- with open(Path(tmp) / "config.h", "wt", encoding="utf-8") as _:
- pass
+ (Path(tmp) / "config.h").write_text("", encoding="utf-8")
# compile the stub to something we can run
xml_exe = Path(tmp) / "xml.exe"
subprocess.check_call(["diffimg", ref, output])
else:
fail = False
- with open(ref, "rt", encoding="utf-8") as a:
- with open(output, "rt", encoding="utf-8") as b:
- for line in difflib.unified_diff(a.read(), b.read(),
- fromfile=str(ref),
- tofile=str(output)):
- sys.stderr.write(f"{line}\n")
- fail = True
+ a = ref.read_text(encoding="utf-8")
+ b = output.read_text(encoding="utf-8")
+ for line in difflib.unified_diff(a, b,
+ fromfile=str(ref),
+ tofile=str(output)):
+ sys.stderr.write(f"{line}\n")
+ fail = True
if fail:
raise RuntimeError(f"diff {ref} {output} failed")