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


Python sublime.installed_packages_path函数代码示例

本文整理汇总了Python中sublime.installed_packages_path函数的典型用法代码示例。如果您正苦于以下问题:Python installed_packages_path函数的具体用法?Python installed_packages_path怎么用?Python installed_packages_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: get_drush_path

 def get_drush_path(self):
     """
     Get the path to the Drush executable. It's either in Packages or
     Installed Packages, depending on the user's installation method.
     If either of those fail, check for system-wide Drush.
     """
     settings = sublime.load_settings("subDrush.sublime-settings")
     if settings:
         drush_path = settings.get("drush_executable")
         if str(drush_path) != "subDrush":
             print("subDrush: Using user defined path to Drush: %s" % drush_path)
             if not os.path.exists(drush_path):
                 sublime.error_message(
                     'You specified "%s" as the path to \
                 Drush but this does not seem to be valid. Please fix your \
                 settings at Preferences > Package Settings > subDrush > \
                 Settings - User'
                     % drush_path
                 )
                 return False
             return drush_path
     print("subDrush: Using subDrush's bundled version of Drush.")
     if os.path.exists("%s/subDrush/lib/drush/drush" % sublime.packages_path()):
         return "%s/subDrush/lib/drush/drush" % sublime.packages_path()
     elif os.path.exists("%s/subDrush/lib/drush/drush" % sublime.installed_packages_path()):
         return "%s/subDrush/lib/drush/drush" % sublime.installed_packages_path()
     else:
         print("subDrush: Using system-wide Drush install.")
         return shutil.which("drush")
开发者ID:kostajh,项目名称:subDrush,代码行数:29,代码来源:drush.py

示例2: __init__

    def __init__(self, view):
        # Setup the plugin in the super class
        sublime_plugin.TextCommand.__init__(self, view)

        try:
            pluginPath = sublime.packages_path() + '/AndroidImport'
            classes_file = open(pluginPath + '/classes.txt')
        except IOError:
            try:
                pluginPath = sublime.installed_packages_path() + '/AndroidImport'
                classes_file = open(pluginPath + '/classes.txt')
            except IOError:
                try:
                    pluginPath = sublime.packages_path() + '/AndroidImport.sublime-package'
                    with zipfile.ZipFile(pluginPath) as package_zip:
                        classes_file = package_zip.open('classes.txt')
                except IOError:
                    try:
                        pluginPath = sublime.installed_packages_path() + '/AndroidImport.sublime-package'
                        with zipfile.ZipFile(pluginPath) as package_zip2:
                            classes_file = package_zip2.open('classes.txt')
                    except IOError:
                        sublime.error_message("Couldn't load AndroidImport plugin. Maybe try reinstalling...")
                        return

        self.androidClassList = dict()
        for line in classes_file.readlines():
            line_parts = line.split('::')
            key = line_parts[0]
            line_parts.remove(key)

            self.androidClassList[key] = list()
            for package in line_parts:
                self.androidClassList[key].append(''.join(package.split()))
开发者ID:ch3ll0v3k,项目名称:SublimeAndroidImport,代码行数:34,代码来源:android_import.py

示例3: load_schemes

	def load_schemes(self):
		scheme_paths = []
		favorites = self.get_favorites()

		try: # use find_resources() first for ST3.
			scheme_paths = sublime.find_resources('*.tmTheme')

		except: # fallback to walk() for ST2
			# Load the paths for schemes contained in zipped .sublime-package files.
			for root, dirs, files in os.walk(sublime.installed_packages_path()):
				for package in (package for package in files if package.endswith('.sublime-package')):
					zf = zipfile.ZipFile(os.path.join(sublime.installed_packages_path(), package))
					for filename in (filename for filename in zf.namelist() if filename.endswith('.tmTheme')):
						filepath = os.path.join(root, package, filename).replace(sublime.installed_packages_path(), 'Packages').replace('.sublime-package', '').replace('\\', '/')
						scheme_paths.append(filepath)

			# Load the paths for schemes contained in folders.
			for root, dirs, files in os.walk(sublime.packages_path()):
				for filename in (filename for filename in files if filename.endswith('.tmTheme')):
					filepath = os.path.join(root, filename).replace(sublime.packages_path(), 'Packages').replace('\\', '/')
					scheme_paths.append(filepath)

		scheme_paths = self.filter_scheme_list(scheme_paths)

		# Given the paths of all the color schemes, add in the information for
		# the pretty-printed name and whether or not it's been favorited.
		schemes = []
		for scheme_path in scheme_paths:
			scheme_name = self.filter_scheme_name(scheme_path)
			is_favorite = ''
			if scheme_path in favorites: is_favorite = u'   \u2605' # Put a pretty star icon next to favorited schemes. :)
			schemes.append([scheme_name, scheme_path, is_favorite])

		schemes.sort(key=lambda s: s[0].lower())
		return schemes
