本文整理汇总了Python中sublime.platform方法的典型用法代码示例。如果您正苦于以下问题:Python sublime.platform方法的具体用法?Python sublime.platform怎么用?Python sublime.platform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sublime
的用法示例。
在下文中一共展示了sublime.platform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_hidden
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def is_hidden(self, filename, path, goto=''):
if not (path or goto): # special case for ThisPC
return False
tests = self.view.settings().get('dired_hidden_files_patterns', ['.*'])
if isinstance(tests, str):
tests = [tests]
if any(fnmatch.fnmatch(filename, pattern) for pattern in tests):
return True
if sublime.platform() != 'windows':
return False
# check for attribute on windows:
try:
attrs = ctypes.windll.kernel32.GetFileAttributesW(join(path, goto, filename))
assert attrs != -1
result = bool(attrs & 2)
except (AttributeError, AssertionError):
result = False
return result
示例2: plugin_loaded
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def plugin_loaded():
"""
perform some work to set up env correctly.
"""
global global_path
global local_path
global settings
settings = sublime.load_settings(SETTINGS_FILE)
view = sublime.active_window().active_view()
if platform != "windows":
maybe_path = calculate_user_path()
if len(maybe_path) > 0:
global_path = maybe_path[0]
search_path = generate_search_path(view)
local_path = search_path
print_status(global_path, search_path)
示例3: command_version
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def command_version(command):
"""
Uses subprocess to format a given string.
"""
startupinfo = None
if platform == "windows":
# Prevent cmd.exe window from popping up
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= (
subprocess.STARTF_USESTDHANDLES | subprocess.STARTF_USESHOWWINDOW
)
startupinfo.wShowWindow = subprocess.SW_HIDE
std = subprocess.Popen(
[command, "--version"],
env=calculate_env(),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
startupinfo=startupinfo
)
out, err = std.communicate()
return out.decode("utf-8").replace("\r", ""), err
示例4: _pid_exists
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def _pid_exists(self):
if not self.pid:
return False
if sublime.platform() == "windows":
taskkill = subprocess.Popen(['C:\\Windows\\system32\\tasklist.exe', '/FI', 'PID eq %s' % self.pid, '/FO', 'CSV'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
(stdout, stderr) = taskkill.communicate()
failed = taskkill.returncode == 127 or stderr
found = str(self.pid) in CrossPlatformCodecs.force_decode(stdout)
return found or failed
else:
try:
os.kill(self.pid, 0)
except OSError as err:
if err.errno == errno.ESRCH:
return False
elif err.errno == errno.EPERM:
return True
else:
raise
else:
return True
示例5: command_variables
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def command_variables(args, view, command, format=True):
if format and args.get("format"):
command = args["format"].replace('${input}', command)
for region in view.sel():
(row,col) = view.rowcol(view.sel()[0].begin())
command = command.replace('${row}', str(row+1))
command = command.replace('${region}', view.substr(region))
break
# packages, platform, file, file_path, file_name, file_base_name,
# file_extension, folder, project, project_path, project_name,
# project_base_name, project_extension.
command = sublime.expand_variables(command, sublime.active_window().extract_variables())
return command
示例6: _get_phpunit_executable
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def _get_phpunit_executable(working_dir, include_composer_vendor_dir=True):
debug_message('find phpunit executable composer=%s', include_composer_vendor_dir)
if include_composer_vendor_dir:
if platform() == 'windows':
composer_phpunit_executable = os.path.join(working_dir, os.path.join('vendor', 'bin', 'phpunit.bat'))
debug_message(' found \'%s\' (windows)', composer_phpunit_executable)
else:
composer_phpunit_executable = os.path.join(working_dir, os.path.join('vendor', 'bin', 'phpunit'))
debug_message(' found \'%s\' (unix)', composer_phpunit_executable)
if is_file_executable(composer_phpunit_executable):
return composer_phpunit_executable
debug_message(' Warning: \'%s\' is not executable!', composer_phpunit_executable)
executable = shutil.which('phpunit')
debug_message(' found \'%s\' (global)', executable)
if executable:
return executable
else:
raise ValueError('phpunit not found')
示例7: load_stream
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def load_stream(self, package, settings):
output = settings["output"]
if not output or output == "<panel>":
output_panel = OutputPanel(
'UnitTesting', file_regex=r'File "([^"]*)", line (\d+)')
output_panel.show()
stream = output_panel
else:
if not os.path.isabs(output):
if sublime.platform() == "windows":
output = output.replace("/", "\\")
output = os.path.join(sublime.packages_path(), package, output)
if os.path.exists(output):
os.remove(output)
stream = open(output, "w")
return stream
示例8: tryHandle
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def tryHandle(self, request):
if request.name != "FocusEditor":
return False
fileName = request.arguments["File"]
line = request.arguments["Line"]
column = request.arguments["Column"]
if not os.path.isfile(fileName):
self._returnFailure("File '{}' does not exist".format(fileName), request.id)
return True
window = self._tryGetWindowFor(request.arguments["Project"])
if window:
try:
window.open_file( "{}:{}:{}".format(fileName, line, column), sublime.ENCODED_POSITION)
if sublime.platform() == "osx":
self._focusWindowOSX()
self.msgManager.sendResponse(self.interop, request.id, "Success")
return True
elif sublime.platform() == "windows":
self.msgManager.sendResponse(self.interop, request.id, "Success", {"FocusHwnd":window.hwnd()})
return True
except Exception as e:
self._returnFailure(str(e), request.id)
return True
return False
示例9: on_done
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def on_done(self, selected_index):
current_index = self._get_current_index()
if selected_index == -1 or current_index == selected_index:
return
folders = self._get_folders()
window_index = folders[selected_index][1]
window_to_move_to = sublime.windows()[window_index]
self.focus(window_to_move_to)
# OS X and Linux require specific workarounds to activate a window
# due to this bug:
# https://github.com/SublimeTextIssues/Core/issues/444
if sublime.platform() == 'osx':
self._osx_focus()
elif sublime.platform() == 'linux':
self._linux_focus(window_to_move_to)
示例10: is_hidden
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def is_hidden(self, filename, path, goto=''):
if not (path or goto): # special case for ThisPC
return False
tests = self.view.settings().get('outline_hidden_files_patterns', ['.*'])
if isinstance(tests, str):
tests = [tests]
if any(fnmatch.fnmatch(filename, pattern) for pattern in tests):
return True
if sublime.platform() != 'windows':
return False
# check for attribute on windows:
try:
attrs = ctypes.windll.kernel32.GetFileAttributesW(join(path, goto, filename))
assert attrs != -1
result = bool(attrs & 2)
except (AttributeError, AssertionError):
result = False
return result
示例11: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def run(self, edit):
# Get the buffer location in correct format for racer
row, col = self.view.rowcol(self.view.sel()[0].begin())
row += 1
results = run_racer(self.view, ["find-definition", str(row), str(col)])
if len(results) == 1:
result = results[0]
path = result.path
# On Windows the racer will return the paths without the drive
# letter and we need the letter for the open_file to work.
if sublime.platform() == 'windows' and not re.compile('^\w\:').match(path):
path = 'c:' + path
encoded_path = "{0}:{1}:{2}".format(path, result.row, result.column)
self.view.window().open_file(encoded_path, sublime.ENCODED_POSITION)
示例12: get_chrome_process
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def get_chrome_process():
user_basename = os.path.basename(get_chrome_path())
is_linux_chrome = sublime.platform() == 'linux' and user_basename != 'chromium-browser'
try:
basenames_to_check = (['chrome', 'google-chrome'] if is_linux_chrome else [user_basename])
for process in psutil.process_iter(attrs=['exe', 'status']):
basename_matches = ('exe' in process.info and process.info['exe'] is not None and
os.path.basename(process.info['exe']) in basenames_to_check)
is_zombie = 'status' in process.info and process.info['status'] == 'zombie'
if basename_matches and not is_zombie:
return process
except Exception as e:
global zombie_message_shown
if not zombie_message_shown:
sublime.error_message("You may have a zombie Chrome Process. If Chrome won't start, try killing it or restarting your machine")
zombie_message_shown = True
return None
示例13: ride_env
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def ride_env(self):
env = os.environ.copy()
paths = self.get("additional_paths", [])
if sublime.platform() == "osx" and os.path.isdir("/Library/TeX/texbin"):
paths += ["/Library/TeX/texbin"]
if paths:
sep = ";" if sublime.platform() == "windows" else ":"
env["PATH"] = sep.join(paths) + sep + env["PATH"]
lang = self.get("lang", None)
if lang:
env["LANG"] = lang
elif "LANG" not in env:
env["LANG"] = "en_US.UTF-8"
return env
示例14: subl
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def subl(*args):
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] + list(args))
def on_activated():
window = sublime.active_window()
view = window.active_view()
if sublime.platform() == 'windows':
# fix focus on windows
window.run_command('focus_neighboring_group')
window.focus_view(view)
sublime_plugin.on_activated(view.id())
sublime.set_timeout_async(lambda: sublime_plugin.on_activated_async(view.id()))
sublime.set_timeout(on_activated, 300)
示例15: get_tabnine_path
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import platform [as 别名]
def get_tabnine_path(binary_dir):
def join_path(*args):
return os.path.join(binary_dir, *args)
translation = {
("linux", "x32"): "i686-unknown-linux-musl/TabNine",
("linux", "x64"): "x86_64-unknown-linux-musl/TabNine",
("osx", "x32"): "i686-apple-darwin/TabNine",
("osx", "x64"): "x86_64-apple-darwin/TabNine",
("windows", "x32"): "i686-pc-windows-gnu/TabNine.exe",
("windows", "x64"): "x86_64-pc-windows-gnu/TabNine.exe",
}
versions = os.listdir(binary_dir)
versions.sort(key=parse_semver, reverse=True)
for version in versions:
key = sublime.platform(), sublime.arch()
path = join_path(version, translation[key])
if os.path.isfile(path):
add_execute_permission(path)
print("TabNine: starting version", version)
return path