def normalize(self, metric, prefix=None, fix_case=False):
        """
        Turn a metric into a well-formed metric name
        prefix.b.c
        :param metric The metric name to normalize
        :param prefix A prefix to to add to the normalized name, default None
        :param fix_case A boolean, indicating whether to make sure that the metric name returned is in "snake_case"
        """
        if isinstance(metric, text_type):
            metric = unicodedata.normalize('NFKD', metric).encode('ascii', 'ignore')

        if fix_case:
            name = self.convert_to_underscore_separated(metric)
            if prefix is not None:
                prefix = self.convert_to_underscore_separated(prefix)
        else:
            name = re.sub(br"[,\+\*\-/()\[\]{}\s]", b"_", metric)
        # Eliminate multiple _
        name = re.sub(br"__+", b"_", name)
        # Don't start/end with _
        name = re.sub(br"^_", b"", name)
        name = re.sub(br"_$", b"", name)
        # Drop ._ and _.
        name = re.sub(br"\._", b".", name)
        name = re.sub(br"_\.", b".", name)

        if prefix is not None:
            return ensure_bytes(prefix) + b"." + name
        else:
            return name
def normalize ( self , metric , prefix = None , fix_case = False ) : if isinstance ( metric , text_type ) : metric = unicodedata . normalize ( 'NFKD' , metric ) . encode ( 'ascii' , 'ignore' ) if fix_case : name = self . convert_to_underscore_separated ( metric ) if prefix is not None : prefix = self . convert_to_underscore_separated ( prefix ) else : name = re . sub ( br"[,\+\*\-/()\[\]{}\s]" , b"_" , metric ) name = re . sub ( br"__+" , b"_" , name ) name = re . sub ( br"^_" , b"" , name ) name = re . sub ( br"_$" , b"" , name ) name = re . sub ( br"\._" , b"." , name ) name = re . sub ( br"_\." , b"." , name ) if prefix is not None : return ensure_bytes ( prefix ) + b"." + name else : return name
Turn a metric into a well-formed metric name
        prefix.b.c
        :param metric The metric name to normalize
        :param prefix A prefix to to add to the normalized name, default None
        :param fix_case A boolean, indicating whether to make sure that the metric name returned is in "snake_case"