Skip to content

Commit

Permalink
Make corrections from PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gianbelinche committed Jun 14, 2024
1 parent 1ee1574 commit 6d2d52d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
3 changes: 3 additions & 0 deletions generate_asm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

python3 scripts/generate_asm.py "$1" "$2"
7 changes: 6 additions & 1 deletion scripts/generate_asm.md → scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ This is a python script for generating arbitrary asm files.

It should be invoked like this:

`python3 generate_asm.py <path_to_your_asm_file>`
`python3 generate_asm.py <path_to_your_asm_file> <output_dir>`

Or from the root directory of this project

`./generate_asm.sh <path_to_your_asm_file> <output_dir>`


The asm given should have the following format:

Expand Down
11 changes: 6 additions & 5 deletions scripts/generate_asm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import re

def replace_asm(file):
def replace_asm(file,outpur_dir):
"""
Creates all the possible files with all the combinations of the replacements
"""
Expand All @@ -18,8 +18,9 @@ def replace_asm(file):
if len(new_files_to_replace) != 0:
files_to_replace = new_files_to_replace

file_name = file.rsplit(".",1)[0].rsplit("/",1)[1]
for j,_file in enumerate(files_to_replace):
with open(file[:-5] + "_replaced_" + str(j) + ".zasm", 'w') as f:
with open(outpur_dir + "/" + file_name + "_replaced_" + str(j) + ".zasm", 'w') as f:
for line in _file:
f.write(line)

Expand Down Expand Up @@ -64,10 +65,10 @@ def get_replacements(file):
return list(set(replacements))

def main():
if len(sys.argv) != 2:
print("Usage: python generate_asm.py <file>")
if len(sys.argv) != 3:
print("Usage: python generate_asm.py <file> <output_dir>")
sys.exit(1)
replace_asm(sys.argv[1])
replace_asm(sys.argv[1],sys.argv[2])

if __name__ == "__main__":
main()

0 comments on commit 6d2d52d

Please sign in to comment.