Commit 66fa0f98 authored by Seblu's avatar Seblu
Browse files

better tagdisplay type patter matching. Better match is selected

parent 4269ef4c
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -58,14 +58,23 @@ class TagDisplay(object):
        '''Transform a tagvalue respecting custom display settings'''
        tagname = unicode(tagname)
        tagvalue = unicode(tagvalue)
        # check general options
        if bool(self.option.get("quotespace", False)):
            if re.search("\s", tagvalue) is not None:
                tagvalue = "'%s'"%re.sub("'", "\'", tagvalue)
        # build list of matching pattern with tagname
        l = [ x for x in self.tagtype if fnmatch.fnmatch(tagname, x) ]
        if len(l) > 0 and self.tagtype[l[0]] in self.types:
            return getattr(self, "type_%s"%self.tagtype[l[0]])(tagvalue)
        if len(l) > 0:
            # select longest match
            tm = max(l)
            if self.tagtype[tm] in self.types:
                return getattr(self, "type_%s"%self.tagtype[tm])(tagvalue)
        return tagvalue

    def type_string(self, value):
        '''DO Nothing'''
        return value()

    def type_lower(self, value):
        '''Lower case type'''
        return value.lower()