• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.strip_and_uniq函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中shinken.util.strip_and_uniq函数的典型用法代码示例。如果您正苦于以下问题:Python strip_and_uniq函数的具体用法?Python strip_and_uniq怎么用?Python strip_and_uniq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: linkify_es_by_s

 def linkify_es_by_s(self, services):
     for es in self:
         # If no host, no hope of having a service
         if not (hasattr(es, 'host_name') and hasattr(es, 'service_description')):
             continue
         es_hname, sdesc = es.host_name, es.service_description
         if '' in (es_hname.strip(), sdesc.strip()):
             continue
         for hname in strip_and_uniq(es_hname.split(',')):
             for sname in strip_and_uniq(sdesc.split(',')):
                 s = services.find_srv_by_name_and_hostname(hname, sname)
                 if s is not None:
                     #print "Linking service", s.get_name(), 'with me', es.get_name()
                     s.escalations.append(es)
开发者ID:David-,项目名称:shinken,代码行数:14,代码来源:escalation.py


示例2: find_several

def find_several(lst, elt, prop, key):
    print 'Find several in', lst, 'for element', elt, 'and property', prop
    value = elt.get(prop, None)
    if value is None:
        return []

    values = value.split(',')
    values = strip_and_uniq(values)
    print 'Our values are', values

    res = []
    # Now try to match what it got
    for dbi in lst:
        print 'Try to look at', dbi, 'for property', key
        v = dbi.get(key, None)
        if v is None:
            continue
        v = v.strip()
        try:
            print 'MAtch with db', v
        except:
            pass
        if v  in values:
            res.append(dbi)
    print "Return find_several::", res
    return res
开发者ID:achamo,项目名称:shinken,代码行数:26,代码来源:local_helper.py


示例3: explode_contact_groups_into_contacts

    def explode_contact_groups_into_contacts(self, contactgroups):
        for i in self:
            if hasattr(i, 'contact_groups'):
                # in tempaltes we need to take care, that contact_groups
                # could still have a leading '+', if we don't remove them now
                # we will not find them in the given contactgroups anymore
                cg = i.contact_groups
                if len(cg) >= 1 and cg[0] == '+':
                    cg = cg[1:]

                cgnames = cg.split(',')
                cgnames = strip_and_uniq(cgnames)
                for cgname in cgnames:
                    cg = contactgroups.find_by_name(cgname)
                    if cg is None:
                        # XXX: Why don't i receive this err when defining contact_groups in a template
                        err = "The contact group '%s' defined on the %s '%s' do not exist" % (cgname, i.__class__.my_type, i.get_name())
                        i.configuration_errors.append(err)
                        continue
                    cnames = contactgroups.get_members_by_name(cgname)
                    # We add contacts into our contacts
                    if cnames != []:
                        if hasattr(i, 'contacts'):
                            i.contacts += ',' + cnames
                        else:
                            i.contacts = cnames
开发者ID:cyrilleJ,项目名称:shinken,代码行数:26,代码来源:item.py


示例4: linkify_es_by_h

 def linkify_es_by_h(self, hosts):
     for es in self:
         # If no host, no hope of having a service
         if (not hasattr(es, 'host_name') or es.host_name.strip() == ''
                 or (hasattr(es, 'service_description') and es.service_description.strip() != '')):
             continue
         # I must be NOT a escalation on for service
         for hname in strip_and_uniq(es.host_name.split(',')):
             h = hosts.find_by_name(hname)
             if h is not None:
                 #print "Linking host", h.get_name(), 'with me', es.get_name()
                 h.escalations.append(es)
开发者ID:G2fx,项目名称:shinken,代码行数:12,代码来源:escalation.py


示例5: linkify_with_notificationways

 def linkify_with_notificationways(self, notificationways):
     for i in self:
         if not hasattr(i, 'notificationways'): continue
         new_notificationways = []
         for nw_name in strip_and_uniq(i.notificationways.split(',')):
             nw = notificationways.find_by_name(nw_name)
             if nw is not None:
                 new_notificationways.append(nw)
             else: #TODO: What?
                 pass
         #Get the list, but first make elements uniq
         i.notificationways = list(set(new_notificationways))
开发者ID:bs-github,项目名称:shinken,代码行数:12,代码来源:contact.py


