本文整理汇总了Python中sublime.installed_packages_path方法的典型用法代码示例。如果您正苦于以下问题:Python sublime.installed_packages_path方法的具体用法?Python sublime.installed_packages_path怎么用?Python sublime.installed_packages_path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sublime
的用法示例。
在下文中一共展示了sublime.installed_packages_path方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unified_mode
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import installed_packages_path [as 别名]
def unified_mode():
source = UNIFIED_SETTINGS['source']
target = os.path.join(sublime.packages_path(), UNIFIED_SETTINGS['target'])
package = os.path.join(sublime.installed_packages_path(),
UNIFIED_SETTINGS['package'])
is_unified = get_settings().get('theme_unified', False)
main = os.path.join(sublime.packages_path(), PARENT, source)
if is_unified:
if not os.path.exists(target):
os.mkdir(target)
if os.path.exists(main):
copy_dir(main, target)
else:
extract_dir(package, source, target)
elif os.path.exists(target):
shutil.rmtree(target)
示例2: has_package
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import installed_packages_path [as 别名]
def has_package(package):
zipped_file = os.path.join(
sublime.installed_packages_path(), "{}.sublime-package".format(package))
unzipped_folder = os.path.join(sublime.packages_path(), package)
if not os.path.exists(zipped_file) and not os.path.exists(unzipped_folder):
return False
preferences = sublime.load_settings("Preferences.sublime-settings")
if package in preferences.get("ignored_packages", []):
return False
return True
示例3: get_package_modules
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import installed_packages_path [as 别名]
def get_package_modules(pkg_name):
in_installed_path = functools.partial(
path_contains,
os.path.join(
sublime.installed_packages_path(),
pkg_name + '.sublime-package'
)
)
in_package_path = functools.partial(
path_contains,
os.path.join(sublime.packages_path(), pkg_name)
)
def module_in_package(module):
file = getattr(module, '__file__', '') or ''
paths = getattr(module, '__path__', ()) or ''
return (
in_installed_path(file) or any(map(in_installed_path, paths)) or
in_package_path(file) or any(map(in_package_path, paths))
)
return {
name: module
for name, module in sys.modules.items()
if module_in_package(module)
}
# check the link for comments
# https://github.com/divmain/GitSavvy/blob/599ba3cdb539875568a96a53fafb033b01708a67/common/util/reload.py
示例4: has_colorschemeunit
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import installed_packages_path [as 别名]
def has_colorschemeunit():
if "ColorSchemeUnit.sublime-package" in os.listdir(sublime.installed_packages_path()):
return True
elif "ColorSchemeUnit" in os.listdir(sublime.packages_path()):
return True
return False
示例5: get_package_modules
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import installed_packages_path [as 别名]
def get_package_modules(pkg_name):
in_installed_path = functools.partial(
path_contains,
os.path.join(
sublime.installed_packages_path(),
pkg_name + '.sublime-package'
)
)
in_package_path = functools.partial(
path_contains,
os.path.join(sublime.packages_path(), pkg_name)
)
def module_in_package(module):
file = getattr(module, '__file__', '')
paths = getattr(module, '__path__', ())
return (
in_installed_path(file) or any(map(in_installed_path, paths)) or
in_package_path(file) or any(map(in_package_path, paths))
)
return {
name: module
for name, module in sys.modules.items()
if module_in_package(module)
}
示例6: get_package_modules
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import installed_packages_path [as 别名]
def get_package_modules(package_names):
package_names = set(package_names)
package_path_bases = [
p
for pkg_name in package_names
for p in (
os.path.join(
sublime.installed_packages_path(),
pkg_name + '.sublime-package'
),
os.path.join(sublime.packages_path(), pkg_name),
)
]
def module_paths(module):
try:
yield module.__file__
except AttributeError:
pass
try:
yield from module.__path__
except AttributeError:
pass
for module in sys.modules.values():
try:
base, path = next(
(base, path)
for path in module_paths(module)
for base in package_path_bases
if path and (path == base or path.startswith(base + os.sep))
)
except StopIteration:
continue
else:
is_plugin = (os.path.dirname(path) == base)
yield module.__name__, is_plugin
# get all the top level plugins in case they were removed from sys.modules
for path in sublime.find_resources("*.py"):
for pkg_name in package_names:
if posixpath.dirname(path) == 'Packages/'+pkg_name:
yield pkg_name + '.' + posixpath.basename(posixpath.splitext(path)[0]), True
示例7: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import installed_packages_path [as 别名]
def run(self):
"""
Creates or updates the system bootstrap package by packaging up the
contents of the resource directory.
"""
self.disable_package()
res_path = normpath(join(dirname(__file__), "..", bootstrap_pkg))
package = join(sublime.installed_packages_path(), bootstrap_pkg +
".sublime-package")
prefix = os.path.commonprefix([res_path, package])
log("Bootstraping {path} to {pkg}",
path=res_path[len(prefix):],
pkg=package[len(prefix):])
pkg_existed = os.path.isfile(package)
success = self.create_bootstrap_package(package, res_path)
self.enable_package(success)
if not success:
return log(
"""
An error was encountered while updating my_package.
Please check the console to see what went wrong.
my_package will not be available until the problem
is resolved.
""", error=True)
if pkg_existed:
log(
"""
my_package has been updated!
In order to complete the update, restart Sublime
Text.
""", dialog=True)
else:
log(
"""
my_package has been installed!
""", dialog=True)
### ---------------------------------------------------------------------------