Patchwork [5,of,8,simple] color: rework conditional 'valideffect'

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 15, 2017, 11:06 a.m.
Message ID <07618a3840fbce3ab108.1487156777@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18506/
State Accepted
Delegated to: Martin von Zweigbergk
Headers show

Comments

Pierre-Yves David - Feb. 15, 2017, 11:06 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1482370203 -3600
#      Thu Dec 22 02:30:03 2016 +0100
# Node ID 07618a3840fbce3ab1084765d94ac8d7a9380ff8
# Parent  bb59bec58bcdf57a3aeb1a9cd4a9b5b004c7c139
# EXP-Topic color
color: rework conditional 'valideffect'

Not very important, but the full conditional is not that hard to follow and
having it unified make the function role a bit clearer in my opinion.

Patch

diff -r bb59bec58bcd -r 07618a3840fb mercurial/color.py
--- a/mercurial/color.py	Thu Dec 22 02:26:50 2016 +0100
+++ b/mercurial/color.py	Thu Dec 22 02:30:03 2016 +0100
@@ -116,10 +116,6 @@  def loadcolortable(ui, extname, colortab
 
 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
+    return ((not _terminfo_params and effect in _effects)
+             or (effect in _terminfo_params
+                 or effect[:-11] in _terminfo_params))