本文整理汇总了Python中karesansui.lib.dict_op.DictOp.insert_order方法的典型用法代码示例。如果您正苦于以下问题:Python DictOp.insert_order方法的具体用法?Python DictOp.insert_order怎么用?Python DictOp.insert_order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karesansui.lib.dict_op.DictOp
的用法示例。
在下文中一共展示了DictOp.insert_order方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: collectdParser
# 需要导入模块: from karesansui.lib.dict_op import DictOp [as 别名]
# 或者: from karesansui.lib.dict_op.DictOp import insert_order [as 别名]
"""
parser = collectdParser()
# 読み込み
dop = DictOp()
dop.addconf("dum",parser.read_conf())
##########################################################
# Uniオプション (一箇所しか設定できないオプション) の追加
##########################################################
# 'Foo foo' を追加(設定値リスト形式モードよる addメソッド)
dop.add("dum",["Foo"],["foo",[["comment foo1","comment foo2"],"comment foo3"]])
#print dop.cdp_get("dum",["Foo"])
#print dop.cdp_get_pre_comment("dum",["Foo"])
#print dop.cdp_get_post_comment("dum",["Foo"])
dop.insert_order("dum",["Foo"])
# 'Bar bar' を追加(設定値文字列形式モードによる cdp_setメソッド)
dop.cdp_set("dum",["Bar"],"bar")
dop.cdp_set_pre_comment("dum",["Bar"],["","comment bar1","comment bar2"])
dop.cdp_set_post_comment("dum",["Bar"],"comment bar3")
dop.insert_order("dum",["Bar"])
##########################################################
# Multiオプション (複数設定できるオプション) の追加
##########################################################
# 'LoadPlugin target_hoge' を追加
dop.cdp_set("dum",["LoadPlugin","target_hoge"],"target_hoge",is_opt_multi=True)
dop.cdp_set_pre_comment("dum",["LoadPlugin","target_hoge"],["","Dis is target_hoge"])
##########################################################
示例2: staticrouteParser
# 需要导入模块: from karesansui.lib.dict_op import DictOp [as 别名]
# 或者: from karesansui.lib.dict_op.DictOp import insert_order [as 别名]
return retval
"""
"""
if __name__ == '__main__':
"""Testing
"""
parser = staticrouteParser()
preprint_r(parser.do_status())
parser.do_add("eth0","5.6.7.0","172.16.0.1")
parser.do_del("eth0","5.6.7.0")
preprint_r(parser.do_status())
conf_arr = parser.read_conf()
preprint_r(conf_arr)
dop = DictOp()
dop.addconf("parser",conf_arr)
dop.add("parser",["eth1","2.3.4.5/32"],"172.16.0.10")
dop.add("parser",["eth1","2.3.4.6/32"],"172.16.0.10")
dop.add("parser",["eth1","2.3.4.7/32"],"172.16.0.10")
#dop.insert_order("parser",["eth1","2.3.4.5/32"],0,is_parent_parser=True)
#dop.insert_order("parser",["eth1","2.3.4.6/32"],0,is_parent_parser=True)
dop.insert_order("parser",["eth1","2.3.4.7/32"],1,is_parent_parser=True)
#dop.delete("parser",["eth1","2.3.4.5/32"])
#dop.delete("parser",["eth1","2.3.4.6/32"])
conf_arr = dop.getconf("parser")
preprint_r(conf_arr)
parser.write_conf(conf_arr,dryrun=True)
示例3:
# 需要导入模块: from karesansui.lib.dict_op import DictOp [as 别名]
# 或者: from karesansui.lib.dict_op.DictOp import insert_order [as 别名]
# Option2 false
# Option1 true
# </Plugin>
dop.cdp_set("dum",[new_plugin_name,"Plugin","foobar","Option1"],"true",multiple_file=True)
dop.cdp_set("dum",[new_plugin_name,"Plugin","foobar","Option2"],"false",multiple_file=True)
dop.cdp_set_pre_comment("dum",[new_plugin_name,"Plugin","foobar","Option2"],"pre comment",multiple_file=True)
dop.cdp_set_post_comment("dum",[new_plugin_name,"Plugin","foobar","Option2"],"post comment",multiple_file=True)
dop.cdp_set("dum",[new_plugin_name,"Plugin","foobar","View","hoge","SubOpt1"],"gege",multiple_file=True)
dop.cdp_set_post_comment("dum",[new_plugin_name,"Plugin","foobar","View","hoge","SubOpt1"],"post",multiple_file=True)
print dop.get("dum",["filter","@ORDERS"],multiple_file=True)
# 複数ファイルを読み込むパーサーの場合は、is_parent_parser=Trueにすること
# '<Plugin foobar>' を 先頭にする
key = [new_plugin_name,"Plugin","foobar"]
dop.insert_order("dum",key,0,is_parent_parser=True)
# 'LoadPlugin target_hoge' を 先頭にする => '<Plugin foobar>' は2番目になる
key = [new_plugin_name,"LoadPlugin","target_hoge"]
dop.insert_order("dum",key,0,is_parent_parser=True)
# 'Foo foo' を 先頭にする => 'LoadPlugin target_hoge' は2番目になる
key = [new_plugin_name,"Foo"]
dop.insert_order("dum",key,0,is_parent_parser=True)
# work completely
#dop.cdp_comment("dum",["python","Plugin","python","Import"],multiple_file=True)
#dop.cdp_comment("dum",["python","Plugin","python","Module","notification"],multiple_file=True)
#dop.cdp_comment("dum",["python","Plugin","python","Module","notification","CountupDBPath"],multiple_file=True)
#dop.cdp_set("dum",["python","Plugin","python","Module","notification","@ORDERS"],[['Environ'],['CountupDBPath']],multiple_file=True,is_opt_multi=True)
# work completely, too.