(replace with underscore)
While here, change the sequence of replaces to a single regex, as it
becomes too long.
Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit
425c5358fed9376939cff8a922c3ce1186d6b9e2)
def promethize(path):
''' replace illegal metric name characters '''
- result = path.replace('.', '_').replace(
- '+', '_plus').replace('::', '_').replace(' ', '_')
+ result = re.sub(r'[./\s]|::', '_', path).replace('+', '_plus')
# Hyphens usually turn into underscores, unless they are
# trailing