I have the following file "template.txt"
function FA()
{
if(){...}
message=[msg]
message=[msg]
}
function FB()
{
if(){...}
message=[msg]
message=[msg]
}
function FC()
{
if(){...}
message=[msg]
message=[msg]
}
I would like to do this:
./script.py --function FB --message TEST
and get this result:
function FA()
{
if(){...}
message=[msg]
message=[msg]
}
function FB()
{
if(){...}
message=TEST
message=TEST
}
function FC()
{
if(){...}
message=[msg]
message=[msg]
}
I can now using getopt retrieve all the options and arguments properly but I can't figure out how to achieve the above behavior elegantly. Any ideas? Are there any libraries that can help me with this?
I was able to achieve this behavior using AWK but now I need it in python. In AWK you can go to a specific line (e.g. function FC()) and start replacing from there until you hit another function. I can't seem to figure this out in python.
I am also wondering if there's a better approach to this problem.