當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。