當前位置: 首頁>>代碼示例>>Python>>正文


Python config.load_dict方法代碼示例

本文整理匯總了Python中fapws.config.load_dict方法的典型用法代碼示例。如果您正苦於以下問題:Python config.load_dict方法的具體用法?Python config.load_dict怎麽用?Python config.load_dict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fapws.config的用法示例。


在下文中一共展示了config.load_dict方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from fapws import config [as 別名]
# 或者: from fapws.config import load_dict [as 別名]
def __init__(self, app, rule, method, callback,
                 name=None,
                 plugins=None,
                 skiplist=None, **config):
        #: The application this route is installed to.
        self.app = app
        #: The path-rule string (e.g. ``/wiki/<page>``).
        self.rule = rule
        #: The HTTP method as a string (e.g. ``GET``).
        self.method = method
        #: The original callback with no plugins applied. Useful for introspection.
        self.callback = callback
        #: The name of the route (if specified) or ``None``.
        self.name = name or None
        #: A list of route-specific plugins (see :meth:`Bottle.route`).
        self.plugins = plugins or []
        #: A list of plugins to not apply to this route (see :meth:`Bottle.route`).
        self.skiplist = skiplist or []
        #: Additional keyword arguments passed to the :meth:`Bottle.route`
        #: decorator are stored in this dictionary. Used for route-specific
        #: plugin configuration and meta-data.
        self.config = app.config._make_overlay()
        self.config.load_dict(config) 
開發者ID:brycesub,項目名稱:silvia-pi,代碼行數:25,代碼來源:bottle.py

示例2: load_dict

# 需要導入模塊: from fapws import config [as 別名]
# 或者: from fapws.config import load_dict [as 別名]
def load_dict(self, source, namespace=''):
        """ Load values from a dictionary structure. Nesting can be used to
            represent namespaces.

            >>> c = ConfigDict()
            >>> c.load_dict({'some': {'namespace': {'key': 'value'} } })
            {'some.namespace.key': 'value'}
        """
        for key, value in source.items():
            if isinstance(key, basestring):
                nskey = (namespace + '.' + key).strip('.')
                if isinstance(value, dict):
                    self.load_dict(value, namespace=nskey)
                else:
                    self[nskey] = value
            else:
                raise TypeError('Key has type %r (not a string)' % type(key))
        return self 
開發者ID:brycesub,項目名稱:silvia-pi,代碼行數:20,代碼來源:bottle.py

示例3: __init__

# 需要導入模塊: from fapws import config [as 別名]
# 或者: from fapws.config import load_dict [as 別名]
def __init__(self, app, rule, method, callback,
                 name=None,
                 plugins=None,
                 skiplist=None, **config):
        #: The application this route is installed to.
        self.app = app
        #: The path-rule string (e.g. ``/wiki/<page>``).
        self.rule = rule
        #: The HTTP method as a string (e.g. ``GET``).
        self.method = method
        #: The original callback with no plugins applied. Useful for introspection.
        self.callback = callback
        #: The name of the route (if specified) or ``None``.
        self.name = name or None
        #: A list of route-specific plugins (see :meth:`Bottle.route`).
        self.plugins = plugins or []
        #: A list of plugins to not apply to this route (see :meth:`Bottle.route`).
        self.skiplist = skiplist or []
        #: Additional keyword arguments passed to the :meth:`Bottle.route`
        #: decorator are stored in this dictionary. Used for route-specific
        #: plugin configuration and meta-data.
        self.config = ConfigDict().load_dict(config) 
開發者ID:warriorframework,項目名稱:warriorframework,代碼行數:24,代碼來源:bottle.py

示例4: load_module

# 需要導入模塊: from fapws import config [as 別名]
# 或者: from fapws.config import load_dict [as 別名]
def load_module(self, path, squash=True):
        """Load values from a Python module.

           Example modue ``config.py``::

                DEBUG = True
                SQLITE = {
                    "db": ":memory:"
                }


           >>> c = ConfigDict()
           >>> c.load_module('config')
           {DEBUG: True, 'SQLITE.DB': 'memory'}
           >>> c.load_module("config", False)
           {'DEBUG': True, 'SQLITE': {'DB': 'memory'}}

           :param squash: If true (default), dictionary values are assumed to
                          represent namespaces (see :meth:`load_dict`).
        """
        config_obj = load(path)
        obj = {key: getattr(config_obj, key) for key in dir(config_obj)
               if key.isupper()}

        if squash:
            self.load_dict(obj)
        else:
            self.update(obj)
        return self 
開發者ID:brycesub,項目名稱:silvia-pi,代碼行數:31,代碼來源:bottle.py

示例5: load_module

# 需要導入模塊: from fapws import config [as 別名]
# 或者: from fapws.config import load_dict [as 別名]
def load_module(self, path, squash):
        """ Load values from a Python module.
            :param squash: Squash nested dicts into namespaces by using
                           load_dict(), otherwise use update()
            Example: load_config('my.app.settings', True)
            Example: load_config('my.app.settings', False)
        """
        config_obj = __import__(path)
        obj = dict([(key, getattr(config_obj, key))
                for key in dir(config_obj) if key.isupper()])
        if squash:
            self.load_dict(obj)
        else:
            self.update(obj)
        return self 
開發者ID:warriorframework,項目名稱:warriorframework,代碼行數:17,代碼來源:bottle.py

示例6: _main

# 需要導入模塊: from fapws import config [as 別名]
# 或者: from fapws.config import load_dict [as 別名]
def _main(argv):  # pragma: no coverage
    args, parser = _cli_parse(argv)

    def _cli_error(cli_msg):
        parser.print_help()
        _stderr('\nError: %s\n' % cli_msg)
        sys.exit(1)

    if args.version:
        _stdout('Bottle %s\n' % __version__)
        sys.exit(0)
    if not args.app:
        _cli_error("No application entry point specified.")

    sys.path.insert(0, '.')
    sys.modules.setdefault('bottle', sys.modules['__main__'])

    host, port = (args.bind or 'localhost'), 8080
    if ':' in host and host.rfind(']') < host.rfind(':'):
        host, port = host.rsplit(':', 1)
    host = host.strip('[]')

    config = ConfigDict()

    for cfile in args.conf or []:
        try:
            if cfile.endswith('.json'):
                with open(cfile, 'rb') as fp:
                    config.load_dict(json_loads(fp.read()))
            else:
                config.load_config(cfile)
        except configparser.Error as parse_error:
            _cli_error(parse_error)
        except IOError:
            _cli_error("Unable to read config file %r" % cfile)
        except (UnicodeError, TypeError, ValueError) as error:
            _cli_error("Unable to parse config file %r: %s" % (cfile, error))

    for cval in args.param or []:
        if '=' in cval:
            config.update((cval.split('=', 1),))
        else:
            config[cval] = True

    run(args.app,
        host=host,
        port=int(port),
        server=args.server,
        reloader=args.reload,
        plugins=args.plugin,
        debug=args.debug,
        config=config) 
開發者ID:brycesub,項目名稱:silvia-pi,代碼行數:54,代碼來源:bottle.py


注:本文中的fapws.config.load_dict方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。