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


Python sublime.packages_path函数代码示例

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


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

示例1: run

    def run(self, view):
        servidor=utils.get_preference("server")
        if not servidor:
            sublime.status_message("No se ha definido un servidor")
            return
        self.servidor=servidor
        comando=server_command[servidor]
        print("el servidor es : "+servidor)
        servidor=server_path[servidor]
        folder=sublime.active_window().folders()[0]
        self.archivos=[]
        self.explore(folder)
        ruta=""
        for archivo in self.archivos:
            if archivo.endswith(".ear"):
                ruta=archivo
                break
            if archivo.endswith(".war"):ruta=archivo
        if not ruta:
            sublime.status_message("no hay nada pa desplegar")
            return
        filename=os.path.basename(ruta)
        os.chdir(folder)
        d={"filepath":ruta, "serverpath":os.path.join(servidor, filename)}
#        comando='mvn -q package -DskipTests && rm -f "%(weblogicpath)s" && cp "%(filepath)s" "%(weblogicpath)s" && exit'%d
        comando=comando%d
        print(comando)
        archivo=open(sublime.packages_path()+os.sep+"start.cmd", "w")
        archivo.write(comando)
        archivo.close()
        os.system("start /min "+sublime.packages_path()+os.sep+"start.cmd")
        threading.Thread(target=self.run_server).start()
开发者ID:programadorsito,项目名称:Packages,代码行数:32,代码来源:servers.py

示例2: backup_package_dir

    def backup_package_dir(self, package_name):
        """
        Does a full backup of the Packages/{package}/ dir to Backup/

        :param package_name:
            The name of the package to back up

        :return:
            If the backup succeeded
        """

        package_dir = os.path.join(sublime.packages_path(), package_name)
        if not os.path.exists(package_dir):
            return True

        try:
            backup_dir = os.path.join(os.path.dirname(
                sublime.packages_path()), 'Backup',
                datetime.datetime.now().strftime('%Y%m%d%H%M%S'))
            if not os.path.exists(backup_dir):
                os.makedirs(backup_dir)
            package_backup_dir = os.path.join(backup_dir, package_name)
            if os.path.exists(package_backup_dir):
                console_write(u"FOLDER %s ALREADY EXISTS!" % package_backup_dir)
            shutil.copytree(package_dir, package_backup_dir)
            return True

        except (OSError, IOError) as e:
            show_error(u'An error occurred while trying to backup the package directory for %s.\n\n%s' % (
                package_name, unicode_from_os(e)))
            if os.path.exists(package_backup_dir):
                shutil.rmtree(package_backup_dir)
            return False
开发者ID:zhjuncai,项目名称:sublime3-sync,代码行数:33,代码来源:package_manager.py

示例3: get_commands

    def get_commands(self):
        """
        This is a stub for getting the existing commands and adding
        autocomplete
        """
        packages = os.listdir(sublime.packages_path())
        self.packages = sorted(packages, key=lambda s: s.lower())
        self.window_commands = []

        for package in self.packages:
            package_dir = sublime.packages_path() + '/' + package
            sys.path.append(package_dir)
            __all__ = [os.path.basename(f)[:-3] for f in glob.glob(package_dir + "/*.py")]
            for sub_package in __all__:
                module = __import__(sub_package)
                for obj in dir(module):
                    actual_obj = getattr(module, obj)
                    if isinstance(actual_obj,
                                  sublime_plugin.WindowCommand):
                        self.window_commands.append(obj)
                    if isinstance(actual_obj,
                                  sublime_plugin.TextCommand):
                        self.window_commands.append(obj)

        print self.window_commands
开发者ID:nicolaslara,项目名称:ExecuteCommand,代码行数:25,代码来源:ExecuteCommand.py

