• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sublime.installed_packages_path函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: get_packages_list

def get_packages_list(ignore_packages=True, ignore_patterns=[]):
    """
    Return a list of packages.
    """
    package_set = set()
    package_set.update(_get_packages_from_directory(sublime.packages_path()))

    if int(sublime.version()) >= 3006:
        package_set.update(_get_packages_from_directory(sublime.installed_packages_path(), ".sublime-package"))

        executable_package_path = os.path.dirname(sublime.executable_path()) + os.sep + "Packages"
        package_set.update(_get_packages_from_directory(executable_package_path, ".sublime-package"))


    if ignore_packages:
        ignored_list = sublime.load_settings(
            "Preferences.sublime-settings").get("ignored_packages", [])
    else:
        ignored_list = []

    for package in package_set:
        for pattern in ignore_patterns:
            if re.match(pattern, package):
                ignored_list.append(package)
                break

    for ignored in ignored_list:
        package_set.discard(ignored)

    return sorted(list(package_set))
开发者ID:antstorm,项目名称:PackageResourceViewer,代码行数:30,代码来源:package_resources.py


示例17: pack_packages

    def pack_packages(self, password=None, backup=False, exclude_from_package_control=True, **kwargs):
        """
        Compresses Packages and Installed Packages
        """
        excluded_dirs = kwargs.get("excluded_dirs", [])
        packages_root_path = os.path.basename(sublime.packages_path())
        installed_packages_root_path = os.path.basename(sublime.installed_packages_path())

        # Append blacklisted Packages to excluded dirs
        for package in blacklist.packages:
            excluded_dirs.append(os.path.join(packages_root_path, package))

        # Append blacklisted Installed Packages to excluded dirs
        for package in blacklist.installed_packages:
            excluded_dirs.append(os.path.join(installed_packages_root_path, package))

        # Append custom ignored packages
        for package in blacklist.get_ignored_packages():
            excluded_dirs.append(package)

        #  Add Package Control excludes
        if exclude_from_package_control and not backup:
            excluded_dirs.extend(self._excludes_from_package_control())

        logger.info("Excluded dirs: %s" % excluded_dirs)
        kwargs["excluded_dirs"] = excluded_dirs

        # Generate a temporary output filename if necessary
        if "output_filename" not in kwargs:
            kwargs["output_filename"] = generate_temp_filename()
        self._run_executable("a", password=password, **kwargs)
        return kwargs["output_filename"]
开发者ID:wilsonmiz,项目名称:Sublimall,代码行数:32,代码来源:archiver.py


示例18: get_package_and_resource_name

def get_package_and_resource_name(path):
    """
    This method will return the package name and resource name from a path.

    Arguments:
    path    Path to parse for package and resource name.
    """
    package = None
    resource = None
    path = _normalize_to_sublime_path(path)
    if os.path.isabs(path):
        packages_path = _normalize_to_sublime_path(sublime.packages_path())
        if path.startswith(packages_path):
            package, resource = _search_for_package_and_resource(path, packages_path)

        if int(sublime.version()) >= 3006:
            packages_path = _normalize_to_sublime_path(sublime.installed_packages_path())
            if path.startswith(packages_path):
                package, resource = _search_for_package_and_resource(path, packages_path)

            packages_path = _normalize_to_sublime_path(os.path.dirname(sublime.executable_path()) + os.sep + "Packages")
            if path.startswith(packages_path):
                package, resource = _search_for_package_and_resource(path, packages_path)
    else:
        path = re.sub(r"^Packages/", "", path)
        split = re.split(r"/", path, 1)
        package = split[0]
        package = package.replace(".sublime-package", "")
        resource = split[1]

    return (package, resource)
开发者ID:antstorm,项目名称:PackageResourceViewer,代码行数:31,代码来源:package_resources.py


示例19: _read_zip_file

def _read_zip_file(package, relative_path, binary=False, debug=False):
    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, True)
        return False

    try:
        contents = package_zip.read(relative_path)
        if not binary:
            contents = contents.decode('utf-8')
        return contents

    except (KeyError) as e:
        pass

    except (IOError) as e:
        message = unicode_from_os(e)
        console_write(u'Unable to read file from sublime-package file for %s due to an invalid filename' % package, True)

    except (UnicodeDecodeError):
        console_write(u'Unable to read file from sublime-package file for %s due to an invalid filename or character encoding issue' % package, True)

    return False
开发者ID:Nielingluo,项目名称:Sublime-Text-2,代码行数:31,代码来源:package_io.py


示例20: get_changed_files

def get_changed_files(files):
    basepath = sublime.installed_packages_path()
    changed = []

    for package, path, timestamp, hash_value in files:
        package_path = os.path.join(basepath, package + ".sublime-package")

        try:
            mtime = os.stat(package_path).st_mtime
        except FileNotFoundError:
            sublime.error_message("{}: package {} not found".format(PACKAGE_NAME, package))
            continue

        if timestamp == mtime:
            continue

        zf = ZipFile(package_path)

        try:
            content = zf.read(path)
        except KeyError:
            sublime.error_message("{}: there is no {} in {}".format(PACKAGE_NAME, path, package))
            continue

        new_hash_value = get_hash(content)

        if new_hash_value == hash_value:
            continue

        changed.append([package, path, mtime, new_hash_value])

    return changed
开发者ID:Shura1oplot,项目名称:MySublimeTextProfile,代码行数:32,代码来源:ChangesObserver.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sublime.load_binary_resource函数代码示例发布时间:2022-05-27
下一篇:
Python sublime.get_clipboard函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap