本文整理汇总了Python中sublime.version函数的典型用法代码示例。如果您正苦于以下问题:Python version函数的具体用法?Python version怎么用?Python version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了version函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: check_dependencies
def check_dependencies():
if sublime.version() > "3000" and 'Package Control' in sys.modules:
package_control = sys.modules['Package Control'].package_control
elif sublime.version() < "3000" and 'package_control' in sys.modules:
package_control = sys.modules['package_control']
else:
sublime.set_timeout(check_dependencies, 20)
return
manager = package_control.package_manager.PackageManager()
required_dependencies = set(manager.find_required_dependencies())
class myPackageCleanup(package_control.package_cleanup.PackageCleanup):
def finish(self, installed_packages, found_packages, found_dependencies):
missing_dependencies = required_dependencies - set(found_dependencies)
if len(missing_dependencies) == 0:
touch("success")
kill_subl()
else:
sublime.set_timeout(_check_dependencies, 20)
def _check_dependencies():
myPackageCleanup().run()
_check_dependencies()
开发者ID:randy3k,项目名称:sublime_text_installer,代码行数:26,代码来源:helper.py
示例2: __init__
def __init__(self, view, syntax=None):
self.platform = sublime.platform()
self.classmap = {}
self.st_version = 2
if sublime.version() == '' or int(sublime.version()) > 3000:
self.st_version = 3
self.file_name = view.file_name()
self.settings = sublime.load_settings('CodeFormatter.sublime-settings')
self.packages_path = sublime.packages_path()
self.syntax_file = view.settings().get('syntax')
self.syntax = syntax or self.get_syntax()
# map of settings names with related class
map_settings_formatter = [
('codeformatter_php_options', PhpFormatter),
('codeformatter_js_options', JsFormatter),
('codeformatter_css_options', CssFormatter),
('codeformatter_html_options', HtmlFormatter),
('codeformatter_python_options', PyFormatter),
('codeformatter_vbscript_options', VbscriptFormatter),
('codeformatter_scss_options', ScssFormatter),
('codeformatter_coldfusion_options', ColdfusionFormatter),
]
for name, _class in map_settings_formatter:
syntaxes = self.settings.get(name, {}).get('syntaxes')
if not syntaxes or not isinstance(syntaxes, str):
continue
for _formatter in syntaxes.split(','):
self.classmap[_formatter.strip()] = _class
开发者ID:akalongman,项目名称:sublimetext-codeformatter,代码行数:33,代码来源:formatter.py
示例3: is_compatible_version
def is_compatible_version(version_range):
min_version = float("-inf")
max_version = float("inf")
if version_range == '*':
return True
gt_match = re.match('>(\d+)$', version_range)
ge_match = re.match('>=(\d+)$', version_range)
lt_match = re.match('<(\d+)$', version_range)
le_match = re.match('<=(\d+)$', version_range)
range_match = re.match('(\d+) - (\d+)$', version_range)
if gt_match:
min_version = int(gt_match.group(1)) + 1
elif ge_match:
min_version = int(ge_match.group(1))
elif lt_match:
max_version = int(lt_match.group(1)) - 1
elif le_match:
max_version = int(le_match.group(1))
elif range_match:
min_version = int(range_match.group(1))
max_version = int(range_match.group(2))
else:
return None
if min_version > int(sublime.version()):
return False
if max_version < int(sublime.version()):
return False
return True
开发者ID:sue-su,项目名称:package_control,代码行数:33,代码来源:release_selector.py
示例4: __init__
def __init__(self, view=False, file_name=False, syntax=False):
self.platform = sublime.platform()
self.classmap = {
"php": PhpFormatter,
"javascript": JsFormatter,
"json": JsFormatter,
"html": HtmlFormatter,
"asp": HtmlFormatter,
"xml": HtmlFormatter,
"css": CssFormatter,
"less": CssFormatter,
"python": PyFormatter,
}
self.st_version = 2
if sublime.version() == "" or int(sublime.version()) > 3000:
self.st_version = 3
self.syntax_file = view.settings().get("syntax")
if syntax == False:
self.syntax = self.getSyntax()
else:
self.syntax = syntax
self.file_name = file_name
self.settings = sublime.load_settings("CodeFormatter.sublime-settings")
self.packages_path = sublime.packages_path()
开发者ID:XxLinkxX,项目名称:Sublime-Text-3,代码行数:26,代码来源:formatter.py
示例5: run
def run(self, package_name, source, items):
# Reload current file first if not in root dir
if os.path.dirname(source):
if sublime.version()[0] == "3":
modulename = package_name + "." + (source.replace(os.sep, ".")[:-3] if source[-11:] != "__init__.py" else source.replace(os.sep, ".")[:-12])
else:
modulename = os.path.join(package_dir, source)
# Reload the file
sublime_plugin.reload_plugin(modulename)
print("Package Reloader - Reloading %s" % package_name)
# Load modules
for item in items:
if sublime.version()[0] == "3":
modulename = package_name + "." + (item.replace("/", ".")[:-3] if item[-11:] != "__init__.py" else item.replace("/", ".")[:-12])
else:
modulename = os.path.join(package_dir, item)
sublime_plugin.reload_plugin(modulename)
# Clean up multiple callbacks
for key, value in sublime_plugin.all_callbacks.items():
items = {}
for item in value:
name = item.__module__ + '.' + item.__class__.__name__
# Save item connected with the name
if name in items:
items[name] += [item]
else:
items[name] = [item]
sublime_plugin.all_callbacks[key] = [value[0] for key, value in items.items()]
开发者ID:csch0,项目名称:SublimeText-Package-Reloader,代码行数:35,代码来源:Package+Reloader.py
示例6: backup_with_prompt_on_done
def backup_with_prompt_on_done(path):
global prompt_parameters
if os.path.exists(path) == True:
if sublime.version()[0] == "2":
if sublime.ok_cancel_dialog(
"Backup already exists @ %s \nReplace it?" % path, "Continue") == True:
prompt_parameters["operation_to_perform"](path)
else:
tools.packagesync_cancelled()
else:
confirm_override = sublime.yes_no_cancel_dialog(
"Backup already exists @ %s \nReplace it?" % path, "Continue")
if confirm_override == sublime.DIALOG_YES:
prompt_parameters["operation_to_perform"](path)
elif sublime.version()[0] == "3" and confirm_override == sublime.DIALOG_NO:
prompt_parameters["initial_text"] = path
prompt_for_location()
else:
tools.packagesync_cancelled()
elif os.path.isabs(os.path.dirname(path)) == True:
prompt_parameters["operation_to_perform"](path)
else:
sublime.error_message("Please provide a valid path for backup.")
prompt_parameters["initial_text"] = path
prompt_for_location()
开发者ID:utkarsh9891,项目名称:PackageSync,代码行数:31,代码来源:offline.py
示例7: get_gutter_mark
def get_gutter_mark(self):
"""
Returns gutter mark icon or empty string if marks are disabled.
"""
# ST does not expect platform specific paths here, but only
# forward-slash separated paths relative to "Packages"
self.gutter_mark_success = '/'.join(
[settings.mark_themes_dir, 'success']
)
if int(sublime.version()) >= 3014:
self.gutter_mark_success += '.png'
self.gutter_mark = ''
mark_type = settings.gutter_marks
if mark_type in ('dot', 'circle', 'bookmark', 'cross'):
self.gutter_mark = mark_type
elif mark_type.startswith('theme-'):
theme = mark_type[6:]
if theme not in ('alpha', 'bright', 'dark', 'hard', 'simple'):
log("unknown gutter mark theme: '{0}'".format(mark_type))
return
# ST does not expect platform specific paths here, but only
# forward-slash separated paths relative to "Packages"
self.gutter_mark = '/'.join(
[settings.mark_themes_dir, '{0}-{{0}}'.format(theme)]
)
if int(sublime.version()) >= 3014:
self.gutter_mark += '.png'
开发者ID:adams-sarah,项目名称:Flake8Lint,代码行数:30,代码来源:Flake8Lint.py
示例8: __init__
def __init__(self, view=False, file_name=False, syntax=False):
self.platform = sublime.platform()
self.classmap = {
'php': PhpFormatter,
'javascript': JsFormatter,
'json': JsFormatter,
'html': HtmlFormatter,
'asp': HtmlFormatter,
'xml': HtmlFormatter,
'css': CssFormatter,
'less': CssFormatter,
'python': PyFormatter
}
self.st_version = 2
if sublime.version() == '' or int(sublime.version()) > 3000:
self.st_version = 3
self.syntax_file = view.settings().get('syntax')
if syntax == False:
self.syntax = self.getSyntax()
else:
self.syntax = syntax
self.file_name = file_name
self.settings = sublime.load_settings('CodeFormatter.sublime-settings')
self.packages_path = sublime.packages_path()
开发者ID:AnatoliyLitinskiy,项目名称:sublimetext-codeformatter,代码行数:26,代码来源:formatter.py
示例9: __init__
def __init__(self, view=False, file_name=False, syntax=False, saving=False):
self.platform = sublime.platform()
self.classmap = {}
self.st_version = 2
if sublime.version() == "" or int(sublime.version()) > 3000:
self.st_version = 3
self.file_name = file_name
self.settings = sublime.load_settings("CodeFormatter.sublime-settings")
self.packages_path = sublime.packages_path()
self.syntax_file = view.settings().get("syntax")
if syntax == False:
self.syntax = self.getSyntax()
else:
self.syntax = syntax
self.saving = saving
# PHP
opts = self.settings.get("codeformatter_php_options")
if "syntaxes" in opts and opts["syntaxes"]:
for _formatter in opts["syntaxes"].split(","):
self.classmap[_formatter.strip()] = PhpFormatter
# Javascript
opts = self.settings.get("codeformatter_js_options")
if "syntaxes" in opts and opts["syntaxes"]:
for _formatter in opts["syntaxes"].split(","):
self.classmap[_formatter.strip()] = JsFormatter
# CSS
opts = self.settings.get("codeformatter_css_options")
if "syntaxes" in opts and opts["syntaxes"]:
for _formatter in opts["syntaxes"].split(","):
self.classmap[_formatter.strip()] = CssFormatter
# HTML
opts = self.settings.get("codeformatter_html_options")
if "syntaxes" in opts and opts["syntaxes"]:
for _formatter in opts["syntaxes"].split(","):
self.classmap[_formatter.strip()] = HtmlFormatter
# Python
opts = self.settings.get("codeformatter_python_options")
if "syntaxes" in opts and opts["syntaxes"]:
for _formatter in opts["syntaxes"].split(","):
self.classmap[_formatter.strip()] = PyFormatter
# VBScript
opts = self.settings.get("codeformatter_vbscript_options")
if "syntaxes" in opts and opts["syntaxes"]:
for _formatter in opts["syntaxes"].split(","):
self.classmap[_formatter.strip()] = VbscriptFormatter
# SCSS
opts = self.settings.get("codeformatter_scss_options")
if "syntaxes" in opts and opts["syntaxes"]:
for _formatter in opts["syntaxes"].split(","):
self.classmap[_formatter.strip()] = PyFormatter
开发者ID:jakebathman,项目名称:sublimetext-codeformatter,代码行数:60,代码来源:formatter.py
示例10: __init__
def __init__(self):
if not hasattr(self, "setting") is None:
self.setting = {}
if platform.system() == 'Windows':
self.dirSep = "\\"
else:
self.dirSep = '/'
self.setting['file_path'] = self.dirSep + "User" + self.dirSep + "memTask.json"
self.stopTimer = True
self.fileName = False
self.fileView = False
self.totalTime = {
'fromLastCommit': 0
}
self.finish = False
if not sublime.version() or int(sublime.version()) > 3000:
# Sublime Text 3
timeout = 1000
else:
timeout = 0
sublime.set_timeout(lambda: self.finish_init(), timeout)
开发者ID:profmugshot,项目名称:memTask,代码行数:25,代码来源:memTask.py
示例11: run
def run(self, edit):
if int(sublime.version()) >= 3000:
org_sel = list(self.view.sel())
for region in self.view.sel():
expand_selection_around(self.view, region, r'(".*?"|\'.*?\'|:\w+)')
for region in self.view.sel():
if region.size() == 0:
continue
selected = self.view.substr(region)
if selected[0] == '"':
inner = selected[1:-1]
replace = ":" + inner
elif selected[0] == "'":
inner = selected[1:-1]
replace = ":" + inner
elif selected[0] == ":":
inner = selected[1:]
replace = '"' + inner + '"'
else:
return
self.view.replace(edit, region, replace)
if int(sublime.version()) >= 3000:
self.view.sel().clear()
self.view.sel().add_all(org_sel)
开发者ID:kieranklaassen,项目名称:SublimeRubyToggleString,代码行数:27,代码来源:RubyToggleString.py
示例12: run
def run(self):
self.window.run_command('hide_panel');
if int(sublime.version()) >= 2136:
self.window.run_command("show_panel", {"panel": "find_in_files", "where":"<open folders>"})
elif int(sublime.version()) >= 2134:
self.window.run_command("show_panel", {"panel": "find_in_files", "where":""})
else:
self.window.run_command("show_panel", {"panel": "find_in_files", "location":"<open folders>"})
开发者ID:aokolovskis,项目名称:config,代码行数:8,代码来源:SideBar.py
示例13: __init__
def __init__(me, cmd, env, listener, path="", shell=False):
threading.Thread.__init__(me, name="cssondiet")
me.finished = False
me.exitcode = 0
me.listener = listener
output = None
try:
idx = cmd.index("-o")
output = cmd[idx+1]
except:
output = False
minify = "-m" in cmd
inputfile = cmd[-1]
if output == False or output == inputfile:
output = inputfile+".css"
class an_argument(object):
def __init__(me, input, output="-", minify=False ):
me.cod_files = [ input ]
me.output = output
me.no_comments = False
me.no_header = False
me.minify_css = minify
me.args = an_argument( inputfile, output, minify )
print("Actually running embedded COD script with inputfile=%s, " \
"output=%s, minify=%s from %s package\n" % \
( inputfile, output, str(minify), PACKAGeDIR) )
me.start_time = time.time()
try:
if sublime.version()[0] == "2":
script_dir = os.path.join( sublime.packages_path(), PACKAGeDIR )
#me.read_stderr("script_dir: %s\n" % script_dir )
fp, pathname, description = imp.find_module("cod", [ script_dir ] )
try:
me.cod_module = imp.load_module("cod", fp, pathname, description)
finally:
if fp:
fp.close()
elif sublime.version()[0] == "3":
sublimemodule = __import__("CSS-On-Diet")
me.cod_module = sublimemodule.cod
except ImportError:
me.read_stderr("[Error loading embedded COD preprocessor]\n")
me.finished = True
if me.listener:
me.listener.on_finished(me)
return
me.start()
开发者ID:wyderkat,项目名称:css-on-diet--sublime-text,代码行数:58,代码来源:exec_and_embedded_cod.py
示例14: get_pygments
def get_pygments(style):
"""
Get pygments style.
Subllime CSS support is limited. It cannot handle well
things like: `.class1 .class2`, but it can handle things like:
`.class1.class2`. So we will not use things like `.highlight` in front.
We will first find {...} which has no syntax class. This will contain
our background and possibly foreground. If for whatever reason we
have no background or foreground, we will use `#000000` or `#ffffff`
respectively.
"""
try:
# Lets see if we can find the pygments theme
text = HtmlFormatter(style=style).get_style_defs(".dummy")
text = re_missing_semi_colon.sub("; }", text)
except Exception:
return ""
bg = None
fg = None
# Find {...} which has no syntax classes
m = re_base_colors.search(text)
if m:
# Find background
m1 = re_bgcolor.search(m.group(1))
if m1:
# Use `background-color` as it works better
# with Sublime CSS
bg = m1.group(1).replace("background", "background-color")
# Find foreground
m1 = re_color.search(m.group(1))
if m1:
fg = m1.group(1)
# Use defaults if None found
if bg is None:
bg = "background-color: #ffffff"
if fg is None:
fg = "color: #000000"
# Reassemble replacing .highlight {...} with .codehilite, .inlinehilite {...}
# All other classes will be left bare with only their syntax class.
code_blocks = CODE_BLOCKS_LEGACY if int(sublime.version()) < 3119 else CODE_BLOCKS
if m:
css = clean_css((text[: m.start(0)] + (code_blocks % (bg, fg)) + text[m.end(0) :] + "\n"))
else:
css = clean_css(((code_blocks % (bg, fg)) + "\n" + text + "\n"))
if int(sublime.version()) < 3119:
return css.replace(".dummy ", "")
else:
return re_pygments_selectors.sub(r".mdpopups .highlight \1, .mdpopups .inline-highlight \1", css)
开发者ID:Chanmoro,项目名称:sublime-text-setting,代码行数:55,代码来源:st_scheme_template.py
示例15: run
def run(self, edit):
view = self.view
window = sublime.active_window()
if(int(sublime.version()) >= 3000):
# ST3 - use project data
project_data = window.project_data()
utils = _projectPHPClassUtils( project_data.get('folders')[0].get('path') )
else:
utils = _projectPHPClassUtils( window.folders()[0] )
if( utils.is_browser_view(view) != True ):
return
point = view.sel()[0]
if(point.begin() == point.end()):
return
window.focus_view(view)
word = view.substr(view.word(point))
line = view.substr(view.line(point))
methodname = None
if( line.startswith('\t') or re.match('\s+', line, re.IGNORECASE) ):
methodname = word
regionbefore = sublime.Region(0,point.end())
lineregions = view.split_by_newlines(regionbefore)
clindex = len( lineregions ) - 1
# for lineregion in lineregions:
classname = None
while( classname == None and clindex >= 0 ):
line = view.substr(lineregions[clindex])
clindex -= 1
if(line.startswith('\t') == False and not re.match('\s+', line, re.IGNORECASE) ):
classname = line
else:
classname = word
classname = classname.split('\n')[0].strip()
if(len(classname)>0):
try:
if(utils.get_num_panels() == 2):
if(view.name() == 'PHP Class Methods'):
# in methods view. open file definition
self._open_file_definition(window, utils, classname, methodname)
else:
# in classes view. update methods view
methodview = utils.find_methods_view()
rootPath = window.folders()[0]
if(int(sublime.version()) >= 3000):
project_data = window.project_data()
rootPath = project_data.get('folders')[0].get('path')
args = {"rootPath" : rootPath, "group": 2, "classname": classname}
methodview.run_command("fill_browser_view", { "args": args })
else:
# all in one... go, go, go!
self._open_file_definition(window, utils, classname, methodname)
except:
sublime.status_message('Unknown Class Name: '+str(classname))
开发者ID:degami,项目名称:ProjectPHPClassBrowser,代码行数:54,代码来源:ProjectPHPClassBrowser.py
示例16: is_visible
def is_visible(self):
st_version = 2
# Warn about out-dated versions of ST3
if sublime.version() == '':
st_version = 3
print('Package Control: Please upgrade to Sublime Text 3 build 3012 or newer')
elif int(sublime.version()) > 3000:
st_version = 3
if st_version == 3 :
return False
return True
开发者ID:gcodillo,项目名称:composer-sublime,代码行数:15,代码来源:composer.py
示例17: 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
示例18: _on_done
def _on_done():
buf = StringIO()
for item in results:
tabulate(item, output=buf)
new_view = sublime.active_window().new_file()
new_view.set_scratch(True)
new_view.settings().set('word_wrap', False)
new_view.settings().set('line_numbers', False)
new_view.settings().set('gutter', False)
new_view.set_name('LaTeXTools System Check')
if sublime.version() < '3103':
new_view.settings().set(
'syntax',
'Packages/LaTeXTools/system_check.hidden-tmLanguage'
)
else:
new_view.settings().set(
'syntax', 'Packages/LaTeXTools/system_check.sublime-syntax'
)
new_view.set_encoding('UTF-8')
new_view.run_command(
'latextools_insert_text',
{'text': buf.getvalue().rstrip()}
)
new_view.set_read_only(True)
buf.close()
开发者ID:SublimeText,项目名称:LaTeXTools,代码行数:31,代码来源:system_check.py
示例19: list_packages
def list_packages(self, unpacked_only=False):
"""
:param unpacked_only:
Only list packages that are not inside of .sublime-package files
:return: A list of all installed, non-default, package names
"""
package_names = os.listdir(sublime.packages_path())
package_names = [path for path in package_names if
os.path.isdir(os.path.join(sublime.packages_path(), path))]
if int(sublime.version()) > 3000 and unpacked_only == False:
package_files = os.listdir(sublime.installed_packages_path())
package_names += [f.replace('.sublime-package', '') for f in package_files if re.search('\.sublime-package$', f) != None]
# Ignore things to be deleted
ignored = ['User']
for package in package_names:
cleanup_file = os.path.join(sublime.packages_path(), package,
'package-control.cleanup')
if os.path.exists(cleanup_file):
ignored.append(package)
packages = list(set(package_names) - set(ignored) -
set(self.list_default_packages()))
packages = sorted(packages, key=lambda s: s.lower())
return packages
开发者ID:zhjuncai,项目名称:sublime3-sync,代码行数:29,代码来源:package_manager.py
示例20: run_shell_command
def run_shell_command(self, command, working_dir):
if not command:
return False
if BEFORE_CALLBACK:
os.system(BEFORE_CALLBACK)
if AFTER_CALLBACK:
command += " ; " + AFTER_CALLBACK
self.save_test_run(command, working_dir)
if COMMAND_PREFIX:
command = COMMAND_PREFIX + ' ' + command
if int(sublime.version().split('.')[0]) <= 2:
command = [command]
if USE_TERMINAL:
trm=OpenInTerminal()
trm.run(working_dir, command)
else:
self.view.window().run_command("exec", {
"cmd": command,
"shell": True,
"working_dir": working_dir,
"file_regex": r"([^ ]*\.rb):?(\d*)",
"encoding": TERMINAL_ENCODING
})
self.display_results()
return True
开发者ID:foton,项目名称:sublime-text-2-ruby-tests,代码行数:25,代码来源:run_ruby_test.py
注:本文中的sublime.version函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论