示例6: linkify_with_resultmodulations

 def linkify_with_resultmodulations(self, resultmodulations):
     for i in self:
         if hasattr(i, 'resultmodulations'):
             resultmodulations_tab = i.resultmodulations.split(',')
             resultmodulations_tab = strip_and_uniq(resultmodulations_tab)
             new_resultmodulations = []
             for rm_name in resultmodulations_tab:
                 rm = resultmodulations.find_by_name(rm_name)
                 if rm is not None:
                     new_resultmodulations.append(rm)
                 else: # TODO WHAT?
                     pass
             i.resultmodulations = new_resultmodulations
开发者ID:wAmpIre,项目名称:shinken,代码行数:13,代码来源:item.py


示例7: linkify_with_escalations

 def linkify_with_escalations(self, escalations):
     for i in self:
         if hasattr(i, 'escalations'):
             #print i.get_name(), 'going to link escalations', i.escalations
             escalations_tab = i.escalations.split(',')
             escalations_tab = strip_and_uniq(escalations_tab)
             new_escalations = []
             for es_name in escalations_tab:
                 es = escalations.find_by_name(es_name)
                 if es is not None:
                     new_escalations.append(es)
                 else: #TODO what?
                     pass
             i.escalations = new_escalations
开发者ID:zoranzaric,项目名称:shinken,代码行数:14,代码来源:item.py


示例8: linkify_with_escalations

 def linkify_with_escalations(self, escalations):
     for i in self:
         if hasattr(i, 'escalations'):
             escalations_tab = i.escalations.split(',')
             escalations_tab = strip_and_uniq(escalations_tab)
             new_escalations = []
             for es_name in [e for e in escalations_tab if e != '']:
                 es = escalations.find_by_name(es_name)
                 if es is not None:
                     new_escalations.append(es)
                 else:  # Escalation not find, not good!
                     err = "the escalation '%s' defined for '%s' is unknown" % (es_name, i.get_name())
                     i.configuration_errors.append(err)
             i.escalations = new_escalations
开发者ID:andrewmcgilvray,项目名称:shinken,代码行数:14,代码来源:item.py


示例9: linkify_command_list_with_commands

 def linkify_command_list_with_commands(self, commands, prop):
     for i in self:
         if hasattr(i, prop):
             coms = getattr(i, prop).split(',')
             coms = strip_and_uniq(coms)
             com_list = []
             for com in coms:
                 if com != '':
                     cmdCall = self.create_commandcall(i, commands, com)
                     # TODO: catch None?
                     com_list.append(cmdCall)
                 else:  # TODO: catch?
                     pass
             setattr(i, prop, com_list)
开发者ID:andrewmcgilvray,项目名称:shinken,代码行数:14,代码来源:item.py


示例10: linkify_with_notificationways

 def linkify_with_notificationways(self, notificationways):
     for i in self:
         if not hasattr(i, 'notificationways'):
             continue
         new_notificationways = []
         for nw_name in strip_and_uniq(i.notificationways.split(',')):
             nw = notificationways.find_by_name(nw_name)
             if nw is not None:
                 new_notificationways.append(nw)
             else:
                 err = "The 'notificationways' of the %s '%s' named '%s' is unknown!" % (i.__class__.my_type, i.get_name(), nw_name)
                 i.configuration_errors.append(err)
         # Get the list, but first make elements uniq
         i.notificationways = list(set(new_notificationways))
开发者ID:andrewmcgilvray,项目名称:shinken,代码行数:14,代码来源:contact.py


示例11: linkify_with_business_impact_modulations

 def linkify_with_business_impact_modulations(self, business_impact_modulations):
     for i in self:
         if hasattr(i, 'business_impact_modulations'):
             business_impact_modulations_tab = i.business_impact_modulations.split(',')
             business_impact_modulations_tab = strip_and_uniq(business_impact_modulations_tab)
             new_business_impact_modulations = []
             for rm_name in business_impact_modulations_tab:
                 rm = business_impact_modulations.find_by_name(rm_name)
                 if rm is not None:
                     new_business_impact_modulations.append(rm)
                 else:
                     err = "the business impact modulation '%s' defined on the %s '%s' do not exist" % (rm_name, i.__class__.my_type, i.get_name())
                     i.configuration_errors.append(err)
                     continue
             i.business_impact_modulations = new_business_impact_modulations
开发者ID:andrewmcgilvray,项目名称:shinken,代码行数:15,代码来源:item.py