示例4: run

	def run(self, edit):
		#print self.window.forders()
		_folder_ = self.view.window().folders()
		__mapping__ = {}
		__mapping__['programs'] = []
		for _path_ in _folder_:
			_random = int(random.random()*1000000)
			if sublime.platform() == 'windows':
				_caption = re.match(r".*\\([^\\]*)", _path_).group(1)
				_tempStr_ = '{ "command": "pathconfig", "caption": "' + _caption + '", "args":{"path":"' + re.sub(r'\\', r'\\\\', _path_) + '", "id":"keynes' + str(_random) + '", "name":"' + _caption + '"}},'
			else :
				_caption = re.match(r".*/([^/]*)", _path_).group(1)
				_tempStr_ = '{ "command": "pathconfig", "caption": "' + _caption + '", "args":{"path":"' + _path_ + '", "id":"keynes' + str(_random) + '", "name":"' + _caption + '"}},'
			print re.sub(r'\\', r'\\\\', _path_)
			__mapping__['programs'].append(_tempStr_)
		_MainRep_ = KeyTemplate(__mainTemplate__()).render({
			"programs":__mapping__['programs']
		})
		#配置文件为packages目录下FE-Package目录
		if sublime.platform() == 'windows':
			_packpath = sublime.packages_path() + r'\FE-Package\Main.sublime-menu'
		else:
			_packpath = sublime.packages_path() + r'/FE-Package/Main.sublime-menu'
		_packfile = open(_packpath, 'w')
		_packfile.writelines(_MainRep_)
		_packfile.close()
开发者ID:KeynesQ,项目名称:WPCF,代码行数:26,代码来源:FE-Package.py

示例5: get_user_packages

def get_user_packages():
    user = set()
    for fname in listdir(sublime.packages_path()):
        path = join(sublime.packages_path(), fname)
        if isdir(path) and not(fname.startswith('.')):
            user.add(fname)
    return user
开发者ID:aziz,项目名称:sublimeText3-Userfiles,代码行数:7,代码来源:download.py

示例6: update_binary

def update_binary():
    bindir = os.path.join(sublime.packages_path(), usrbin)
    binpath = os.path.join(bindir, binname)
    pkgpath = os.path.join(sublime.installed_packages_path(), 'ColorPicker.sublime-package')
    respath = 'Packages/ColorPicker/lib/' + binname
    libdir = os.path.join(sublime.packages_path(), 'ColorPicker', 'lib')
    libpath = os.path.join(libdir, binname)

    bininfo = None
    bindata = None

    if os.path.exists(binpath):
        bininfo = os.stat(binpath)
    elif not os.path.exists(bindir):
        os.makedirs(bindir, 0o755)

    if os.path.exists(libpath):
        libinfo = os.stat(libpath)
        if bininfo == None or bininfo[ST_MTIME] < libinfo[ST_MTIME]:
            with open(libpath, 'rb') as libfile:
                bindata = libfile.read()
                libfile.close()
    elif sublime_version == 3 and os.path.exists(pkgpath):
        pkginfo = os.stat(pkgpath)
        if bininfo == None or bininfo[ST_MTIME] < pkginfo[ST_MTIME]:
            bindata = sublime.load_binary_resource(respath)

    if bindata != None:
        print("* Updating " + binpath)
        with open(binpath, 'wb') as binfile:
            binfile.write(bindata)
            binfile.close()

    if not os.access(binpath, os.X_OK):
        os.chmod(binpath, 0o755)
开发者ID:Beatt,项目名称:ColorPicker,代码行数:35,代码来源:sublimecp.py

示例7: run

    def run(self):
        if self.window.active_view().file_name():
            configFile = os.path.join(os.path.dirname(self.window.active_view().file_name()), 'pandoc-config.json')
        else:
            sublime.status_message("Cannot create project configuration for unsaved files.")
            return

        if os.path.exists(configFile):
            self.window.open_file(configFile)
            return

        defaultConfigFile = os.path.join(sublime.packages_path(), 'Pandown', 'default-pandoc-config.json')
        userConfigFile = os.path.join(sublime.packages_path(), 'User', 'pandoc-config.json')
        if not os.path.exists(defaultConfigFile) and not os.path.exists(userConfigFile):
            sublime.status_message("Could not find default Pandoc configuration.")
            print("[Pandown stores default configuration information in Projects/Pandown/default-pandoc-config.json.]")
            print("[If this file has been moved or deleted, please reinstall Pandown.]")
            print("[See the README for support information.]")
            return
        try:
            toCopy = defaultConfigFile if (not os.path.exists(userConfigFile)) else userConfigFile
            shutil.copy(toCopy, configFile)
        except Exception as e:
            sublime.status_message("Could not write " + configFile)
            print("[Pandown encountered an exception:]")
            print("[e: " + str(e) + "]")
        else:
            self.window.open_file(configFile)
