I'm new to python and I m trying to parse a file. I have a file with this format :
Function func1
(
arg1 arg1
arg2 arg2
);
Function func2
(
arg3 arg3
);
its pretty repetitive. I'm tryin to parse this file and search for certain functions only and store their args into a list/object (I don't know exactly how) and reuse these infos to write to a file. I started my code like this
def get_wanted_funcs(path,list_func):
f = open(path,'r')
while True:
text = f.readline()
if list_func in text:
## store name of func + args
templ = myfile_h()
# something like templ.stored_objects = stored_objects
with open(os.path.join(generated_dir, "myfile.h"), "w") as f:
f.write(str(templ))
But I don't what is the best way to proceed to store this objects/items. Any suggets or sample codes are welcome. thank you