开发者ID:SyntaxColoring,项目名称:Schemr,代码行数:35,代码来源:schemr.py

示例4: load_themes

	def load_themes(self):
		all_themes = set()

		try: # use find_resources() first for ST3
			for theme_resource in sublime.find_resources('*.sublime-theme'):
				filename = os.path.basename(theme_resource)
				all_themes.add(filename)

		except: # fallback to walk() for ST2
			for root, dirs, files in os.walk(sublime.packages_path()):
				for filename in (filename for filename in files if filename.endswith('.sublime-theme')):
					all_themes.add(filename)

			for root, dirs, files in os.walk(sublime.installed_packages_path()):
				for package in (package for package in files if package.endswith('.sublime-package')):
					zf = zipfile.ZipFile(os.path.join(sublime.installed_packages_path(), package))
					for filename in (filename for filename in zf.namelist() if filename.endswith('.sublime-theme')):
						all_themes.add(filename)

		favorite_themes = self.get_favorites()
		themes = []

		for theme in all_themes:
			favorited = theme in favorite_themes
			pretty_name = 'Theme: ' + theme.replace('.sublime-theme', '')
			if favorited: pretty_name += u' \N{BLACK STAR}' # Put a pretty star icon next to favorited themes. :)
			themes.append([pretty_name, theme, favorited])

		themes.sort()
		return themes
开发者ID:andreystarkov,项目名称:sublime2-frontend,代码行数:30,代码来源:themr.py

示例5: __init__

 def __init__(self):
     """
     Stores sublime packages paths
     """
     self.directory_list = {sublime.packages_path(): "", sublime.installed_packages_path(): ".sublime-package"}
     self.packages_bak_path = "%s.bak" % sublime.packages_path()
     self.installed_packages_bak_path = "%s.bak" % (sublime.installed_packages_path())
     self.settings = sublime.load_settings(SETTINGS_USER_FILE)
开发者ID:wilsonmiz,项目名称:Sublimall,代码行数:8,代码来源:archiver.py

示例6: move_packages_to_backup_dirs

    def move_packages_to_backup_dirs(self):
        """
        Moves packages directories to backups
        """
        self.remove_backup_dirs()

        logger.info("Move %s to %s" % (sublime.installed_packages_path(), self.installed_packages_bak_path))
        self._safe_copy(sublime.installed_packages_path(), self.installed_packages_bak_path)
        logger.info("Move %s to %s" % (sublime.packages_path(), self.packages_bak_path))
        self._safe_copy(sublime.packages_path(), self.packages_bak_path)
开发者ID:wilsonmiz,项目名称:Sublimall,代码行数:10,代码来源:archiver.py

示例7: __init__

 def __init__(self):
     """
     Stores sublime packages paths
     """
     self.directory_list = {
         sublime.packages_path(): '',
         sublime.installed_packages_path(): '.sublime-package'
     }
     self.packages_bak_path = '%s.bak' % sublime.packages_path()
     self.installed_packages_bak_path = '%s.bak' % sublime.installed_packages_path()
开发者ID:koriolis,项目名称:Sublimall,代码行数:10,代码来源:archiver.py

示例8: _zip_file_exists

def _zip_file_exists(package, relative_path):
    zip_path = os.path.join(sublime.installed_packages_path(),
        package + '.sublime-package')

    if not os.path.exists(zip_path):
        return False

    try:
        package_zip = zipfile.ZipFile(zip_path, 'r')

    except (zipfile.BadZipfile):
        console_write(
            u'''
            An error occurred while trying to unzip the sublime-package file
            for %s.
            ''',
            package
        )
        return False

    try:
        package_zip.getinfo(relative_path)
        return True

    except (KeyError):
        return False
