Despite it would be easy to solve the problem using a combination of python code and regular expressions, it wouldn't be so easy to store/retrieve that information to/from the configuration file.
After some investingation, it's been decided to use one line sed scripts since they provide the flexibility needed to do fix the problem (s/ubuntu/${distro}/g;s/$/~rev${revno}/) and at the same time is really easy to store/retrieve them as a string to/from the configuration file.
Despite it would be easy to solve the problem using a combination of python code and regular expressions, it wouldn't be so easy to store/retrieve that information to/from the configuration file.
After some investingation, it's been decided to use one line sed scripts since they provide the flexibility needed to do fix the problem (s/ubuntu/ ${distro} /g;s/$/ ~rev${revno} /) and at the same time is really easy to store/retrieve them as a string to/from the configuration file.