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


Python dict_op.DictOp类代码示例

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


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

示例1: __init__

class nullParser:

    _comment     = ""

    _module      = "null_parser"

    def __init__(self,paths=[]):
        self.dop = DictOp()
        self.dop.addconf(self._module,{})
        self.set_source_file(paths)

    def set_comment(self, comment=""):
        self._comment = comment

    def set_source_file(self,paths=[]):
        if type(paths) == str:
            paths = [paths]
        self.paths = paths
        return True

    def get_source_file(self):
        return self.paths

    def source_file(self):
        return self.get_source_file()

    def read_conf(self):
        return self.dop.getconf(self._module)

    def write_conf(self,conf_arr={},dryrun=False):
        retval = True
        return retval
开发者ID:AdUser,项目名称:karesansui,代码行数:32,代码来源:null_parser.py

示例2: convert_old_style

    def convert_old_style(self, conf_arr):

        dop = DictOp()
        dop.addconf("__",{})
        orders = []
        for cnt in range(0,20):
            try:
                try:
                    exec("action  = conf_arr['ADDRESS%d']['action']" % cnt)
                except:
                    action = None

                exec("address = conf_arr['ADDRESS%d']['value']" % cnt)
                exec("netmask = conf_arr['NETMASK%d']['value']" % cnt)
                exec("gateway = conf_arr['GATEWAY%d']['value']" % cnt)

                target = "%s/%s" % (address,netmask,)
                net = NetworkAddress(target)
                try:
                    target = net.cidr
                except:
                    pass
                dop.add("__",[target],gateway)

                if action == "delete":
                    dop.delete("__",[target])

                orders.append([target])
            except:
                pass

        if len(orders) != 0:
            dop.add("__",['@ORDERS'],orders)

        return dop.getconf("__")
开发者ID:goura,项目名称:karesansui,代码行数:35,代码来源:staticroute.py

示例3: _get_iscsi_config

def _get_iscsi_config(node):
    path = iscsi_get_config_path_node(node)
    parser = iscsidParser()
    dop = DictOp()

    dop.addconf(MODULE, parser.read_conf(path))
    return dop
开发者ID:goura,项目名称:karesansui,代码行数:7,代码来源:iscsi.py

示例4: __init__

    def __init__(self):
        self.dop = DictOp()
        self.dop.addconf(self._module,{})

        self.parser = Parser()
        self.base_parser_name = self.parser.__class__.__name__
        pass
开发者ID:goura,项目名称:karesansui,代码行数:7,代码来源:iptables.py

示例5: process

    def process(self):
        (opts, args) = getopts()
        chkopts(opts)
        self.up_progress(1)

        dop = DictOp()
        modules = opts.module.split(":")
        files   = opts.file.split(":")

        retval = True
        cnt = 0
        for _mod in modules:
            _file = files[cnt]
            try:
                exec("from karesansui.lib.parser.%s import %sParser as Parser" % (_mod,_mod,))

                self.up_progress(5)
                parser = Parser()

                self.up_progress(5)
                if opts.raw is True:
                    raw_str = "Config_Raw_%s = {}\n" % (_mod,)
                    for _src in parser.source_file():
                        raw_str = "%sConfig_Raw_%s['%s'] = \"\"\"%s\"\"\"\n" % (raw_str,_mod,_src,open(_src).read())
                    ConfigFile(_file).write(raw_str)

                else:
                    # 設定ファイルの読み込み
                    extra_args = {}
                    extra_args["include"] = opts.include
                    conf_arr = parser.read_conf(extra_args=extra_args)
                    dop.addconf(_mod,conf_arr)
                    #dop.preprint_r(_mod)

                    # 辞書配列ファイルに書き込み
                    _var = "Config_Dict_%s" % (_mod,)
                    if opts.php is True:
                        _str = python_dict_to_php_array(dop.getconf(_mod),_var)
                        ConfigFile(_file).write(_str)
                    else:
                        ConfigFile(_file).write("%s = %s\n" % (_var,str(dop.getconf(_mod)),))

            finally:
                cnt = cnt + 1

        self.up_progress(10)
        return True
开发者ID:fkei,项目名称:karesansui,代码行数:47,代码来源:read_conf.py

示例6: __init__

    def __init__(self,paths=[]):
        self.dop = DictOp()
        self.dop.addconf(self._module,{})
        self.set_source_file(paths)

        self.opt_uni   = ['PIDFile']
        self.opt_multi = ['LoadPlugin','Include']
        self.opt_sect  = ['Directory','VirtualHost','View']
开发者ID:AdUser,项目名称:karesansui,代码行数:8,代码来源:xml_like_conf_parser.py

示例7: _PUT

    def _PUT(self, *param, **params):
        host_id = self.chk_hostby1(param)
        if host_id is None: return web.notfound()

        host = findbyhost1(self.orm, host_id)
        if not validates_iptables_save(self, host):
            return web.badrequest(self.view.alert)

        from karesansui.lib.dict_op import DictOp
        dop = DictOp()
        dop.addconf("iptables", {})
        dop.set("iptables",["config"],self.input.iptables_save.split("\r\n"))
        retval = write_conf(dop, self, host)
        if retval is False:
            return web.internalerror('Internal Server Error. (Adding Task)')

        return web.accepted(url=web.ctx.path)
