本文整理汇总了Python中sublime.version函数的典型用法代码示例。如果您正苦于以下问题:Python version函数的具体用法?Python version怎么用?Python version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了version函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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
示例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
示例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()
示例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()]
示例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()
示例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'
示例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()
示例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
示例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)
示例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)
示例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>"})
示例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()
示例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)
示例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))