开发者ID:Brother-Simon,项目名称:package_control,代码行数:26,代码来源:package_io.py

示例9: run

    def run(self, edit):
        def_path = join(dirname(sublime.executable_path()), 'Packages')
        default = set([re.sub(r'\.sublime-package', '', p) for p in listdir(def_path)])
        user = get_user_packages() - get_dependencies()
        pc = set([re.sub(r'\.sublime-package', '', p) for p in listdir(sublime.installed_packages_path())])
        disabled = set(sublime.load_settings('Preferences.sublime-settings').get('ignored_packages', []))
        ignored = set(["User", "bz2", "0_package_control_loader", ".DS_Store"])

        enabled_def = default - disabled
        disabled_def = default - enabled_def
        pc_total = (pc | (user - default)) - ignored
        enabled_pc = pc_total - disabled
        disabled_pc = pc_total - enabled_pc
        total = (pc | user | disabled | default) - ignored
        enabled = total - disabled

        Row = namedtuple('Row', ['Type', 'Total', 'Disabled', 'Enabled'])
        row1 = Row("Built-in", len(default), len(disabled_def), len(enabled_def))
        row2 = Row("Package Control", len(pc_total), len(disabled_pc), len(enabled_pc))
        row3 = Row("Total", len(total), len(disabled), len(enabled))
        results = pprinttable([row1, row2, row3])
        sep_line = "\n————————————————————————————————————————————\n\t"

        out = self.view.window().get_output_panel("stats")
        self.view.window().run_command("show_panel", {"panel": "output.stats"})
        out.insert(edit, out.size(), results)
        out.insert(edit, out.size(), "\n\nPackage Control Packages (Enabled):" + sep_line + '\n\t'.join(sorted(enabled_pc, key=lambda s: s.lower())))
        out.insert(edit, out.size(), "\n\nPackage Control Packages (Disabled):" + sep_line + '\n\t'.join(sorted(disabled_pc, key=lambda s: s.lower())))
        out.insert(edit, out.size(), "\n\nDefault Packages (Enabled):" + sep_line + '\n\t'.join(sorted(enabled_def, key=lambda s: s.lower())))
        out.insert(edit, out.size(), "\n\nDefault Packages (Disabled):" + sep_line + '\n\t'.join(sorted(disabled_def, key=lambda s: s.lower())))
开发者ID:aziz,项目名称:sublimeText3-Userfiles,代码行数:30,代码来源:download.py

示例10: remove_package

    def remove_package(self, package):
        # Check for installed_package path
        try:
            installed_package_path = os.path.join(sublime.installed_packages_path(), package + ".sublime-package")
            if os.path.exists(installed_package_path):
                os.remove(installed_package_path)
        except:
            return False

        # Check for pristine_package_path path
        try:
            pristine_package_path = os.path.join(
                os.path.dirname(sublime.packages_path()), "Pristine Packages", package + ".sublime-package"
            )
            if os.path.exists(pristine_package_path):
                os.remove(pristine_package_path)
        except:
            return False

        # Check for package dir
        try:
            os.chdir(sublime.packages_path())
            package_dir = os.path.join(sublime.packages_path(), package)
            if os.path.exists(package_dir):
                if shutil.rmtree(package_dir):
                    open(os.path.join(package_dir, "package-control.cleanup"), "w").close()
        except:
            return False

        return True
开发者ID:jbgriffith,项目名称:SublimeText-Package-Syncing,代码行数:30,代码来源:thread.py

示例11: read_js

def read_js(file_path, use_unicode=True):
	file_path = os.path.normpath(file_path)
	if hasattr(sublime, 'load_resource'):
		rel_path = None
		for prefix in [sublime.packages_path(), sublime.installed_packages_path()]:
			if file_path.startswith(prefix):
				rel_path = os.path.join('Packages', file_path[len(prefix) + 1:])
				break

		if rel_path:
			rel_path = rel_path.replace('.sublime-package', '')
			# for Windows we have to replace slashes
			# print('Loading %s' % rel_path)
			rel_path = rel_path.replace('\\', '/')
			return sublime.load_resource(rel_path)

	if use_unicode:
		f = codecs.open(file_path, 'r', 'utf-8')
	else:
		f = open(file_path, 'r')

	content = f.read()
	f.close()

	return content