开发者ID:AdUser,项目名称:karesansui,代码行数:17,代码来源:hostby1iptables.py

示例8: __init__

    def __init__(self):
        self.dop = DictOp()
        self.dop.addconf(self._module,{})

        self.base_parser_name = Parser.__name__

        self.encoding = "UTF-8"
        pass
开发者ID:goura,项目名称:karesansui,代码行数:8,代码来源:eml.py

示例9: __init__

    def __init__(self):
        self.dop = DictOp()
        self.dop.addconf(self._module, {})

        self.parser = Parser()
        self.exclude_device_regex = "\.old|\.bak|\.rpm.*|lo|\.20"
        self.exclude_device_regex = "\.old|\.bak|\.rpm.*|\.20"
        self.base_parser_name = self.parser.__class__.__name__
        pass
开发者ID:nabeken,项目名称:karesansui,代码行数:9,代码来源:ifcfg.py

示例10: __init__

    def __init__(self):
        self.dop = DictOp()
        self.dop.addconf(self._module,{})

        self.parser = Parser()
        self.parser.set_delim("[ \t]+")
        self.parser.set_new_delim("\t")
        self.parser.set_comment("#")
        self.base_parser_name = self.parser.__class__.__name__
        pass
开发者ID:AdUser,项目名称:karesansui,代码行数:10,代码来源:hosts.py

示例11: __init__

    def __init__(self):
        self.dop = DictOp()
        self.dop.addconf(self._module,{})

        self.parser = Parser()
        self.parser.set_delim(" ")
        self.parser.set_new_delim(" ")
        self.parser.set_multidefine(True)
        self.base_parser_name = self.parser.__class__.__name__
        pass
开发者ID:AdUser,项目名称:karesansui,代码行数:10,代码来源:resolv.py

示例12: __init__

    def __init__(self):
        self.dop = DictOp()
        self.dop.addconf(self._module,{})
        self.exclude_device_regex = "\.old|\.bak|\.rpm.*|\.20"

        self.parser = Parser()

        self.config_style = self.detect_config_style()
        if self.config_style == "old":
            self.parser.set_delim(" via ")
            self.parser.set_new_delim(" via ")
        else:
            self.parser.set_delim("=")
            self.parser.set_new_delim("=")

        self.base_parser_name = self.parser.__class__.__name__
        pass
开发者ID:goura,项目名称:karesansui,代码行数:17,代码来源:staticroute.py

示例13: __init__

    def __init__(self):
        self.dop = DictOp()
        self.dop.addconf(self._module,{})

        self.parser = Parser()
        self.parser.set_delim("[ \t]+")
        self.parser.set_new_delim("\t")
        self.parser.set_comment("#")
        self.base_parser_name = self.parser.__class__.__name__

        from karesansui.lib.parser.collectd import collectdParser
        collectdp = collectdParser()

        self.parser.set_opt_uni(collectdp.opt_uni)
        self.parser.set_opt_multi(collectdp.opt_multi)
        self.parser.set_opt_sect(collectdp.opt_sect)

        pass
开发者ID:AdUser,项目名称:karesansui,代码行数:18,代码来源:collectdplugin.py

示例14: _pre_write_conf

    def _pre_write_conf(self,conf_arr={}):

        # Change permission to be able to read/write data kss group.
        if os.path.exists(COLLECTD_DATA_DIR):
            if os.getuid() == 0:
                r_chgrp(COLLECTD_DATA_DIR,KARESANSUI_GROUP)
                r_chmod(COLLECTD_DATA_DIR,"g+rwx")
                r_chmod(COLLECTD_DATA_DIR,"o-rwx")

        dop = DictOp()
        dop.addconf("__",conf_arr)

        if dop.isset("__",["python"]) is True:
            dop.cdp_unset("__",["python","Plugin","python","@ORDERS"],multiple_file=True)
            orders = []
            orders.append(['Encoding'])
            orders.append(['LogTraces'])
            orders.append(['Interactive'])
            orders.append(['ModulePath'])
            orders.append(['Import'])
            orders.append(['Module'])
            dop.cdp_set("__",["python","Plugin","python","@ORDERS"],orders,is_opt_multi=True,multiple_file=True)

        return dop.getconf("__")
开发者ID:AdUser,项目名称:karesansui,代码行数:24,代码来源:collectdplugin.py

示例15: _new_lines

    def _new_lines(self,search_key,new_key):

        try:
            attrs = self.dop.get(self._module,search_key,with_attr=True)
            action    = attrs['action']
            iscomment = attrs['comment']
            val       = attrs['value']
        except:
            action    = self.dop.action(self._module,search_key)
            iscomment = self.dop.iscomment(self._module,search_key)
            val       = self.dop.get(self._module,search_key)
            pass

        #print val
        dop = DictOp()
        dop.addconf('__',{})
        if action == "delete":
            dop.add('__',new_key,val)
            dop.delete('__',new_key)
        elif action == "set":
            dop.set('__',new_key,val)
        else:
            dop.add('__',new_key,val)
        if iscomment is True:
            dop.comment('__',new_key)

        #preprint_r(dop.getconf('__'))
        new_lines = self._value_to_lines(dop.getconf('__'))
        #print "\n".join(new_lines)

        return new_lines
开发者ID:AdUser,项目名称:karesansui,代码行数:31,代码来源:xml_like_conf_parser.py


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