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


Python sublime_plugin.reload_plugin方法代码示例

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


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

示例1: reload_dependency

# 需要导入模块: import sublime_plugin [as 别名]
# 或者: from sublime_plugin import reload_plugin [as 别名]
def reload_dependency(dependency_name, dummy=True, verbose=True):
    """
    Reload.

    Package Control dependencies aren't regular packages, so we don't want to
    call `sublime_plugin.unload_module` or `sublime_plugin.reload_plugin`.
    Instead, we manually unload all of the modules in the dependency and then
    `reload_package` any packages that use that dependency. (We have to manually
    unload the dependency's modules because calling `reload_package` on a
    dependent module will not unload the dependency.)
    """
    for name in get_package_modules(dependency_name):
        del sys.modules[name]

    manager = PackageManager()
    for package in manager.list_packages():
        if dependency_name in manager.get_dependencies(package):
            reload_package(package, dummy=False, verbose=verbose)

    if dummy:
        load_dummy(verbose) 
开发者ID:SublimeText,项目名称:UnitTesting,代码行数:23,代码来源:reloader.py

示例2: reload_package

# 需要导入模块: import sublime_plugin [as 别名]
# 或者: from sublime_plugin import reload_plugin [as 别名]
def reload_package(pkg_name, dummy=True, verbose=True):
    if is_dependency(pkg_name):
        reload_dependency(pkg_name, dummy, verbose)
        return

    if pkg_name not in sys.modules:
        dprint("error:", pkg_name, "is not loaded.")
        return

    if verbose:
        dprint("begin", fill='=')

    modules = get_package_modules(pkg_name)

    for m in modules:
        if m in sys.modules:
            sublime_plugin.unload_module(modules[m])
            del sys.modules[m]

    try:
        with intercepting_imports(modules, verbose), \
                importing_fromlist_aggresively(modules):

            reload_plugin(pkg_name)
    except Exception:
        dprint("reload failed.", fill='-')
        reload_missing(modules, verbose)
        raise

    if dummy:
        load_dummy(verbose)

    if verbose:
        dprint("end", fill='-') 
开发者ID:SublimeText,项目名称:UnitTesting,代码行数:36,代码来源:reloader.py

示例3: reload_plugin

# 需要导入模块: import sublime_plugin [as 别名]
# 或者: from sublime_plugin import reload_plugin [as 别名]
def reload_plugin(pkg_name):
    pkg_path = os.path.join(os.path.realpath(sublime.packages_path()), pkg_name)
    plugins = [pkg_name + "." + os.path.splitext(file_path)[0]
               for file_path in os.listdir(pkg_path) if file_path.endswith(".py")]
    for plugin in plugins:
        sublime_plugin.reload_plugin(plugin) 
开发者ID:SublimeText,项目名称:UnitTesting,代码行数:8,代码来源:reloader.py

示例4: reload_plugin

# 需要导入模块: import sublime_plugin [as 别名]
# 或者: from sublime_plugin import reload_plugin [as 别名]
def reload_plugin(verbose=True, then=None):
    threading.Thread(
        target=functools.partial(reload_package, 'GitSavvy', verbose=verbose, then=then)
    ).start() 
开发者ID:timbrel,项目名称:GitSavvy,代码行数:6,代码来源:reload.py

示例5: reload_package

# 需要导入模块: import sublime_plugin [as 别名]
# 或者: from sublime_plugin import reload_plugin [as 别名]
def reload_package(pkg_name, dummy=True, verbose=True):
    if pkg_name not in sys.modules:
        dprint("error:", pkg_name, "is not loaded.")
        return

    main = sys.modules[pkg_name]

    if verbose:
        dprint("begin", fill='=')

    modules = {main.__name__: main}
    modules.update({name: module for name, module in sys.modules.items()
                    if name.startswith(pkg_name + ".")})
    for m in modules:
        if m in sys.modules:
            sublime_plugin.unload_module(modules[m])
            del sys.modules[m]

    try:
        with intercepting_imports(modules, verbose), \
                importing_fromlist_aggresively(modules):

            reload_plugin(pkg_name)
    except Exception:
        dprint("reload failed.", fill='-')
        reload_missing(modules, verbose)
        raise

    if dummy:
        load_dummy(verbose)

    if verbose:
        dprint("end", fill='-') 
开发者ID:randy3k,项目名称:Terminus,代码行数:35,代码来源:reloader.py

示例6: plugin_unloaded

# 需要导入模块: import sublime_plugin [as 别名]
# 或者: from sublime_plugin import reload_plugin [as 别名]
def plugin_unloaded():
    PACKAGE_NAME = __name__.split('.')[0]
    from package_control import events

    if events.pre_upgrade(PACKAGE_NAME):
        print('Upgrading from %s!' % events.pre_upgrade(PACKAGE_NAME))
    elif events.remove(PACKAGE_NAME):
        # set_language("EN", True)
        cleanup()
        sublime_plugin.reload_plugin('Default')
        print('Removing %s!' % events.remove(PACKAGE_NAME)) 
开发者ID:rexdf,项目名称:Chinese-Localization,代码行数:13,代码来源:Localization.py

示例7: reload_package

# 需要导入模块: import sublime_plugin [as 别名]
# 或者: from sublime_plugin import reload_plugin [as 别名]
def reload_package(package, dependencies=[], dummy=True, verbose=True):
    if verbose:
        dprint("begin", fill='=')

    packages = [package] + dependencies
    parents = set()
    for package in packages:
        for parent in resolve_parents(package):
            parents.add(parent)
    parents = list(parents)

    modules = sorted(
        list(set(get_package_modules(packages + parents))),
        key=lambda x: x[0].split('.')
    )

    plugins = [m for m, is_plugin in modules if is_plugin]
    # Tell Sublime to unload plugin_modules
    for plugin in plugins:
        if plugin in sys.modules:
            sublime_plugin.unload_module(sys.modules[plugin])

    # these are modules marked to be reloaded, they are not necessarily reloaded
    modules_to_reload = [sys.modules[m] for m, is_plugin in modules if m in sys.modules]

    with ReloadingImporter(modules_to_reload, verbose) as importer:
        if plugins:
            # we only reload top level plugin_modules to mimic Sublime Text natural order
            for plugin in plugins:
                if plugin in sys.modules:
                    module = sys.modules[plugin]
                    importer.reload(module)

            for plugin in plugins:
                if plugin in sys.modules:
                    module = sys.modules[plugin]
                    sublime_plugin.load_module(module)
                else:
                    # in case we missed something
                    sublime_plugin.reload_plugin(plugin)
        else:
            # it is possibly a dependency but no packages use it
            for module in modules_to_reload:
                importer.reload(module)

    if dummy:
        load_dummy(verbose)

    if verbose:
        dprint("end", fill='-') 
开发者ID:randy3k,项目名称:AutomaticPackageReloader,代码行数:52,代码来源:reloader.py


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