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


Python DictOp.cdp_get方法代码示例

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


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

示例1: hostsParser

# 需要导入模块: from karesansui.lib.dict_op import DictOp [as 别名]
# 或者: from karesansui.lib.dict_op.DictOp import cdp_get [as 别名]
        try:
            self.dop.addconf("parser",{})
            self.dop.set("parser",[PARSER_HOSTS_CONF],conf_arr)
            #self.dop.preprint_r("parser")
            arr = self.dop.getconf("parser")
            self.parser.write_conf(arr,dryrun=dryrun)
        except:
            pass

        return retval

"""
"""
if __name__ == '__main__':
    """Testing
    """
    parser = hostsParser()
    dop = DictOp()
    dop.addconf("dum",parser.read_conf())
    dop.add("dum",['key'],['value',[['comment foo','comment bar'],'comment hoge']])
    print dop.cdp_get("dum",['key'])
    print dop.cdp_get_pre_comment("dum",['key'])
    print dop.cdp_get_post_comment("dum",['key'])
    print dop.cdp_set("dum",['key'],"value2")
    print dop.cdp_set_pre_comment("dum",['key'],["comment foo2","comment bar2","a"])
    print dop.cdp_set_post_comment("dum",['key'],"comment fuga")
    conf = dop.getconf("dum")
    preprint_r(conf)
    parser.write_conf(conf,dryrun=True)
开发者ID:AdUser,项目名称:karesansui,代码行数:31,代码来源:hosts.py

示例2:

# 需要导入模块: from karesansui.lib.dict_op import DictOp [as 别名]
# 或者: from karesansui.lib.dict_op.DictOp import cdp_get [as 别名]
    #        <View "hoge">
    #                SubOpt1         gege # post
    #        </View>
    #        Option2         false
    #        Option1         true
    # </Plugin>
    dop.cdp_set("dum",["Plugin","foobar","Option1"],"true")
    dop.cdp_set("dum",["Plugin","foobar","Option2"],"false")
    dop.cdp_set("dum",["Plugin","foobar","View","hoge","SubOpt1"],"gege")
    dop.cdp_set_pre_comment("dum",["Plugin","foobar","View","hoge","SubOpt1"],["","pre comment"])
    dop.cdp_set_post_comment("dum",["Plugin","foobar","View","hoge","SubOpt1"],"post")

    # 'LoadPlugin target_replace' の値を取得
    key = ["LoadPlugin","target_hoge"]
    dop.insert_order("dum",key)
    value = dop.cdp_get("dum",key)
    preprint_r(value)

    # 'LoadPlugin target_replace' の設定順を取得
    key = ["LoadPlugin","target_hoge"]
    num = dop.order("dum",key)
    print num

    # '<Plugin foobar>' を 'LoadPlugin target_hoge' の前にする
    key = ["Plugin","foobar"]
    dop.insert_order("dum",key,num)

    # '<Plugin foobar>' を 'LoadPlugin target_hoge' の後に変更する
    dop.change_order("dum",key,num+1)

    # 'Foo' を 'Bar' の後に変更する
开发者ID:AdUser,项目名称:karesansui,代码行数:33,代码来源:collectd.py


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