1
0

bytebeat_compiler.py: add verbose mode for subst.

This commit is contained in:
Intel A80486DX2-66 2024-01-09 18:04:26 +03:00
parent 2f346e7f5f
commit bd53ac920f
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -59,9 +59,15 @@ def read_from_file_or_stdin(path: str) -> str:
print("The specified file doesn't exist")
raise SystemExit
def substitute_vars(replacements: dict, text: str) -> str:
def substitute_vars(replacements: dict, text: str, verbose: bool) -> str:
if verbose:
print("Substituting values:")
for placeholder, replacement in replacements.items():
if verbose and placeholder != "bytebeat_contents":
print(placeholder, ": ", replacement, sep="")
text = text.replace(f"`{placeholder}`", str(replacement))
if verbose:
print()
return text
CC = fetch("CC")
@ -103,6 +109,8 @@ if __name__ == "__main__":
help="do not output anything during generation")
parser.add_argument("-v", "--verbose", default=False, action="store_true",
help="show progress during generation")
parser.add_argument("-E", "--show-substituted-values", default=False,
action="store_true", help="show substituted values")
args = parser.parse_args()
bytebeat_contents = read_from_file_or_stdin(args.file).strip()
@ -164,7 +172,7 @@ if __name__ == "__main__":
"silent_mode": "true" if args.silent else "false",
"verbose_mode": "true" if args.verbose and not args.silent else "false",
"fwrite_le": "../" + PATHS["fwrite_le_header"]
}, read_file(PATHS["template"])))
}, read_file(PATHS["template"]), args.show_substituted_values))
# Compile by invoking the shell script
print("Compiling")