Changeset View
Changeset View
Standalone View
Standalone View
src/bench/data/convert-raw-to-header.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2019 The Bitcoin developers | # Copyright (c) 2019 The Bitcoin developers | ||||
import sys | import sys | ||||
def main(test_name, input_file): | def main(test_name, input_file): | ||||
with open(input_file, "rb") as f: | with open(input_file, "rb") as f: | ||||
contents = f.read() | contents = f.read() | ||||
print("static unsigned const char {}[] = {{".format(test_name)) | print("static unsigned const char {}[] = {{".format(test_name)) | ||||
print(", ".join(map(lambda x: "0x{:02x}".format(ord(x)), contents))) | print(", ".join(map(lambda x: "0x{:02x}".format(x), contents))) | ||||
print("};") | print("};") | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
if len(sys.argv) != 3: | if len(sys.argv) != 3: | ||||
print("We need additional pylons!") | print("We need additional pylons!") | ||||
sys.exit(1) | sys.exit(1) | ||||
main(sys.argv[1], sys.argv[2]) | main(sys.argv[1], sys.argv[2]) |