示例12: linkify_with_resultmodulations

 def linkify_with_resultmodulations(self, resultmodulations):
     for i in self:
         if hasattr(i, 'resultmodulations'):
             resultmodulations_tab = i.resultmodulations.split(',')
             resultmodulations_tab = strip_and_uniq(resultmodulations_tab)
             new_resultmodulations = []
             for rm_name in resultmodulations_tab:
                 rm = resultmodulations.find_by_name(rm_name)
                 if rm is not None:
                     new_resultmodulations.append(rm)
                 else:
                     err = "the result modulation '%s' defined on the %s '%s' do not exist" % (rm_name, i.__class__.my_type, i.get_name())
                     i.configuration_warnings.append(err)
                     continue
             i.resultmodulations = new_resultmodulations
开发者ID:andrewmcgilvray,项目名称:shinken,代码行数:15,代码来源:item.py


示例13: hg_name_get_groupnames

def hg_name_get_groupnames(all_res, hosts, hostgroups, res=None):
    if res is None:
        res = {}

    for tok in all_res:
        if isinstance(tok, tuple):
            hg_name_get_groupnames(tok[0], hosts, hostgroups, res)
            hg_name_get_groupnames(tok[1], hosts, hostgroups, res)
            continue
        if isinstance(tok, list):
            hg_name_get_groupnames(tok, hosts, hostgroups, res)
            continue
        
        save_tok = tok
        if tok in HostGroup_Name_Parse_Ctx.specials_hostgroup_name_chars + ( '-', ):
            if tok != '*':
                continue
            tok = HostGroup_Name_Parse_Ctx.catch_all_name
        
        if tok in res: # we already got it, good.
            continue
        
        if save_tok == '*':
            elts = get_all_host_names_set(hosts)
        else:
            # we got a group name :
            members = hostgroups.get_members_by_name(tok)
            # TODO: check why:
            # sometimes we get a list, sometimes we get a string of hosts name which are ',' separated..
            if isinstance(members, list):
                elts = members
            else:
                elts = members.split(',')
            elts = strip_and_uniq(elts)
            
            # the "host_name" members of a hostgroup can also be '*' :
            if '*' in elts:
                tok = HostGroup_Name_Parse_Ctx.catch_all_name 
                if tok in res:
                    elts = res[tok]
                else: 
                    elts = get_all_host_names_set(hosts)    
                # the original tok must still be set:
                res[save_tok] = elts 

        res[tok] = set(elts)

    return res
开发者ID:wAmpIre,项目名称:shinken,代码行数:48,代码来源:item.py


示例14: find_object

    def find_object(self, pattern):
        obj = None
        error = None
        pattern = pattern.strip()

        if pattern == "*":
            obj = [
                h.host_name
                for h in self.all_elements.items.values()
                if getattr(h, "host_name", "") != "" and not h.is_tpl()
            ]
            return obj, error

        # Ok a more classic way

        # print "GRPS", self.grps

        if self.ctx == "hostgroups":
            # Ok try to find this hostgroup
            hg = self.grps.find_by_name(pattern)
            # Maybe it's an known one?
            if not hg:
                error = "Error : cannot find the %s of the expression '%s'" % (self.ctx, pattern)
                return hg, error
            # Ok the group is found, get the elements!
            elts = hg.get_hosts().split(",")
            elts = strip_and_uniq(elts)

            # Maybe the hostgroup memebrs is '*', if so expand with all hosts
            if "*" in elts:
                elts.extend(
                    [
                        h.host_name
                        for h in self.all_elements.items.values()
                        if getattr(h, "host_name", "") != "" and not h.is_tpl()
                    ]
                )
                # And remove this strange hostname too :)
                elts.remove("*")
            return elts, error

        else:  # templates
            obj = self.grps.find_hosts_that_use_template(pattern)

        return obj, error
开发者ID:zllak,项目名称:shinken,代码行数:45,代码来源:complexexpression.py


示例15: linkify_with_contacts

 def linkify_with_contacts(self, contacts):
     for i in self:
         if hasattr(i, 'contacts'):
             contacts_tab = i.contacts.split(',')
             contacts_tab = strip_and_uniq(contacts_tab)
             new_contacts = []
             for c_name in contacts_tab:
                 if c_name != '':
                     c = contacts.find_by_name(c_name)
                     if c is not None:
                         new_contacts.append(c)
                     # Else: Add in the errors tab.
                     # will be raised at is_correct
                     else:
                         err = "the contact '%s' defined for '%s' is unknown" % (c_name, i.get_name())
                         i.configuration_errors.append(err)
             # Get the list, but first make elements uniq
             i.contacts = list(set(new_contacts))
