当前位置: 首页>>代码示例>>Python>>正文


Python Utils.dictMatch方法代码示例

本文整理汇总了Python中DIRAC.ResourceStatusSystem.Utilities.Utils.dictMatch方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.dictMatch方法的具体用法?Python Utils.dictMatch怎么用?Python Utils.dictMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.ResourceStatusSystem.Utilities.Utils的用法示例。


在下文中一共展示了Utils.dictMatch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __getPolTypes

# 需要导入模块: from DIRAC.ResourceStatusSystem.Utilities import Utils [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Utilities.Utils import dictMatch [as 别名]
  def __getPolTypes(self, granularity, status=None, formerStatus=None, newStatus=None,
                    siteType=None, serviceType=None, resourceType=None):
    """Get Policy Types from config that match the given keyword
    arguments"""

    # This dict is constructed to be used with function dictMatch that
    # helps selecting policies. **kwargs are not used due to the fact
    # that it's too dangerous here.
    argsdict = {'Granularity': granularity,
                'Status': status,
                'FormerStatus': formerStatus,
                'NewStatus': newStatus,
                'SiteType': siteType,
                'ServiceType': serviceType,
                'ResourceType': resourceType}

    pTconfig = getTypedDictRootedAt("PolicyTypes")

    pTypes = []

    for pt in pTconfig:
      if Utils.dictMatch(argsdict, pTconfig[pt]):
        pTypes.append(pt)

    for pt_name in pTypes:
      if 'Alarm_PolType' in pt_name:
        pTypes.remove(pt_name)
        pTypes.append('Alarm_PolType')

    return pTypes
开发者ID:NathalieRauschmayr,项目名称:DIRAC,代码行数:32,代码来源:InfoGetter.py

示例2: __getPanelsInfo

# 需要导入模块: from DIRAC.ResourceStatusSystem.Utilities import Utils [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Utilities.Utils import dictMatch [as 别名]
  def __getPanelsInfo( self, granularity, statusType = None, status = None,
                       formerStatus = None, siteType = None, serviceType = None,
                       resourceType = None, panel_name = None, useNewRes = False ):

    info = []

    # First, select only policies we want.
    argsdict = {'Granularity'  : granularity,
                'StatusType'   : statusType,
                'Status'       : status,
                'FormerStatus' : formerStatus,
                'SiteType'     : siteType,
                'ServiceType'  : serviceType,
                'ResourceType' : resourceType}


    all_policies = getTypedDictRootedAtOperations("Policies")
    selected_policies = []
    for p in all_policies:
      if Utils.dictMatch(argsdict, all_policies[p]):
        selected_policies.append(p)

    for p in selected_policies:                   # For selected policies
      if panel_name in self.C_Policies[p].keys(): # For selected panel_name (arguments)

        toAppend = copy.deepcopy(self.C_Policies[p][panel_name]) # type(toAppend) = list

        # Put CommandIn and args to correct values according to useNewRes
        if useNewRes:
          for panel in toAppend:
            for info_type in panel.keys():

              if type(panel[info_type]) == dict:
                try:
                  panel[info_type]['CommandIn'] = panel[info_type]['CommandInNewRes']
                  del panel[info_type]['CommandInNewRes']
                except KeyError:
                  pass
                try:
                  panel[info_type]['args'] = panel[info_type]['argsNewRes']
                  del panel[info_type]['argsNewRes']
                except KeyError:
                  pass
        else:
          for panel in toAppend:
            for info_type in panel.keys():
              try:
                del panel[info_type]['CommandInNewRes']
              except KeyError:
                pass
              try:
                del panel[info_type]['argsNewRes']
              except KeyError:
                pass

        info.append({p:toAppend})

    return info
开发者ID:bmb,项目名称:DIRAC,代码行数:60,代码来源:InfoGetter.py

示例3: __getPolToEval

# 需要导入模块: from DIRAC.ResourceStatusSystem.Utilities import Utils [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Utilities.Utils import dictMatch [as 别名]
  def __getPolToEval(self, granularity, status=None, formerStatus=None, siteType=None,
                     serviceType=None, resourceType=None, useNewRes=False):

    # This dict is constructed to be used with function dictMatch that
    # helps selecting policies. **kwargs are not used due to the fact
    # that it's too dangerous here.
    argsdict = {'Granularity': granularity,
                'Status': status,
                'FormerStatus': formerStatus,
                'SiteType': siteType,
                'ServiceType': serviceType,
                'ResourceType': resourceType}

    pConfig = getTypedDictRootedAt("Policies")
    pol_to_eval = []

    for p in pConfig:
      if Utils.dictMatch(argsdict, pConfig[p]):
        pol_to_eval.append(p)

    polToEval_Args = []

    for p in pol_to_eval:
      try:
        moduleName = self.C_Policies[p]['module']
      except KeyError:
        moduleName = None
      try:
        ConfirmationPolicy = self.C_Policies[p]['ConfirmationPolicy']
      except KeyError:
        ConfirmationPolicy = None

      if useNewRes:
        try:
          commandIn = self.C_Policies[p]['commandInNewRes']
        except KeyError:
          commandIn = self.C_Policies[p]['commandIn']
        try:
          args = self.C_Policies[p]['argsNewRes']
        except KeyError:
          args = self.C_Policies[p]['args']
      else:
        commandIn = self.C_Policies[p]['commandIn']
        args = self.C_Policies[p]['args']

      polToEval_Args.append({'Name' : p, 'Module' : moduleName, 'args' : args,
                             'ConfirmationPolicy' : ConfirmationPolicy,
                             'commandIn' : commandIn})

    return polToEval_Args
开发者ID:NathalieRauschmayr,项目名称:DIRAC,代码行数:52,代码来源:InfoGetter.py

示例4: __getPolTypes

# 需要导入模块: from DIRAC.ResourceStatusSystem.Utilities import Utils [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Utilities.Utils import dictMatch [as 别名]
  def __getPolTypes( self, granularity, statusType=None, status=None,
                     formerStatus=None, newStatus=None, siteType=None,
                     serviceType=None, resourceType=None ):
    """Get Policy Types from config that match the given keyword
    arguments. Always returns a generator object, possibly empty."""

    # This dict is constructed to be used with function dictMatch that
    # helps selecting policies. **kwargs are not used due to the fact
    # that it's too dangerous here.
    argsdict = {'Granularity'  : granularity,
                'StatusType'   : statusType,
                'Status'       : status,
                'FormerStatus' : formerStatus,
                'NewStatus'    : newStatus,
                'SiteType'     : siteType,
                'ServiceType'  : serviceType,
                'ResourceType' : resourceType }

    pTconfig = RssConfiguration.getValidPolicyTypes()
    return (pt for pt in pTconfig if Utils.dictMatch(argsdict, pTconfig[pt]))
开发者ID:bmb,项目名称:DIRAC,代码行数:22,代码来源:InfoGetter.py

示例5: _getUsersToNotify

# 需要导入模块: from DIRAC.ResourceStatusSystem.Utilities import Utils [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Utilities.Utils import dictMatch [as 别名]
 def _getUsersToNotify(self):
   groups = CS.getTypedDictRootedAtOperations("AssigneeGroups/" + CS.getSetup()).values()
   concerned_groups = [g for g in groups if Utils.dictMatch(self.kw["Params"], g)]
   return [{'Users':g['Users'],
            'Notifications':g['Notifications']} for g in concerned_groups]
开发者ID:bmb,项目名称:DIRAC,代码行数:7,代码来源:AlarmAction.py


注:本文中的DIRAC.ResourceStatusSystem.Utilities.Utils.dictMatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。