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


Python _compat.iteritems方法代码示例

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


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

示例1: print_usage

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import iteritems [as 别名]
def print_usage(actions):
    """Print the usage information.  (Help screen)"""
    actions = sorted(iteritems(actions))
    print('usage: %s <action> [<options>]' % basename(sys.argv[0]))
    print('       %s --help' % basename(sys.argv[0]))
    print()
    print('actions:')
    for name, (func, doc, arguments) in actions:
        print('  %s:' % name)
        for line in doc.splitlines():
            print('    %s' % line)
        if arguments:
            print()
        for arg, shortcut, default, argtype in arguments:
            if isinstance(default, bool):
                print('    %s' % (
                    (shortcut and '-%s, ' % shortcut or '') + '--' + arg
                ))
            else:
                print('    %-30s%-10s%s' % (
                    (shortcut and '-%s, ' % shortcut or '') + '--' + arg,
                    argtype, default
                ))
        print() 
开发者ID:jpush,项目名称:jbox,代码行数:26,代码来源:script.py

示例2: _find_common_roots

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import iteritems [as 别名]
def _find_common_roots(paths):
    """Out of some paths it finds the common roots that need monitoring."""
    paths = [x.split(os.path.sep) for x in paths]
    root = {}
    for chunks in sorted(paths, key=len, reverse=True):
        node = root
        for chunk in chunks:
            node = node.setdefault(chunk, {})
        node.clear()

    rv = set()

    def _walk(node, path):
        for prefix, child in iteritems(node):
            _walk(child, path + (prefix,))
        if not node:
            rv.add('/'.join(path))
    _walk(root, ())
    return rv 
开发者ID:jpush,项目名称:jbox,代码行数:21,代码来源:_reloader.py

示例3: restart_with_reloader

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import iteritems [as 别名]
def restart_with_reloader(self):
        """Spawn a new Python interpreter with the same arguments as this one,
        but running the reloader thread.
        """
        while 1:
            _log('info', ' * Restarting with %s' % self.name)
            args = [sys.executable] + sys.argv
            new_environ = os.environ.copy()
            new_environ['WERKZEUG_RUN_MAIN'] = 'true'

            # a weird bug on windows. sometimes unicode strings end up in the
            # environment and subprocess.call does not like this, encode them
            # to latin1 and continue.
            if os.name == 'nt' and PY2:
                for key, value in iteritems(new_environ):
                    if isinstance(value, text_type):
                        new_environ[key] = value.encode('iso-8859-1')

            exit_code = subprocess.call(args, env=new_environ,
                                        close_fds=False)
            if exit_code != 3:
                return exit_code 
开发者ID:jpush,项目名称:jbox,代码行数:24,代码来源:_reloader.py

示例4: restart_with_reloader

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import iteritems [as 别名]
def restart_with_reloader(self):
        """Spawn a new Python interpreter with the same arguments as this one,
        but running the reloader thread.
        """
        while 1:
            _log('info', ' * Restarting with %s' % self.name)
            args = _get_args_for_reloading()
            new_environ = os.environ.copy()
            new_environ['WERKZEUG_RUN_MAIN'] = 'true'

            # a weird bug on windows. sometimes unicode strings end up in the
            # environment and subprocess.call does not like this, encode them
            # to latin1 and continue.
            if os.name == 'nt' and PY2:
                for key, value in iteritems(new_environ):
                    if isinstance(value, text_type):
                        new_environ[key] = value.encode('iso-8859-1')

            exit_code = subprocess.call(args, env=new_environ,
                                        close_fds=False)
            if exit_code != 3:
                return exit_code 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:24,代码来源:_reloader.py

示例5: print_usage

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import iteritems [as 别名]
def print_usage(actions):
    """Print the usage information.  (Help screen)"""
    _deprecated()
    actions = sorted(iteritems(actions))
    print('usage: %s <action> [<options>]' % basename(sys.argv[0]))
    print('       %s --help' % basename(sys.argv[0]))
    print()
    print('actions:')
    for name, (func, doc, arguments) in actions:
        print('  %s:' % name)
        for line in doc.splitlines():
            print('    %s' % line)
        if arguments:
            print()
        for arg, shortcut, default, argtype in arguments:
            if isinstance(default, bool):
                print('    %s' % (
                    (shortcut and '-%s, ' % shortcut or '') + '--' + arg
                ))
            else:
                print('    %-30s%-10s%s' % (
                    (shortcut and '-%s, ' % shortcut or '') + '--' + arg,
                    argtype, default
                ))
        print() 
开发者ID:liantian-cn,项目名称:RSSNewsGAE,代码行数:27,代码来源:script.py

示例6: _find_common_roots

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import iteritems [as 别名]
def _find_common_roots(paths):
    """Out of some paths it finds the common roots that need monitoring."""
    paths = [x.split(os.path.sep) for x in paths]
    root = {}
    for chunks in sorted(paths, key=len, reverse=True):
        node = root
        for chunk in chunks:
            node = node.setdefault(chunk, {})
        node.clear()

    rv = set()
    def _walk(node, path):
        for prefix, child in iteritems(node):
            _walk(child, path + (prefix,))
        if not node:
            rv.add('/'.join(path))
    _walk(root, ())
    return rv 
开发者ID:chalasr,项目名称:Flask-P2P,代码行数:20,代码来源:_reloader.py

示例7: restart_with_reloader

# 需要导入模块: from werkzeug import _compat [as 别名]
# 或者: from werkzeug._compat import iteritems [as 别名]
def restart_with_reloader(self):
        """Spawn a new Python interpreter with the same arguments as this one,
        but running the reloader thread.
        """
        while 1:
            _log('info', ' * Restarting with %s' % self.name)
            args = [sys.executable] + sys.argv
            new_environ = os.environ.copy()
            new_environ['WERKZEUG_RUN_MAIN'] = 'true'

            # a weird bug on windows. sometimes unicode strings end up in the
            # environment and subprocess.call does not like this, encode them
            # to latin1 and continue.
            if os.name == 'nt' and PY2:
                for key, value in iteritems(new_environ):
                    if isinstance(value, text_type):
                        new_environ[key] = value.encode('iso-8859-1')

            exit_code = subprocess.call(args, env=new_environ)
            if exit_code != 3:
                return exit_code 
开发者ID:chalasr,项目名称:Flask-P2P,代码行数:23,代码来源:_reloader.py


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