开发者ID:andrewmcgilvray,项目名称:shinken,代码行数:18,代码来源:item.py


示例16: explode_contact_groups_into_contacts

 def explode_contact_groups_into_contacts(self, contactgroups):
     for i in self:
         if hasattr(i, 'contact_groups'):
             cgnames = i.contact_groups.split(',')
             cgnames = strip_and_uniq(cgnames)
             for cgname in cgnames:
                 cg = contactgroups.find_by_name(cgname)
                 if cg is None:
                     err = "The contact group '%s' defined on the %s '%s' do not exist" % (cgname, i.__class__.my_type, i.get_name())
                     i.configuration_errors.append(err)
                     continue
                 cnames = contactgroups.get_members_by_name(cgname)
                 # We add contacts into our contacts
                 if cnames != []:
                     if hasattr(i, 'contacts'):
                         i.contacts += ',' + cnames
                     else:
                         i.contacts = cnames
开发者ID:jackode,项目名称:shinken,代码行数:18,代码来源:item.py


示例17: linkify_s_by_plug

    def linkify_s_by_plug(self):
        for s in self:
            new_modules = []
            mods = s.modules.split(",")
            mods = strip_and_uniq(mods)
            for plug_name in mods:
                plug_name = plug_name.strip()

                # don't read void names
                if plug_name == "":
                    continue

                # We are the modules, we search them :)
                plug = self.find_by_name(plug_name)
                if plug is not None:
                    new_modules.append(plug)
                else:
                    logger.error("[module] unknown %s module from %s" % (plug_name, s.get_name()))
                    s.configuration_errors.append(err)
            s.modules = new_modules
开发者ID:amosshapira,项目名称:shinken,代码行数:20,代码来源:module.py


示例18: linkify_s_by_plug

    def linkify_s_by_plug(self):
        for s in self:
            new_modules = []
            mods = s.modules.split(',')
            mods = strip_and_uniq(mods)
            for plug_name in mods:
                plug_name = plug_name.strip()

                # don't read void names
                if plug_name == '':
                    continue

                # We are the modules, we search them :)
                plug = self.find_by_name(plug_name)
                if plug is not None:
                    new_modules.append(plug)
                else:
                    err = "Error : the module %s is unknown for %s" % (plug_name, s.get_name())
                    print "err", err
                    s.configuration_errors.append(err)
            s.modules = new_modules
开发者ID:bs-github,项目名称:shinken,代码行数:21,代码来源:module.py


示例19: linkify_command_list_with_commands

 def linkify_command_list_with_commands(self, commands, prop):
     for i in self:
         if hasattr(i, prop):
             coms = getattr(i, prop).split(',')
             coms = strip_and_uniq(coms)
             com_list = []
             for com in coms:
                 if com != '':
                     if hasattr(i, 'poller_tag'):
                         cmdCall = CommandCall(commands, com,
                                               poller_tag=i.poller_tag)
                     elif hasattr(i, 'reactionner_tag'):
                         cmdCall = CommandCall(commands, com,
                                               reactionner_tag=i.reactionner_tag)
                     else:
                         cmdCall = CommandCall(commands, com)
                     # TODO: catch None?
                     com_list.append(cmdCall)
                 else:  # TODO: catch?
                     pass
             setattr(i, prop, com_list)
开发者ID:jackode,项目名称:shinken,代码行数:21,代码来源:item.py


示例20: find_several

def find_several(lst, elt, prop, key):
    print "Find several in", lst, "for element", elt, "and property", prop
    value = elt.get(prop, None)
    if value is None:
        return []

    values = value.split(",")
    values = strip_and_uniq(values)
    print "Our values are", values

    res = []
    # Now try to match what it got
    for dbi in lst:
        print "Try to look at", dbi, "for property", key
        v = dbi.get(key, None)
        if v is None:
            continue
        v = v.strip()
        print "MAtch with db", v
        if v in values:
            res.append(dbi)
    print "Return find_several::", res
    return res
开发者ID:radu-gheorghe,项目名称:shinken,代码行数:23,代码来源:local_helper.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.unique_value函数代码示例发布时间:2022-05-27
下一篇:
Python util.safe_print函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap