Skip to content
Snippets Groups Projects
Commit 66fa0f98 authored by Seblu's avatar Seblu
Browse files

better tagdisplay type patter matching. Better match is selected

parent 4269ef4c
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment