Revision cfef1cdc
fixed the issue of behavior list not corresponding to the GUI list
of behaviors
scout/libscout/generate_behavior_lists.py | ||
---|---|---|
66 | 66 |
LAST_PATH_CODE : last_paths, |
67 | 67 |
BASE_NAME_CODE : base_names} |
68 | 68 |
|
69 |
# Write all the replacements in R_FILES |
|
70 |
for outfile_name in R_FILES.keys(): |
|
71 |
with open(outfile_name, 'w') as outfile: |
|
72 |
with open(R_FILES[outfile_name], 'r') as infile: |
|
73 |
|
|
74 |
# Write an obvious header so no one will edit our nicely |
|
75 |
# generated file |
|
76 |
outfile.write(AUTOGEN_HEADER) |
|
69 |
# also simultaneously write a txt file for the GUI to read from |
|
70 |
with open("../scoutsim/behaviorList.txt", "w") as listFile: |
|
71 |
# Write all the replacements in R_FILES |
|
72 |
for outfile_name in sorted(R_FILES.keys()): |
|
73 |
with open(outfile_name, 'w') as outfile: |
|
74 |
with open(R_FILES[outfile_name], 'r') as infile: |
|
75 |
|
|
76 |
# Write an obvious header so no one will edit our nicely |
|
77 |
# generated file |
|
78 |
outfile.write(AUTOGEN_HEADER) |
|
77 | 79 |
|
78 |
for line in infile.readlines(): |
|
79 |
# If the line needs replacing, don't write the orgininal |
|
80 |
# to the output file; rather, write many versions of the |
|
81 |
# line replaced with each replacement value. |
|
82 |
replaced = False |
|
83 |
for r_key in replacements: |
|
84 |
if r_key in line: |
|
85 |
replaced = True |
|
86 |
for b in replacements[r_key]: |
|
87 |
outfile.write(line.replace(r_key, b)) |
|
88 |
# If it doesn't need replacing, just write the original |
|
89 |
if not replaced: |
|
90 |
outfile.write(line) |
|
80 |
for line in infile.readlines(): |
|
81 |
# If the line needs replacing, don't write the orgininal |
|
82 |
# to the output file; rather, write many versions of the |
|
83 |
# line replaced with each replacement value. |
|
84 |
replaced = False |
|
85 |
for r_key in replacements: |
|
86 |
if r_key in line: |
|
87 |
replaced = True |
|
88 |
for b in replacements[r_key]: |
|
89 |
outfile.write(line.replace(r_key, b)) |
|
90 |
if (r_key == BASE_NAME_CODE): |
|
91 |
listFile.write(b+"\n") |
|
92 |
# If it doesn't need replacing, just write the original |
|
93 |
if not replaced: |
|
94 |
outfile.write(line) |
|
95 |
|
|
96 |
|
Also available in: Unified diff