1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2025-06-07 00:51:40 +00:00

Tests: allow to fix compressed files

This commit is contained in:
The Tumultuous Unicorn Of Darkness 2025-04-30 21:31:56 +02:00
parent aeb788c723
commit 8ba8465bb1
No known key found for this signature in database
GPG key ID: 1E55EE2EFF18BC1A

View file

@ -38,7 +38,17 @@ def fmt_error(err):
return "{} expected `{}'\n{} got `{}'".format(pfix, err[1], ' '*len(pfix), err[2])
def fixFile(filename, input_lines, output_lines):
f = open(filename, "wt")
pfilename = Path(filename)
if len(pfilename.suffixes) >= 2:
# Compressed file
if pfilename.suffixes[1] == ".xz":
f = lzma.open(pfilename, "wt")
else:
print(f"Cannot fix {pfilename.name} because {''.join(pfilename.suffixes[1:])} is not supported")
return
else:
# Plain text file
f = open(pfilename, "wt")
f.writelines([s + "\n" for s in input_lines])
f.write(delimiter + "\n")
f.writelines([s + "\n" for s in output_lines])