本文整理汇总了Python中sublime.executable_path函数的典型用法代码示例。如果您正苦于以下问题:Python executable_path函数的具体用法?Python executable_path怎么用?Python executable_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了executable_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: _get_resource
def _get_resource(package_name, resource, return_binary=False, encoding="utf-8"):
packages_path = sublime.packages_path()
content = None
if VERSION > 3013:
try:
if return_binary:
content = sublime.load_binary_resource("Packages/" + package_name + "/" + resource)
else:
content = sublime.load_resource("Packages/" + package_name + "/" + resource)
except IOError:
pass
else:
path = None
if os.path.exists(os.path.join(packages_path, package_name, resource)):
path = os.path.join(packages_path, package_name, resource)
content = _get_directory_item_content(path, return_binary, encoding)
if VERSION >= 3006:
sublime_package = package_name + ".sublime-package"
packages_path = sublime.installed_packages_path()
if content is None:
if os.path.exists(os.path.join(packages_path, sublime_package)):
content = _get_zip_item_content(os.path.join(packages_path, sublime_package), resource, return_binary, encoding)
packages_path = os.path.dirname(sublime.executable_path()) + os.sep + "Packages"
if content is None:
if os.path.exists(os.path.join(packages_path, sublime_package)):
content = _get_zip_item_content(os.path.join(packages_path, sublime_package), resource, return_binary, encoding)
return content.replace("\r\n", "\n").replace("\r", "\n")
开发者ID:antstorm,项目名称:PackageResourceViewer,代码行数:32,代码来源:package_resources.py
示例3: 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
示例4: subl
def subl(args=[]):
# learnt from SideBarEnhancements
executable_path = sublime.executable_path()
if sublime.platform() == 'osx':
app_path = executable_path[:executable_path.rfind(".app/") + 5]
executable_path = app_path + "Contents/SharedSupport/bin/subl"
subprocess.Popen([executable_path] + args)
开发者ID:mkeeler,项目名称:Project-Manager,代码行数:7,代码来源:pm.py
示例5: list_package_files
def list_package_files(package, ignore_patterns=[]):
"""
List files in the specified package.
"""
package_path = os.path.join(sublime.packages_path(), package, "")
path = None
file_set = set()
file_list = []
if os.path.exists(package_path):
for root, directories, filenames in os.walk(package_path):
temp = root.replace(package_path, "")
for filename in filenames:
file_list.append(os.path.join(temp, filename))
file_set.update(file_list)
if VERSION >= 3006:
sublime_package = package + ".sublime-package"
packages_path = sublime.installed_packages_path()
if os.path.exists(os.path.join(packages_path, sublime_package)):
file_set.update(_list_files_in_zip(packages_path, sublime_package))
packages_path = os.path.dirname(sublime.executable_path()) + os.sep + "Packages"
if os.path.exists(os.path.join(packages_path, sublime_package)):
file_set.update(_list_files_in_zip(packages_path, sublime_package))
file_list = []
for filename in file_set:
if not _ignore_file(filename, ignore_patterns):
file_list.append(_normalize_to_sublime_path(filename))
return sorted(file_list)
开发者ID:antstorm,项目名称:PackageResourceViewer,代码行数:35,代码来源:package_resources.py
示例6: open_folder
def open_folder(dir_path):
"""dir_pathにあるディレクトリをSublime Text 3で開く.
現状の実装ではsubprocess.Popenを用いて, 新しいウィンドウを起動する.
(これはSideBarEnhancementsパッケージを参考にしたものである)
"""
subprocess.Popen([sublime.executable_path(), dir_path], cwd=dir_path)
开发者ID:autopp,项目名称:Open-Sublime-Package,代码行数:7,代码来源:open_sublime_package.py
示例7: 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
示例8: run
def run(self, args = []):
# 替换参数中的环境变量
env = self.window.extract_variables()
args = [sublime.expand_variables(x, env) for x in args]
# 获取【sublime】执行路径
executable_path = sublime.executable_path()
# 获取【OSX】下的【subl】目录
if sublime.platform() == 'osx':
app_path = executable_path[:executable_path.rfind(".app/") + 5]
executable_path = app_path + "Contents/SharedSupport/bin/subl"
# 运行【subl】命令
subprocess.Popen([executable_path] + args)
# 修复在【Windows】下窗口推动焦点
if sublime.platform() == "windows":
def fix_focus():
window = sublime.active_window()
view = window.active_view()
window.run_command('focus_neighboring_group')
window.focus_view(view)
sublime.set_timeout(fix_focus, 300)
开发者ID:edonet,项目名称:package,代码行数:26,代码来源:subl_command.py
示例9: launch_ST3
def launch_ST3(self, files):
executable_path = sublime.executable_path()
if OSX:
app_path = executable_path[:executable_path.rfind(".app/")+5]
executable_path = app_path+"Contents/SharedSupport/bin/subl"
items = [executable_path, "-n"] + files
subprocess.Popen(items, cwd=None if NT else self.path)
开发者ID:DesruX,项目名称:SublimeFileBrowser,代码行数:7,代码来源:dired_misc.py
示例10: init
def init():
absDir = os.path.dirname(os.path.abspath(__file__))
if v == '3' and os.path.isfile(absDir):
pkgDir = os.path.join(sublime.packages_path(), pName);
if not os.path.isdir(pkgDir):
unpackSelf(absDir, pkgDir)
return
locale = ''
firstRun = False
fFile = os.path.join(pDir, '.firstRun')
if not os.path.isfile(fFile):
firstRun = True
backupMenu()
open(fFile, 'wt').write('')
locale = getSetting('locale', '')
eDir = os.path.join(mDir, version, 'en');
if v == '3' and not os.path.isdir(eDir):
eFile = sublime.executable_path();
dFile = os.path.join(os.path.dirname(eFile), 'Packages', 'Default.sublime-package');
unpackMenu(dFile, eDir);
makeMenu(locale, firstRun)
makeCommand(locale, firstRun)
setLocale(locale, firstRun)
s = sublime.load_settings(sFile)
s.add_on_change('locale', updateLocale)
开发者ID:zam1024t,项目名称:LocalizedMenu,代码行数:26,代码来源:Localize.py
示例11: load_and_save_scopes
def load_and_save_scopes(self):
scopes = set()
for x in os.walk(sublime.packages_path() + '/..'):
for f in glob.glob(os.path.join(x[0], '*.tmLanguage')):
for s in self.get_scopes_from(plistlib.readPlist(f)):
scopes.add(s.strip())
for x in os.walk(os.path.dirname(sublime.executable_path())):
for f in glob.glob(os.path.join(x[0], '*.sublime-package')):
input_zip = ZipFile(f)
for name in input_zip.namelist():
if name.endswith('.tmLanguage'):
for s in self.get_scopes_from(plistlib.readPlistFromBytes(input_zip.read(name))):
scopes.add(s.strip())
for x in os.walk(sublime.packages_path() + '/..'):
for f in glob.glob(os.path.join(x[0], '*.sublime-package')):
input_zip = ZipFile(f)
for name in input_zip.namelist():
if name.endswith('.tmLanguage'):
for s in self.get_scopes_from(plistlib.readPlistFromBytes(input_zip.read(name))):
scopes.add(s.strip())
names = list(scopes)
scopes = dict()
for name in names:
value = name
if value.startswith('source.'):
value = value[7:]
elif value.startswith('text.'):
value = value[5:]
scopes[name] = value
self.settings.set('scopes', scopes)
sublime.save_settings('smart-pieces.sublime-settings')
开发者ID:webNeat,项目名称:smart-pieces-sublime-text,代码行数:33,代码来源:SmartPieces.py
示例12: run
def run(self, edit, **args):
current_project = sublime.active_window().project_file_name()
if current_project is None:
current_project = ""
executable_path = sublime.executable_path()
subprocess.Popen([executable_path, "-n", current_project])
开发者ID:aqt,项目名称:Sublime-text-config,代码行数:8,代码来源:aqt-commands.py
示例13: sublime_package_paths
def sublime_package_paths():
"""Get all the locations where plugins live."""
return [
sublime.installed_packages_path(),
join(dirname(sublime.executable_path()), "Packages"),
sublime.packages_path()
]
开发者ID:facelessuser,项目名称:ColorSchemeEditor,代码行数:8,代码来源:package_search.py
示例14: run
def run(self, paths = []):
import subprocess
items = []
items.append(sublime.executable_path())
for item in SideBarSelection(paths).getSelectedItems():
items.append(item.forCwdSystemPath())
items.append(item.path())
subprocess.Popen(items, cwd=items[1])
开发者ID:pcm1509,项目名称:SublimeText3-Packages,代码行数:8,代码来源:SideBar.py
示例15: open_in_new_window
def open_in_new_window(path):
" Open a path in a new ST3 window by invoking the subl cli utility "
# https://github.com/titoBouzout/SideBarEnhancements/blob/st3/SideBar.py#L1643
executable_path = sublime.executable_path()
if sublime.platform() == 'osx':
app_path = executable_path[:executable_path.rfind(".app/") + 5]
executable_path = app_path + "Contents/SharedSupport/bin/subl"
subprocess.Popen([executable_path, path], env=env())
开发者ID:countergram,项目名称:Pypr,代码行数:8,代码来源:commands.py
示例16: get_subl_executable_path
def get_subl_executable_path():
executable_path = sublime.executable_path()
if sublime.platform() == 'osx':
suffix = '.app/'
app_path = executable_path[:executable_path.rfind(suffix) + len(suffix)]
executable_path = app_path + 'Contents/SharedSupport/bin/subl'
return executable_path
开发者ID:molee1905,项目名称:ShenMa,代码行数:9,代码来源:sm.py
示例17: defaultMenuOverrides
def defaultMenuOverrides( self ):
## Let's remove 'Copy File Path' from default menus; we'll add our own
# Create a 'Default' directory in /Packages/ so we can override the default ST menu; 'Default' will be automagically created if it doesn't already exist
packages_default_dir = os.path.join( os.path.dirname( sublime.packages_path() ), 'Packages', 'Default' )
# TODO: implement or remove this
#if not os.path.exists( packages_default_dir ):
# os.mkdir( packages_default_dir )
# Get ST's Default.sublime-package
default_sublime_package = os.path.join( os.path.dirname( sublime.executable_path() ), 'Packages', 'Default.sublime-package' )
# Read archive contents but don't truncate
archive = open( default_sublime_package, 'rb')
# Unzip archive
unzippedArchive = zipfile.ZipFile( archive )
# Iterate over archive files
for name in unzippedArchive.namelist():
# Extract file we need
unzippedArchive.extract( 'Context.sublime-menu', packages_default_dir )
# Close archive
unzippedArchive.close()
## Edit /Packages/Default/Context.sublime-menu created by File Metadata plugin
# Retrieve file
context_sublime_menu = os.path.join( os.path.dirname( sublime.packages_path() ), 'Packages', 'Default', 'Context.sublime-menu' )
# Open file in 'read' mode
f = open( context_sublime_menu, 'r' )
# Get all lines from the file
lines = f.readlines()
# Close the file
f.close()
# Re-open the file in 'write' mode (why you need to do dis twice, Python??)
f = open( context_sublime_menu, 'w' )
# Iterate over lines
for line in lines:
# If line doesn't match our exclude pattern
if not '{ "command": "copy_path", "caption": "Copy File Path" }' in line:
# Write the remaining lines
f.write(line)
# Close the file
f.close()
开发者ID:hugoburiel,项目名称:FileMetadata,代码行数:56,代码来源:file_metadata.py
示例18: get_subl_executable_path
def get_subl_executable_path( self ):
"""Return the path to the subl command line binary."""
executable_path = sublime.executable_path()
if sublime.platform() == 'osx':
suffix = '.app/'
app_path = executable_path[:executable_path.rfind(suffix) + len(suffix)]
executable_path = app_path + 'Contents/SharedSupport/bin/subl'
return executable_path
开发者ID:DanCassiano,项目名称:Gitblime,代码行数:10,代码来源:Gitblime.py
示例19: get_installed_packages
def get_installed_packages(ignore_packages=True, ignore_patterns=[]):
package_set = set()
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"))
return sorted(list(_remove_ignored_packages(ignore_packages, ignore_patterns, package_set)))
开发者ID:skuroda,项目名称:PackageResources,代码行数:11,代码来源:package_resources.py
示例20: extract_package
def extract_package(package):
if VERSION >= 3006:
package_location = os.path.join(sublime.installed_packages_path(), package + ".sublime-package")
if not os.path.exists(package_location):
package_location = os.path.join(os.path.dirname(sublime.executable_path()), "Packages", package + ".sublime-package")
if not os.path.exists(package_location):
package_location = None
if package_location:
with zipfile.ZipFile(package_location) as zip_file:
extract_location = os.path.join(sublime.packages_path(), package)
zip_file.extractall(extract_location)
开发者ID:antstorm,项目名称:PackageResourceViewer,代码行数:11,代码来源:package_resources.py
注:本文中的sublime.executable_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论