From 66fa0f98dfec908e7b3ba8c28800dc601c7efbd8 Mon Sep 17 00:00:00 2001
From: Seblu <sebastien.luttringer@smartjog.com>
Date: Thu, 10 Feb 2011 13:02:16 +0100
Subject: [PATCH] better tagdisplay type patter matching. Better match is
 selected

---
 cccli/tagdisplay.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/cccli/tagdisplay.py b/cccli/tagdisplay.py
index 3716268..b1f6da4 100644
--- a/cccli/tagdisplay.py
+++ b/cccli/tagdisplay.py
@@ -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()
-- 
GitLab