Python sublime.installed_packages_path() Examples
The following are 7
code examples of sublime.installed_packages_path().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sublime
, or try the search function
.
Example #1
Source File: addons.py From sublime-boxy-theme with MIT License | 6 votes |
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)
Example #2
Source File: package.py From AutomaticPackageReloader with MIT License | 5 votes |
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
Example #3
Source File: reloader.py From UnitTesting with MIT License | 5 votes |
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
Example #4
Source File: test_3141596.py From UnitTesting with MIT License | 5 votes |
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
Example #5
Source File: reload.py From GitSavvy with MIT License | 5 votes |
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) }
Example #6
Source File: reloader.py From AutomaticPackageReloader with MIT License | 4 votes |
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
Example #7
Source File: bootstrapper.py From SublimeScraps with MIT License | 4 votes |
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) ### ---------------------------------------------------------------------------