本文整理汇总了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)
示例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='-')
示例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)
示例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()
示例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='-')
示例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))
示例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='-')