Skip to content

Conversation

@GhostOps77
Copy link

@GhostOps77 GhostOps77 commented Oct 16, 2025

The old PR (#498) was not rebased properly. So, made a new one.


The earlier code used str.replace method to replace each placeholder in the labels with their values. This can be done by str.format and str.format_map methods. This will make the job easier to insert values.

So, instead of doing something like this

label_values = {
    "icon": icon,
    "data": data
}

for key, value in label_values:
    formatted_text = part.replace('{' + key + '}', value) 

This can be done like this

formatted_text = part.format(icon=icon, data=data)

or like this

formatted_text = part.format_map(label_values)

This is how it was done in this PR.

…in labels

- Replaced all the instances of str.replace to substitute appropriate data in labels with str.format and str.format_map methods
@GhostOps77 GhostOps77 marked this pull request as ready for review October 16, 2025 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant