I have an log-file with some written f-strings. Now I want to get the parameters again and save them in a dictionary.
e.g. I have the following log:
The following data is received: Name: Kreijeck, age=35, country=Germany
from this method:
def create_fstring():
name = "Kreijeck"
age = "35"
country = "Germany"
print(f"The following data is received: Name: {name}, age={age}, country={country}")
Now I want to create a Method that can extract the parameters again:
def get_key_value_pairs(f_string, log_string) -> dict:
### PSEUDOCODE ###
d = f_string.extract_parametes(log_string)
return d
where d shall be:
d = {
'name': "Kreijeck",
'age': 35,
'country': 'Germany',
}
when the input is the correct f_string
f_string = "The following data is received: Name: {name}, age={age}, country={country}"