changeset 20992:05086b56b564

color: extract method for determining a valid effect This patch is just setup work so that we can reduce code duplication and have one place to define a valid effect.
author Sean Farley <sean.michael.farley@gmail.com>
date Mon, 07 Apr 2014 15:33:46 -0500
parents a05d694599f9
children a8db48e997b5
files hgext/color.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/color.py	Mon Apr 07 23:17:51 2014 +0200
+++ b/hgext/color.py	Mon Apr 07 15:33:46 2014 -0500
@@ -311,6 +311,15 @@
     for name, ext in extensions.extensions():
         _styles.update(getattr(ext, '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
+
 def configstyles(ui):
     for status, cfgeffects in ui.configitems('color'):
         if '.' not in status or status.startswith('color.'):
@@ -319,9 +328,7 @@
         if cfgeffects:
             good = []
             for e in cfgeffects:
-                if not _terminfo_params and e in _effects:
-                    good.append(e)
-                elif e in _terminfo_params or e[:-11] in _terminfo_params:
+                if valideffect(e):
                     good.append(e)
                 else:
                     ui.warn(_("ignoring unknown color/effect %r "