开发者ID:labyrlnth,项目名称:livestyle-sublime,代码行数:25,代码来源:diff.py

示例12: get_package_modules

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)
    }
开发者ID:randy3k,项目名称:PackageReloader,代码行数:27,代码来源:reloader.py

示例13: do

def do(renderer, keymap_counter):
	default_packages = ['Default']
	user_packages = ['User']
	global_settings = sublime.load_settings("Preferences.sublime-settings")
	ignored_packages = global_settings.get("ignored_packages", [])
	package_control_settings = sublime.load_settings("Package Control.sublime-settings")
	installed_packages = package_control_settings.get("installed_packages", [])
	if len(installed_packages) == 0:
		includes = ('.sublime-package')
		os_packages = []
		for (root, dirs, files) in os.walk(sublime.installed_packages_path()):
			for file in files:
				if file.endswith(includes):
					os_packages.append(file.replace(includes, ''))
		for (root, dirs, files) in os.walk(sublime.packages_path()):
			for dir in dirs:
				os_packages.append(dir)
			break	# just the top level
		installed_packages = []
		[installed_packages.append(package) for package in os_packages if package not in installed_packages]

	diff = lambda l1,l2: [x for x in l1 if x not in l2]
	active_packages = diff( default_packages + installed_packages + user_packages, ignored_packages)

	keymapsExtractor = KeymapsExtractor(active_packages, keymap_counter)
	worker_thread = WorkerThread(keymapsExtractor, renderer)
	worker_thread.start()
	ThreadProgress(worker_thread, 'Searching ' + MY_NAME, 'Done.', keymap_counter)
开发者ID:sandroqz,项目名称:sublime-text,代码行数:28,代码来源:Keymaps.py

示例14: on_activated

    def on_activated(self, view):
        point = view.sel()[0].b
        if not view.score_selector(point, "text.tex.latex"):
            return

        # Checking whether LaTeX-cwl is installed
        global CWL_COMPLETION
        if os.path.exists(sublime.packages_path() + "/LaTeX-cwl") or \
            os.path.exists(sublime.installed_packages_path() + "/LaTeX-cwl.sublime-package"):
            CWL_COMPLETION = True

        if CWL_COMPLETION:
            g_settings = sublime.load_settings("Preferences.sublime-settings")
            acts = g_settings.get("auto_complete_triggers", [])

            # Whether auto trigger is already set in Preferences.sublime-settings
            TEX_AUTO_COM = False
            for i in acts:
                if i.get("selector") == "text.tex.latex" and i.get("characters") == "\\":
                    TEX_AUTO_COM = True

            if not TEX_AUTO_COM:
                acts.append({
                    "characters": "\\",
                    "selector": "text.tex.latex"
                })
                g_settings.set("auto_complete_triggers", acts)
开发者ID:AJLitt,项目名称:LaTeXTools,代码行数:27,代码来源:latex_cwl_completions.py

示例15: plugin_loaded

def plugin_loaded():
    if DEBUG:
        UTC_TIME = datetime.utcnow()
        PYTHON = sys.version_info[:3]
        VERSION = sublime.version()
        PLATFORM = sublime.platform()
        ARCH = sublime.arch()
        PACKAGE = sublime.packages_path()
        INSTALL = sublime.installed_packages_path()

        message = (
            'Jekyll debugging mode enabled...\n'
            '\tUTC Time: {time}\n'
            '\tSystem Python: {python}\n'
            '\tSystem Platform: {plat}\n'
            '\tSystem Architecture: {arch}\n'
            '\tSublime Version: {ver}\n'
            '\tSublime Packages Path: {package}\n'
            '\tSublime Installed Packages Path: {install}\n'
        ).format(time=UTC_TIME, python=PYTHON, plat=PLATFORM, arch=ARCH,
                 ver=VERSION, package=PACKAGE, install=INSTALL)

        sublime.status_message('Jekyll: Debugging enabled...')
        debug('Plugin successfully loaded.', prefix='\n\nJekyll', level='info')
        debug(message, prefix='Jekyll', level='info')
开发者ID:nighthawk,项目名称:sublime-jekyll,代码行数:25,代码来源:jekyll.py


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