本文整理汇总了Python中sublime.load_binary_resource函数的典型用法代码示例。如果您正苦于以下问题:Python load_binary_resource函数的具体用法?Python load_binary_resource怎么用?Python load_binary_resource使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_binary_resource函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: update_binary
def update_binary():
pkgpath = os.path.join(sublime.installed_packages_path(), 'InputHelper.sublime-package')
srcdir = os.path.join(sublime.packages_path(), 'InputHelper', 'lib')
srcpath = os.path.join(srcdir, binname)
srcdb = os.path.join(srcdir, dbname)
bindir = os.path.join(sublime.packages_path(), usrbin)
binpath = os.path.join(bindir, binname)
bindb = os.path.join(bindir, dbname)
resdir = 'Packages/InputHelper/lib/'
resbin = resdir + binname
resdb = resdir + dbname
bininfo = None
bindata = None
dbdata = None
if os.path.exists(binpath):
bininfo = os.stat(binpath)
elif not os.path.exists(bindir):
os.makedirs(bindir, 0o755)
if not os.path.exists(bindb):
if os.path.exists(srcdb):
with open(srcdb, 'rb') as srcfile:
dbdata = srcfile.read()
srcfile.close
elif st_version == 3 and os.path.exists(pkgpath):
dbdata = sublime.load_binary_resource(resdb)
if dbdata != None:
print("* Creating " + bindb)
with open(bindb, 'wb') as dbfile:
dbfile.write(dbdata)
dbfile.close()
if os.path.exists(srcpath):
srcinfo = os.stat(srcpath)
if bininfo == None or bininfo[ST_MTIME] < srcinfo[ST_MTIME]:
with open(srcpath, 'rb') as srcfile:
bindata = srcfile.read()
srcfile.close()
elif st_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(resbin)
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:fengyexia,项目名称:InputHelper,代码行数:53,代码来源:inputhelper.py
示例2: __init__
def __init__(self, scheme_file, color_filter=None):
"""Initialize."""
if color_filter is None:
color_filter = self.filter
self.legacy = not scheme_file.lower().endswith('.sublime-color-scheme')
self.color_scheme = path.normpath(scheme_file)
self.scheme_file = path.basename(self.color_scheme)
if self.legacy:
self.scheme_obj = color_filter(
readPlistFromBytes(
re.sub(
br"^[\r\n\s]*<!--[\s\S]*?-->[\s\r\n]*|<!--[\s\S]*?-->", b'',
sublime.load_binary_resource(sublime_format_path(self.color_scheme))
)
)
)
else:
sublime.decode_value(
sublime.load_resource(sublime_format_path(self.color_scheme)),
preserve_lines=True
)
self.scheme_file = scheme_file
self.matched = {}
self.variables = {}
self.parse_scheme()
开发者ID:arnedesmedt,项目名称:dotfiles,代码行数:26,代码来源:st_color_scheme_matcher.py
示例3: update_resource
def update_resource(binname):
# from https://github.com/weslly/ColorPicker/blob/master/sublimecp.py=
targetdir = os.path.join(sublime.packages_path(), 'User', 'R-Box', 'bin')
targetpath = os.path.join(targetdir, binname)
respath = 'Packages/R-Box/bin/' + binname
pkgpath = os.path.join(sublime.installed_packages_path(), 'R-Box.sublime-package')
unpkgpath = os.path.join(sublime.packages_path(), 'R-Box', 'bin', binname)
if os.path.exists(targetpath):
targetinfo = os.stat(targetpath)
else:
if not os.path.exists(targetdir):
os.makedirs(targetdir, 0o755)
targetinfo = None
if os.path.exists(unpkgpath):
pkginfo = os.stat(unpkgpath)
elif os.path.exists(pkgpath):
pkginfo = os.stat(pkgpath)
else:
return
if targetinfo == None or targetinfo.st_mtime < pkginfo.st_mtime:
data = sublime.load_binary_resource(respath)
print("* Updating " + targetpath)
with open(targetpath, 'wb') as binfile:
binfile.write(data)
binfile.close()
if not os.access(targetpath, os.X_OK):
os.chmod(targetpath, 0o755)
开发者ID:jameshliang,项目名称:R-Box,代码行数:31,代码来源:misc.py
示例4: 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
示例5: set_language
def set_language(lang):
if not lang:
return
PACKAGES_PATH = sublime.packages_path()
DEFAULT_PATH = os.path.join(PACKAGES_PATH, "Default")
SYN_PATH = os.path.join(DEFAULT_PATH, "Syntax.sublime-menu")
if os.path.isfile(SYN_PATH):
with open(SYN_PATH, "rb") as f:
syntax = f.read()
m = md5()
m.update(syntax)
if m.hexdigest() == LANGS[lang]['syntax_md5sum']:
sublime.status_message("%s has loaded." % lang)
return
# mkdir if Default not exist
if not os.path.isdir(DEFAULT_PATH):
os.mkdir(DEFAULT_PATH)
# Load binary resource
PACKAGE_NAME = os.path.basename(os.path.dirname(__file__)).split('.')[0]
LOCALZIP_RES = "Packages/{}/{}".format(PACKAGE_NAME,
LANGS[lang]['zipfile'])
lang_bytes = sublime.load_binary_resource(LOCALZIP_RES)
# write to tempfile and unzip it.
import zipfile
from tempfile import NamedTemporaryFile
tmp_file = NamedTemporaryFile(delete=False)
tmp_file.write(lang_bytes)
tmp_file.close()
with zipfile.ZipFile(tmp_file.name, "r") as f:
f.extractall(DEFAULT_PATH)
tmp_file.close()
os.unlink(tmp_file.name)
开发者ID:HeyRoy,项目名称:Chinese-Localization,代码行数:33,代码来源:Localization.py
示例6: startup
def startup(self):
"""
Check and extract helper files
@param on_done: callback after loaded
"""
helpers = sublime.find_resources("JavatarAutocompleteHelper.jar")
installed = False
for helper in helpers:
if helper[:9] == "Packages/":
helper = os.path.join(sublime.packages_path(), helper[9:])
if os.path.exists(helper) and self.verify_helper(helper):
installed = True
break
if not installed:
Logger().info("Updating helper files...")
file_path = os.path.join(
sublime.packages_path(),
"User",
"Javatar",
"Helper",
"JavatarAutocompleteHelper.jar"
)
if os.path.exists(file_path):
os.remove(file_path)
if not os.path.isdir(os.path.dirname(file_path)):
try:
os.makedirs(os.path.dirname(file_path))
except:
pass
helper_file = open(file_path, "wb")
helper_file.write(sublime.load_binary_resource(
"Packages/Javatar/binary/JavatarAutocompleteHelper.jar"
))
helper_file.close()
开发者ID:Pugio,项目名称:Javatar,代码行数:35,代码来源:helper_service.py
示例7: __init__
def __init__(self, scheme_file, color_filter=None):
"""Initialize."""
if color_filter is None:
color_filter = self.filter
self.color_scheme = scheme_file.replace('\\', '/')
self.scheme_file = path.basename(self.color_scheme)
if NEW_SCHEMES and scheme_file.endswith(('.sublime-color-scheme', '.hidden-color-scheme')):
self.legacy = False
self.scheme_obj = {
'variables': {},
GLOBAL_OPTIONS: {},
'rules': []
}
else:
try:
content = sublime.load_binary_resource(sublime_format_path(self.color_scheme))
except IOError:
# Fallback if file was created manually and not yet found in resources
with open(packages_path(self.color_scheme), 'rb') as f:
content = f.read()
self.legacy = True
self.convert_format(readPlistFromBytes(XML_COMMENT_RE.sub(b'', content)))
self.overrides = []
if NEW_SCHEMES:
self.merge_overrides()
self.scheme_file = scheme_file
self.matched = {}
self.variables = {}
self.parse_scheme()
self.scheme_obj = color_filter(self.scheme_obj)
self.setup_matcher()
开发者ID:PwnArt1st,项目名称:dotfiles,代码行数:32,代码来源:color_scheme_matcher.py
示例8: update_resources
def update_resources(*target):
targetpath = os.path.join(sublime.packages_path(), 'User', PKGNAME, *target)
targetdir = os.path.dirname(targetpath)
respath = 'Packages/%s/' % PKGNAME + "/".join(target)
pkgpath = os.path.join(sublime.installed_packages_path(), '%s.sublime-package' % PKGNAME)
unpkgpath = os.path.join(sublime.packages_path(), PKGNAME, *target)
if os.path.exists(targetpath):
targetinfo = os.stat(targetpath)
else:
if not os.path.exists(targetdir):
os.makedirs(targetdir, 0o755)
targetinfo = None
if os.path.exists(unpkgpath):
pkginfo = os.stat(unpkgpath)
elif os.path.exists(pkgpath):
pkginfo = os.stat(pkgpath)
else:
return
if targetinfo is None or targetinfo.st_mtime < pkginfo.st_mtime:
print("* Updating " + targetpath)
if sublime.version() < '3000':
shutil.copy2(unpkgpath, targetpath)
else:
data = sublime.load_binary_resource(respath)
with open(targetpath, 'wb') as f:
f.write(data)
f.close()
if not os.access(targetpath, os.X_OK):
os.chmod(targetpath, 0o755)
开发者ID:pkmital,项目名称:SendTextPlus,代码行数:33,代码来源:update_resources.py
示例9: 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
示例10: edit_plist_color_scheme
def edit_plist_color_scheme(original_color_scheme):
scheme_data = plistlib.readPlistFromBytes(sublime.load_binary_resource(original_color_scheme))
if os.path.exists(sublime.packages_path() + "/MCC/ModifiedColorSchemes/" + scheme_data["name"] + ".tmTheme"):
sublime.load_settings("Preferences.sublime-settings").set("color_scheme", "Packages/MCC/ModifiedColorSchemes/" + scheme_data["name"] + ".tmTheme")
sublime.save_settings("Preferences.sublime-settings")
return
elif scheme_data["name"].find("(MCC)") > -1:
return
try:
new_background_rgb = "#000000"
if "background" in scheme_data["settings"][0]["settings"]:
new_background_rgb = ColorSchemeEditor.change_color_by_one(scheme_data["settings"][0]["settings"]["background"])
scheme_data = ColorSchemeEditor.add_mcc_scopes(scheme_data, False, new_background_rgb)
if not os.path.exists(sublime.packages_path() + "/MCC/ModifiedColorSchemes/"):
os.makedirs(sublime.packages_path() + "/MCC/ModifiedColorSchemes/")
new_file_name = "/MCC/ModifiedColorSchemes/" + scheme_data["name"] + ".tmTheme"
scheme_data["name"] = scheme_data["name"] + " (MCC)"
plistlib.writePlist(scheme_data, sublime.packages_path() + new_file_name)
sublime.load_settings("Preferences.sublime-settings").set("color_scheme", "Packages" + new_file_name)
sublime.save_settings("Preferences.sublime-settings")
except Exception as e:
# sublime.error_message("MCC couldn't convert your current color scheme")
print("Error on tmTheme conversion")
print(e)
sublime.active_window().run_command("show_panel", {"panel": "console", "toggle": True})
开发者ID:42iscool42,项目名称:MCC,代码行数:30,代码来源:ColorSchemeEditor.py
示例11: run
def run(self):
# Wait for _corona_utils initialization to complete
# print("Waiting for InitializedEvent...")
_corona_utils.InitializedEvent.wait()
self._snippets_dir = os.path.join(_corona_utils.PACKAGE_USER_DIR, "Snippets")
if not os.path.exists(self._snippets_dir):
os.makedirs(self._snippets_dir)
print(_corona_utils.PACKAGE_NAME + ": Extracting snippets ...")
try:
# In ST3 our ZIP file is not on the filesystem, it's in our package so we have to extract
# it and unzip from there (to work on Windows the temp file must be closed before it can
# be reopened to be unzipped)
zip_bytes = sublime.load_binary_resource(_corona_utils.ST_PACKAGE_PATH + "snippets.zip")
with tempfile.NamedTemporaryFile(suffix = ".zip", delete=False) as tempzip:
tempzip.write(zip_bytes)
tempzip.close()
UnZIPToDir(tempzip.name, self._snippets_dir)
os.remove(tempzip.name)
except:
# We're on ST2 and the ZIP file is just a file in our package directory
UnZIPToDir(os.path.join(_corona_utils.PACKAGE_DIR, "snippets.zip"), self._snippets_dir)
snippetMenuArray = []
snippetJSON = ""
if os.path.isdir(self._snippets_dir):
snippetMenuArray = self.addDirectory(self._snippets_dir)
snippetJSON = json.dumps(snippetMenuArray, indent=4, separators=(',', ': '))
if snippetJSON == "":
print(_corona_utils.PACKAGE_NAME + ": Failed to build Snippets menu")
return
# Put our menu into the Main.sublime-menu.template file
menus = ""
if _corona_utils.SUBLIME_VERSION < 3000:
with open(os.path.join(_corona_utils.PACKAGE_DIR, "Main.sublime-menu.template"), "r") as fd:
menus = fd.read()
else:
menus = sublime.load_resource(_corona_utils.ST_PACKAGE_PATH + "Main.sublime-menu.template")
if menus == "":
print(_corona_utils.PACKAGE_NAME + ": Failed to create Snippets menu")
return
menus = menus.replace("$corona_snippets", snippetJSON)
if not os.path.exists(_corona_utils.PACKAGE_DIR):
os.makedirs(_corona_utils.PACKAGE_DIR)
if _corona_utils.SUBLIME_VERSION < 3000:
with open(os.path.join(_corona_utils.PACKAGE_DIR, "Main.sublime-menu"), "w") as fd:
fd.write("// Generated file - do not edit - modify 'Main.sublime-menu.template' instead\n")
fd.write(menus)
else: # ST3/P3
with open(os.path.join(_corona_utils.PACKAGE_DIR, "Main.sublime-menu"), "w", encoding='utf-8') as fd:
fd.write("// Generated file - do not edit - modify 'Main.sublime-menu.template' instead\n")
fd.write(menus)
开发者ID:avenauche,项目名称:CoronaSDK-SublimeText,代码行数:60,代码来源:snippets.py
示例12: parse_scheme
def parse_scheme(self):
HaxeColorScheme.styles = None
HaxeColorScheme.color_map = None
color_scheme = self.settings.get('color_scheme')
try:
if int(sublime.version()) >= 3000:
b = sublime.load_binary_resource(color_scheme)
pl = readPlistFromBytes(b)
else:
pl = readPlist(os.path.join(os.path.abspath(
sublime.packages_path() + '/..'), color_scheme))
except:
return
def safe_update(fr, to):
for k in fr.keys():
if k not in to:
to[k] = fr[k]
dct = {}
for d in pl.settings:
if 'settings' not in d:
continue
s = d['settings']
if 'scope' not in d:
safe_update(s, dct)
else:
scope = d['scope']
scopes = [sc.strip() for sc in scope.split(',')]
if 'text' in scopes or 'source' in scopes:
dct.update(d.settings)
HaxeColorScheme.color_map = dct
开发者ID:elibroide,项目名称:haxe-sublime-bundle,代码行数:35,代码来源:haxe_hint.py
示例13: _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
示例14: set_view
def set_view(self, src, lang):
"""Setup view for conversion."""
# Get the output panel
self.view = sublime.active_window().get_output_panel('mdpopups')
# Let all plugins no to leave this view alone
self.view.settings().set('is_widget', True)
# Don't translate anything.
self.view.settings().set("translate_tabs_to_spaces", False)
# Don't mess with my indenting Sublime!
self.view.settings().set("auto_indent", False)
# Insert into the view
self.view.run_command('insert', {'characters': src})
# Setup the proper syntax
lang = lang.lower()
user_map = sublime.load_settings('Preferences.sublime-settings').get('mdpopups.sublime_user_lang_map', {})
keys = set(list(user_map.keys()) + list(lang_map.keys()))
loaded = False
for key in keys:
v = lang_map.get(key, (tuple(), tuple()))
user_v = user_map.get(key, (tuple(), tuple()))
if lang in (tuple(user_v[0]) + v[0]):
for l in (tuple(user_v[1]) + v[1]):
for ext in ST_LANGUAGES:
sytnax_file = 'Packages/%s%s' % (l, ext)
try:
sublime.load_binary_resource(sytnax_file)
except Exception:
continue
self.view.set_syntax_file(sytnax_file)
loaded = True
break
if loaded:
break
if loaded:
break
if not loaded:
# Default to plain text
for ext in ST_LANGUAGES:
# Just in case text one day switches to 'sublime-syntax'
sytnax_file = 'Packages/Plain text%s' % ext
try:
sublime.load_binary_resource(sytnax_file)
except Exception:
continue
self.view.set_syntax_file(sytnax_file)
开发者ID:1901,项目名称:sublime_sync,代码行数:46,代码来源:st_code_highlight.py
示例15: load_plist
def load_plist(relative_path):
try:
plist_data = plistlib.readPlistFromBytes(sublime.load_binary_resource(relative_path))
print("CFML: loaded plist file - " + relative_path)
return plist_data
except:
print("CFML: unable to load plist file - " + relative_path)
return None
开发者ID:jcberquist,项目名称:sublimetext-cfml,代码行数:8,代码来源:build_cfml_tmlanguage.py
示例16: modify_color_scheme
def modify_color_scheme(l,s,read_original = False):
prefs = sublime.load_settings("Preferences.sublime-settings")
read_original = read_original and prefs.has("original_color_scheme")
if read_original and prefs.get('color_scheme').find('/Colorcoder/') == -1:
read_original = False
if prefs.get('original_color_scheme').find('/\(Colorcoded\)/') != -1:
print("original theme already colorcoded, abort")
return
global modification_running
if modification_running:
return
modification_running = True
name = prefs.get("original_color_scheme") if read_original else sublime.active_window().active_view().settings().get('color_scheme')
try:
cs = plistlib.readPlistFromBytes(sublime.load_binary_resource(name))
tokenclr = "#000000"
for rule in cs["settings"]:
if "scope" not in rule and "name" not in rule:
bgc = rule["settings"]["background"]
r = int(bgc[1:3],16)
g = int(bgc[3:5],16)
b = int(bgc[5:7],16)
if b>0:
b = b-1
elif g>0:
g = g-1
elif r>0:
r = r-1
else:
rule["settings"]["background"] = "#000001"
tokenclr = "#%02x%02x%02x" % (r,g,b)
break
cs["name"] = cs["name"] + " (Colorcoded)"
for x in range(0,256):
cs["settings"].append(dict(
scope="cc0x%x" % x,
settings=dict(
foreground="#"+''.join(map(lambda c: "%02x" % int(256*c),colorsys.hls_to_rgb(x/256., l, s))),
background=tokenclr
)
))
newname = "/%s (Colorcoded).tmTheme" % re.search("/([^/]+).tmTheme$", name).group(1)
plistlib.writePlist(cs,"%s%s" % (colorshemeemodifier.get_save_dir(),newname))
prefs.set("original_color_scheme", name)
prefs.set("color_scheme","Packages%s%s" % (colorshemeemodifier.get_relative_save_dir(), newname))
sublime.save_settings("Preferences.sublime-settings")
except Exception as e:
sublime.error_message("Colorcoder was not able to parse the colorscheme\nCheck the console for the actual error message.")
sublime.active_window().run_command("show_panel", {"panel": "console", "toggle": True})
print(e)
finally:
modification_running = False
开发者ID:Sawtaytoes,项目名称:Sublime-Colorcoder,代码行数:58,代码来源:colorcoder.py
示例17: load_completions
def load_completions(self):
"""
Create the `word_dict_list` containing all the words of the dictionary.
The format of `word_dict_list` is
{"pref" : ["prefix", "Prefab", ...], ...}
where the length of "pref" is determined by `minimal_len` global setting variable.
This method is called on the first activation of the view and when the dictionary (language) is changed.
If this method is called without a language change it simply returns.
"""
global last_language, word_dict_list, minimal_len, force_reload, print_debug
view = sublime.active_window().active_view()
dictionary = view.settings().get('dictionary')
if not dictionary:
return
language = os.path.splitext(os.path.basename(dictionary))[0]
if "status" in print_debug:
if plugin_is_active:
view.set_status('DictionaryAutoComplete', '' + language + ' dictionary complete+' + str(minimal_len))
else:
view.set_status('DictionaryAutoComplete', 'dictionary complete is disabled')
if last_language != language or force_reload:
force_reload = False
last_language = language
get_setting(language)
if local_dictionary:
dictionary = local_dictionary
debug("Load dictionary from ", dictionary, "[", dict_encoding, "]")
else:
debug("Load standard dictionary: ", language, "[", dict_encoding, "]")
try:
if ST3:
words = sublime.load_binary_resource(dictionary).decode(dict_encoding).splitlines()
else: #ST2
dict_path = os.path.join(sublime.packages_path()[:-9], dictionary)
words = open(dict_path, encoding=dict_encoding, mode='r').read().splitlines()
words = [word.split('/')[0].split('\t')[0] for word in words]
except Exception as e:
debug("Error reading from dictionary:", e)
# optimize the list
# the first line of .dic file is the number of words
if not local_dictionary:
del words[0:1]
# keep only words longer than the minimal prefix length
words = [word for word in words if len(word) >= minimal_len]
# create dictionary of prefix -> list of words
word_dict_list = {}
for word in words:
pref = smash(word[:minimal_len])
if not pref in word_dict_list:
word_dict_list[pref] = []
word_dict_list[pref].append(word)
debug("Number of words: ", len(words))
debug("First ones: ", words[:10])
debug("Number of prefixes of length ", minimal_len, " : ", len(word_dict_list))
开发者ID:Zinggi,项目名称:DictionaryAutoComplete,代码行数:57,代码来源:DictionaryAutoComplete.py
示例18: load_resource
def load_resource(resource, binary=False):
"""Load the given resource."""
bfr = None
if not binary:
bfr = sublime.load_resource(resource)
else:
bfr = sublime.load_binary_resource(resource)
return bfr
开发者ID:facelessuser,项目名称:ColorSchemeEditor,代码行数:9,代码来源:color_scheme_editor.py
示例19: tint_raw
def tint_raw(img, color, opacity=255):
"""Tint the image."""
if isinstance(img, str):
try:
img = sublime.load_binary_resource(img)
except Exception:
_log('Could not open binary file!')
_debug(traceback.format_exc(), ERROR)
return ''
return imagetint.tint_raw(img, color, opacity)
开发者ID:awwakum,项目名称:dotfiles,代码行数:11,代码来源:__init__.py
示例20: scheme_lums
def scheme_lums(scheme_file):
color_scheme = os.path.normpath(scheme_file)
scheme_file = os.path.basename(color_scheme)
plist_file = readPlistFromBytes(
sublime.load_binary_resource(
sublime_format_path(color_scheme)
)
)
color_settings = plist_file["settings"][0]["settings"]
rgba = RGBA(color_settings.get("background", '#FFFFFF'))
return rgba.luminance()
开发者ID:marcos0x,项目名称:Sublime-Text-3,代码行数:12,代码来源:scheme_lum.py
注:本文中的sublime.load_binary_resource函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论