开发者ID:dflock,项目名称:Pandown,代码行数:28,代码来源:pandownTouchProjectConfigCommand.py

示例8: beautify

	def beautify(self, text, indent, filters):
		stderr = ""
		stdout = ""
		php_path = self.formatter.settings.get('codeformatter_php_path', '');
		if (php_path == ""):
			php_path = "php"

		try:
			if (self.formatter.platform == "windows"):
				startupinfo = subprocess.STARTUPINFO()
				startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
				startupinfo.wShowWindow = subprocess.SW_HIDE

				beautifier_exe = sublime.packages_path()+"\CodeFormatter\codeformatter\lib\phpbeautifier\php_beautifier"
				cmd = sublime.packages_path()+"\CodeFormatter\codeformatter\lib\phpbeautifier\php_beautifier.bat"
				fullcmd = [str(cmd), str(php_path), str(beautifier_exe), indent, "-l", filters, "-f", "-", "-o", "-"]
				#print(" ".join(map(str, fullcmd)))
				p = subprocess.Popen(fullcmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo, shell=False, creationflags=subprocess.SW_HIDE)
			else:
				cmd = sublime.packages_path()+"/CodeFormatter/codeformatter/lib/phpbeautifier/php_beautifier"
				p = subprocess.Popen([str(cmd), indent, "-l", filters, "-f", "-", "-o", "-"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
			stdout, stderr = p.communicate(text)
		except Exception as e:
			stderr = str(e)

		if (not stderr and not stdout):
			stderr = "Formatting error!"

		return stdout, stderr
开发者ID:baldhead,项目名称:sublimetext-codeformatter,代码行数:29,代码来源:__init__.py

示例9: write_file

    def write_file(self):
        if os.path.exists(sublime.packages_path()+'/Gitignore'):
            path = sublime.packages_path()+'/Gitignore/boilerplates/'
        else:
            path = sublime.packages_path()+'/Sublime-Gitignore/boilerplates/'

        final = ''

        for bp in self.chosen_array:
            bpfile = open(path+bp+'.gitignore', 'r')
            text = bpfile.read()
            bpfile.close()

            final = final + '###'+bp+'###\n \n'+text+'\n\n'

        view = sublime.active_window().new_file()
        edit = view.begin_edit()
        view.insert(edit, 0, final)
        view.set_name('.gitignore')
        view.end_edit(edit)

        self.chosen_array = []
        self.first_list = ['Actionscript', 'Android', 'Autotools', 'CakePHP', 'CFWheels', 'C', 'C++', 'Clojure', 'CMake', 'CodeIgniter', 'Compass', 'Concrete5', 'Coq', 'CSharp', 'Delphi', 'Django', 'Drupal', 'Erlang', 'ExpressionEngine', 'Finale', 'ForceDotCom', 'FuelPHP', 'gcov', 'Go', 'Grails', 'GWT', 'Haskell', 'Java', 'Jboss', 'Jekyll', 'Joomla', 'Jython', 'Kohana', 'LaTeX', 'Leiningen', 'LemonStand', 'Lilypond', 'Lithium', 'Magento', 'Maven', 'nanoc', 'Node', 'Objective-C', 'OCaml', 'Opa', 'opencart', 'OracleForms', 'Perl', 'PlayFramework', 'Python', 'Qooxdoo', 'Rails', 'R', 'RhodesRhomobile', 'Ruby', 'Scala', 'SeamGen', 'SketchUp', 'SugarCRM', 'Symfony2', 'Symfony', 'SymphonyCMS', 'Target3001', 'Tasm', 'Textpattern', 'TurboGears2', 'Unity', 'VB.Net', 'Waf', 'Wordpress', 'Yii', 'ZendFramework', 'Archives', 'CVS', 'Eclipse', 'Emacs', 'Espresso', 'FlexBuilder', 'IntelliJ', 'Linux', 'Matlab', 'Mercurial', 'ModelSim', 'MonoDevelop', 'NetBeans', 'OSX', 'Quartus2', 'Redcar', 'RubyMine', 'SASS', 'SBT', 'SublimeText', 'SVN', 'Tags', 'TextMate', 'vim', 'VisualStudio', 'Windows', 'XilinxISE']

        self.second_list = ['Done', 'Actionscript', 'Android', 'Autotools', 'CakePHP', 'CFWheels', 'C', 'C++', 'Clojure', 'CMake', 'CodeIgniter', 'Compass', 'Concrete5', 'Coq', 'CSharp', 'Delphi', 'Django', 'Drupal', 'Erlang', 'ExpressionEngine', 'Finale', 'ForceDotCom', 'FuelPHP', 'gcov', 'Go', 'Grails', 'GWT', 'Haskell', 'Java', 'Jboss', 'Jekyll', 'Joomla', 'Jython', 'Kohana', 'LaTeX', 'Leiningen', 'LemonStand', 'Lilypond', 'Lithium', 'Magento', 'Maven', 'nanoc', 'Node', 'Objective-C', 'OCaml', 'Opa', 'opencart', 'OracleForms', 'Perl', 'PlayFramework', 'Python', 'Qooxdoo', 'Rails', 'R', 'RhodesRhomobile', 'Ruby', 'Scala', 'SeamGen', 'SketchUp', 'SugarCRM', 'Symfony2', 'Symfony', 'SymphonyCMS', 'Target3001', 'Tasm', 'Textpattern', 'TurboGears2', 'Unity', 'VB.Net', 'Waf', 'Wordpress', 'Yii', 'ZendFramework', 'Archives', 'CVS', 'Eclipse', 'Emacs', 'Espresso', 'FlexBuilder', 'IntelliJ', 'Linux', 'Matlab', 'Mercurial', 'ModelSim', 'MonoDevelop', 'NetBeans', 'OSX', 'Quartus2', 'Redcar', 'RubyMine', 'SASS', 'SBT', 'SublimeText', 'SVN', 'Tags', 'TextMate', 'vim', 'VisualStudio', 'Windows', 'XilinxISE']
开发者ID:mattclements,项目名称:Sublime-Gitignore,代码行数:25,代码来源:gitignore.py

示例10: getSnippet

    def getSnippet(self, name=None, scope=['text.plain']):
        
        snippetFilenames = self.findFiles(sublime.packages_path())

        sublime_package_filenames = self.findFiles(sublime.packages_path() + "\\..", ".sublime-package")

        content = []
        for sp in sublime_package_filenames:
            file = zipfile.ZipFile(sp)
            content.append( [file.open(name).read() for name in file.namelist() if name.endswith(".sublime-snippet") ])

        content = [item for sublist in content for item in sublist]

        tex = self.xmlMatchTabTriggerFromString(content, str(name))
        package_snippet_contents =[
            x.find('content').text
            for x in tex
            if self.filterByScope(x, scope)
        ]

        snippet_xmls = self.xmlMatchTabTrigger(snippetFilenames, str(name))

        custom_snippet_contents = [
            x.find('content').text
            for x in snippet_xmls
            if self.filterByScope(x, scope)
        ]
        return custom_snippet_contents + package_snippet_contents
开发者ID:ColinRyan,项目名称:SnippetX,代码行数:28,代码来源:snippetx.py

示例11: 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

示例12: plugin_loaded

def plugin_loaded():
    global full_data_path, full_icons_path, full_themes_path
    full_data_path = os.path.join(sublime.packages_path()[:-len("Packages")], os.path.normpath(data_path))
    full_icons_path = os.path.join(full_data_path, "icons")
    full_themes_path = os.path.join(full_data_path, "themes")
    # Create folders
    if not os.path.exists(full_data_path):
        os.mkdir(full_data_path)
    if not os.path.exists(full_icons_path):
        os.mkdir(full_icons_path)
    if not os.path.exists(full_themes_path):
        os.mkdir(full_themes_path)

    # Copy binary
    binary = "ColorPicker_" + get_ext()
    chflags = stat.S_IXUSR|stat.S_IXGRP|stat.S_IRUSR|stat.S_IRUSR|stat.S_IWUSR|stat.S_IWGRP
    fpath = os.path.join(full_data_path, binary)
    if get_version() >= 3000:
        if not os.path.exists(fpath):
            data = sublime.load_binary_resource('/'.join(["Packages", "Color Highlighter", "ColorPicker", binary]))
            if len(data) != 0:
                write_bin_file(fpath, data)
                os.chmod(fpath, chflags)
    else:
        if not os.path.exists(fpath):
            shutil.copy(os.path.join(sublime.packages_path(), "Color Highlighter", "ColorPicker", binary), fpath)
            os.chmod(fpath, chflags)

    # restore themes
    restore_broken_schemes()
开发者ID:rocknrollMarc,项目名称:Sublime-Text-2,代码行数:30,代码来源:ColorHighlighter.py

示例13: find_syntax_files

def find_syntax_files():
	global syntax_files

	new = []

	# Packages folder
	for root, dirs, files in os.walk(sublime.packages_path()):
		for name in files:
			try:
				ext = os.path.splitext(name)[-1]
				if ext == '.tmLanguage':
					path = os.path.join(root, name)
					name = os.path.splitext(os.path.split(path)[1])[0]
					new.append((path, name))
			except:
				pass
	
	# Installed Packages
	for root, dirs, files in os.walk(sublime.packages_path()):
		break # don't know how to address tmLanguage files in zips for set_syntax_file
		try:
			ext = os.path.splitext(name)[-1]
			if ext == '.sublime-package':
				pass
		except:
			pass
	
	new.sort(key=lambda x: x[1])
	syntax_files = new
开发者ID:lunixbochs,项目名称:sublime-syntaxget,代码行数:29,代码来源:syntaxget.py

示例14: enumerate_virtual_package_folders

def enumerate_virtual_package_folders():
    """
    
    Note that a package may appear more than once in this list.
    
    An abstract Package consist of a sublime-package sitting in one of the 
    `zipped_package_locations()` and also various overrides in a folder 
    on `sublime.packages_path()`
    
    """
    installed_packages       = ([

            # We make redundant info here, so later we know this
            bunch( zip_path    = False,
                   folder_path = join(sublime.packages_path(), d),
                   pkg_name    = d )
        for
            d in os.listdir(sublime.packages_path())
        if
            isdir (join(sublime.packages_path(), d))
    ])

    for location in zipped_package_locations():
        packages_pattern = location + '/*.sublime-package'
        packages = glob.glob(packages_pattern)

        for package in packages:
            package_info = bunch (
                folder_path=False,
                zip_path=package,
                pkg_name=basename(splitext(package)[0]))
            installed_packages.append(package_info)

    return installed_packages
开发者ID:sublimator,项目名称:EditPreferences,代码行数:34,代码来源:package_resources.py

示例15: get_project

def get_project():
    if not sublime.active_window():
        return None
    win_id = sublime.active_window().id()
    project = None
    reg_session = os.path.join(sublime.packages_path(), "..", "Settings", "Session.sublime_session")
    auto_save = os.path.join(sublime.packages_path(), "..", "Settings", "Auto Save Session.sublime_session")
    session = auto_save if os.path.exists(auto_save) else reg_session

    if not os.path.exists(session) or win_id == None:
        return project

    try:
        with open(session, 'r') as f:
            # Tabs in strings messes things up for some reason
            j = json.JSONDecoder(strict=False).decode(f.read())
            for w in j['windows']:
                if w['window_id'] == win_id:
                    if "workspace_name" in w:
                        if sublime.platform() == "windows":
                            # Account for windows specific formatting
                            project = os.path.normpath(w["workspace_name"].lstrip("/").replace("/", ":/", 1))
                        else:
                            project = w["workspace_name"]
                        break
    except:
        pass

    # Throw out empty project names
    if project == None or re.match(".*\\.sublime-project", project) == None or not os.path.exists(project):
        project = None

    return project
开发者ID:altintx,项目名称:sublimeconfig2,代码行数:33,代码来源:swi.py


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