Skip to content

Commit

Permalink
Make Modifier.isChosen() private
Browse files Browse the repository at this point in the history
  • Loading branch information
makortel committed Apr 1, 2019
1 parent 88fc537 commit 0e49537
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Configuration/StandardSequences/python/Eras.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def inspectModifier(self,m,details):

def inspectEra(self,e,details):
print('\nEra:',e)
print(' isChosen:',getattr(self,e).isChosen())
print(' isChosen:',getattr(self,e)._isChosen())
if details: print(' Modifiers:')
nmod=0
for value in getattr(self,e).__dict__['_ModifierChain__chain']:
Expand Down
28 changes: 14 additions & 14 deletions FWCore/ParameterSet/python/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def vpsets_(self):

def isUsingModifier(self,mod):
"""returns True if the Modifier is in used by this Process"""
if mod.isChosen():
if mod._isChosen():
for m in self.__modifiers:
if m._isOrContains(mod):
return True
Expand Down Expand Up @@ -1316,12 +1316,12 @@ def __init__(self, lhs, rhs=None):
self._rhs = rhs
def toModify(self,obj, func=None,**kw):
Modifier._toModifyCheck(obj,func,**kw)
if not self.isChosen():
if not self._isChosen():
return
Modifier._toModify(obj,func,**kw)
def toReplaceWith(self,toObj,fromObj):
Modifier._toReplaceWithCheck(toObj,fromObj)
if not self.isChosen():
if not self._isChosen():
return
Modifier._toReplaceWith(toObj,fromObj)
def makeProcessModifier(self,func):
Expand All @@ -1340,22 +1340,22 @@ class _AndModifier(_BoolModifierBase):
"""A modifier which only applies if multiple Modifiers are chosen"""
def __init__(self, lhs, rhs):
super(_AndModifier,self).__init__(lhs, rhs)
def isChosen(self):
return self._lhs.isChosen() and self._rhs.isChosen()
def _isChosen(self):
return self._lhs._isChosen() and self._rhs._isChosen()

class _InvertModifier(_BoolModifierBase):
"""A modifier which only applies if a Modifier is not chosen"""
def __init__(self, lhs):
super(_InvertModifier,self).__init__(lhs)
def isChosen(self):
return not self._lhs.isChosen()
def _isChosen(self):
return not self._lhs._isChosen()

class _OrModifier(_BoolModifierBase):
"""A modifier which only applies if at least one of multiple Modifiers is chosen"""
def __init__(self, lhs, rhs):
super(_OrModifier,self).__init__(lhs, rhs)
def isChosen(self):
return self._lhs.isChosen() or self._rhs.isChosen()
def _isChosen(self):
return self._lhs._isChosen() or self._rhs._isChosen()


class Modifier(object):
Expand Down Expand Up @@ -1394,7 +1394,7 @@ def toModify(self,obj, func=None,**kw):
mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) )
"""
Modifier._toModifyCheck(obj,func,**kw)
if not self.isChosen():
if not self._isChosen():
return
Modifier._toModify(obj,func,**kw)
@staticmethod
Expand All @@ -1412,7 +1412,7 @@ def toReplaceWith(self,toObj,fromObj):
"""If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj
"""
Modifier._toReplaceWithCheck(toObj,fromObj)
if not self.isChosen():
if not self._isChosen():
return
Modifier._toReplaceWith(toObj,fromObj)
@staticmethod
Expand All @@ -1437,7 +1437,7 @@ def _toReplaceWith(toObj,fromObj):
def _setChosen(self):
"""Should only be called by cms.Process instances"""
self.__chosen = True
def isChosen(self):
def _isChosen(self):
return self.__chosen
def __and__(self, other):
return _AndModifier(self,other)
Expand Down Expand Up @@ -1465,7 +1465,7 @@ def _setChosen(self):
self.__chosen = True
for m in self.__chain:
m._setChosen()
def isChosen(self):
def _isChosen(self):
return self.__chosen
def copyAndExclude(self, toExclude):
"""Creates a new ModifierChain which is a copy of
Expand Down Expand Up @@ -1509,7 +1509,7 @@ def __init__(self, modifier, func):
self.__func = func
self.__seenProcesses = set()
def apply(self,process):
if self.__modifier.isChosen():
if self.__modifier._isChosen():
if process not in self.__seenProcesses:
self.__func(process)
self.__seenProcesses.add(process)
Expand Down

0 comments on commit 0e49537

Please sign in to comment.