@@ -105,17 +105,19 @@ def main(file):
105
105
print ("\t ------- Tag: %s -------" % tag )
106
106
107
107
start_of_config_block = file .find ('Name:' , start )
108
- updated_config = str (file [ : start_of_config_block ]) # + "Configuration parameters\n------------------------\n")
108
+ updated_config = str (file [ : start_of_config_block ])
109
109
for line in out .splitlines ():
110
110
if 'Name' in line and tag in line :
111
111
updated_config += line
112
112
113
113
# Collect all text until next parameter name. If there's no following 'Name:' token, its the last
114
- # config option, match to 'Macros' instead to termiante the block
115
- if out .find ('Name:' , out .find (line ) + 4 ) > 0 :
116
- updated_config += out [out .find ('\n ' , out .find (line )) : out .find ('Name:' , out .find (line ) + 4 )]
114
+ # config option, match to 'Macros' instead to termiante the block. Offset starting index to avoid finding
115
+ # the current line's 'Name:' token.
116
+ eol = out .find ('\n ' , out .find (line ))
117
+ if out .find ('Name:' , out .find (line ) + len ('Name:' )) > 0 :
118
+ updated_config += out [eol : out .find ('Name:' , out .find (line ) + len ('Name:' ))]
117
119
else :
118
- updated_config += out [out . find ( ' \n ' , out . find ( line )) : out .find ('Macros' , out .find (line ) + 4 )]
120
+ updated_config += out [eol : out .find ('Macros' , out .find (line ))]
119
121
120
122
updated_config += str (file [end :])
121
123
else :
0 commit comments