本文整理汇总了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)
示例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' の後に変更する