color: move 'valideffect' function into the core module
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Thu, 22 Dec 2016 02:26:50 +0100
changeset 30969 ddc80d1777a6
parent 30968 0d2a58a04080
child 30970 683606a829e8
color: move 'valideffect' function into the core module
hgext/color.py
mercurial/color.py
--- a/hgext/color.py	Thu Dec 22 02:23:23 2016 +0100
+++ b/hgext/color.py	Thu Dec 22 02:26:50 2016 +0100
@@ -332,16 +332,6 @@
         stop = _effect_str('none')
     return ''.join([start, text, stop])
 
-def valideffect(effect):
-    'Determine if the effect is valid or not.'
-    good = False
-    if not color._terminfo_params and effect in color._effects:
-        good = True
-    elif (effect in color._terminfo_params
-          or effect[:-11] in color._terminfo_params):
-        good = True
-    return good
-
 def configstyles(ui):
     for status, cfgeffects in ui.configitems('color'):
         if '.' not in status or status.startswith(('color.', 'terminfo.')):
@@ -350,7 +340,7 @@
         if cfgeffects:
             good = []
             for e in cfgeffects:
-                if valideffect(e):
+                if color.valideffect(e):
                     good.append(e)
                 else:
                     ui.warn(_("ignoring unknown color/effect %r "
@@ -412,7 +402,7 @@
             s = color._styles.get(l, '')
             if s:
                 effects.append(s)
-            elif valideffect(l):
+            elif color.valideffect(l):
                 effects.append(l)
         effects = ' '.join(effects)
         if effects:
--- a/mercurial/color.py	Thu Dec 22 02:23:23 2016 +0100
+++ b/mercurial/color.py	Thu Dec 22 02:26:50 2016 +0100
@@ -113,3 +113,13 @@
 
 def loadcolortable(ui, extname, colortable):
     _styles.update(colortable)
+
+def valideffect(effect):
+    'Determine if the effect is valid or not.'
+    good = False
+    if not _terminfo_params and effect in _effects:
+        good = True
+    elif (effect in _terminfo_params
+          or effect[:-11] in _terminfo_params):
+        good = True
+    return good