本文整理汇总了Python中sublime.load_resource函数的典型用法代码示例。如果您正苦于以下问题:Python load_resource函数的具体用法?Python load_resource怎么用?Python load_resource使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_resource函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: decodeEntity
def decodeEntity(xml, category='iso'):
global entities
if not isinstance(xml, str):
return xml
if entities[category]:
forward, reverse = entities[category]
else:
if category == 'iso':
forward = sublime.decode_value(sublime.load_resource('Packages/' + package_name + '/IsoEntities.json'))
elif category == 'html':
forward = sublime.decode_value(sublime.load_resource('Packages/' + package_name + '/HtmlEntities.json'))
reverse = dict((v, k) for k, v in forward.items())
entities[category] = (forward, reverse)
def parseEntity(match):
entity = match.group(1)
try:
if entity.isdigit():
return reverse[int(entity)]
else:
return chr(forward[entity])
except:
return match.group(0)
xml = re.sub('&([a-zA-Z0-9]+);', parseEntity, xml)
return xml
开发者ID:john1688,项目名称:docphp,代码行数:25,代码来源:docphp.py
示例2: parseJSON
def parseJSON(self, package, name, ext):
if ST2:
path = os.path.join(sublime.packages_path(), package, name + '.' + ext)
if not os.path.isfile(path):
path = os.path.join(sublime.packages_path(), package, 'Default.' + ext)
if not os.path.isfile(path):
return None
return None
with codecs.open(path) as f:
content = self.removeComments(f.read())
if f is not None:
f.close()
try:
parsedJSON = json.loads(content, cls=ConcatJSONDecoder)
except (ValueError):
return None
return parsedJSON[0]
else:
try:
resource = sublime.load_resource('Packages/' + package + '/' + name + '.' + ext)
except (IOError):
try:
resource = sublime.load_resource('Packages/' + package + '/Default.' + ext)
except (IOError):
return None
return None
return sublime.decode_value(resource)
开发者ID:sandroqz,项目名称:sublime-text,代码行数:27,代码来源:Keymaps.py
示例3: __init__
def __init__(self):
self.client_id = "141"
self.client_secret = "4*ic:5WfF;LxE534"
self.settings = tools.load_settings("LaTeXing", mendeley_oauth_token="", mendeley_internal_cite_key=False, mendeley_cite_key_pattern="{Author}{year}")
# Load map
self.map = sublime.decode_value(sublime.load_resource("Packages/LaTeXing/latexing/api/mendeley.map"))
# bibtex: zotero type
self.type_map = self.map["types"]
# bibtex: zotero field
self.field_map = self.map["fields"]
# Check for user maps
try:
self.user_map = sublime.decode_value(sublime.load_resource("Packages/User/LaTeXing/mendeley.map"))
self.type_map.update(self.user_map["types"] if "types" in self.user_map else {})
self.field_map.update(self.user_map["fields"] if "fields" in self.user_map else {})
except:
pass
self.status = "Ok"
self.items = []
self.items_no_key = {}
开发者ID:LaTeXing,项目名称:LaTeXing,代码行数:26,代码来源:mendeley.py
示例4: apply_syntax
def apply_syntax(self, syntax, view):
# print("Applying", syntax)
try:
sublime.load_resource(syntax)
except Exception:
print("Syntax file not found", syntax)
view.set_syntax_file(syntax)
开发者ID:oleksiyk,项目名称:SublimeEasySyntax,代码行数:7,代码来源:main.py
示例5: get_code
def get_code(self, type, namespace, filename):
code = ''
file_name = "%s.tmpl" % type
isIOError = False
tmpl_dir = 'Packages/' + self.PACKAGE_NAME + '/' + self.TMLP_DIR + '/'
user_tmpl_dir = 'Packages/User/' + \
self.PACKAGE_NAME + '/' + self.TMLP_DIR + '/'
self.user_tmpl_path = os.path.join(user_tmpl_dir, file_name)
self.tmpl_path = os.path.join(tmpl_dir, file_name)
try:
code = sublime.load_resource(self.user_tmpl_path)
except IOError:
try:
code = sublime.load_resource(self.tmpl_path)
except IOError:
isIOError = True
if isIOError:
sublime.message_dialog('[Warning] No such file: ' + self.tmpl_path
+ ' or ' + self.user_tmpl_path)
code = code.replace('${namespace}', namespace)
code = code.replace('${classname}', filename)
return code
开发者ID:jsiwek,项目名称:omnisharp-sublime,代码行数:29,代码来源:new_file.py
示例6: plugin_loaded
def plugin_loaded():
global settings
global KWDB
global SETTINGS_FILE
global INDENT_STYLE
global INDENT_STYLE_ALLMAN
global INDENT_STYLE_K_AND_R
SETTINGS_FILE = 'LSL.sublime-settings'
INDENT_STYLE = os.path.join(sublime.packages_path(), 'User', 'LSL_indent_style.tmPreferences')
INDENT_STYLE_ALLMAN = sublime.load_resource('Packages/LSL/metadata/LSL_indent_style.tmPreferences.allman')
INDENT_STYLE_K_AND_R = sublime.load_resource('Packages/LSL/metadata/LSL_indent_style.tmPreferences.k_and_r')
try:
settings = sublime.load_settings(SETTINGS_FILE)
except Exception as e:
print(e)
if not os.path.exists(INDENT_STYLE):
with open(INDENT_STYLE, mode='w', newline='\n') as file:
file.write(INDENT_STYLE_ALLMAN)
kwdbAsString = sublime.load_resource('Packages/LSL/other/kwdb/kwdb.xml')
KWDB = etree.fromstring(kwdbAsString)
开发者ID:buildersbrewery,项目名称:linden-scripting-language,代码行数:25,代码来源:main.py
示例7: set_syntax
def set_syntax(self, name):
# the default settings file uses / to separate the syntax name parts, but if the user
# is on windows, that might not work right. And if the user happens to be on Mac/Linux but
# is using rules that were written on windows, the same thing will happen. So let's
# be intelligent about this and replace / and \ with os.path.sep to get to
# a reasonable starting point
path = os.path.dirname(name)
name = os.path.basename(name)
if not path:
path = name
file_name = name + ".tmLanguage"
new_syntax = sublime_format_path("/".join(["Packages", path, file_name]))
current_syntax = self.view.settings().get("syntax")
# only set the syntax if it's different
if new_syntax != current_syntax:
# let's make sure it exists first!
try:
sublime.load_resource(new_syntax)
self.view.set_syntax_file(new_syntax)
log("Syntax set to " + name + " using " + new_syntax)
except:
log("Syntax file for " + name + " does not exist at " + new_syntax)
开发者ID:TLCasella,项目名称:CodeEnvironment,代码行数:27,代码来源:ApplySyntax.py
示例8: __init__
def __init__(self):
self.client_key = "40af22476e380eadfef5"
self.client_secret = "ec5cfba3fb9fb063d0d4"
self.settings = tools.load_settings("LaTeXing",
zotero_user_key="",
zotero_user_id="",
zotero_cite_key_pattern="{Author}{year}"
)
# Load map
self.map = sublime.decode_value(sublime.load_resource("Packages/LaTeXing/latexing/api/zotero.map"))
# bibtex: zotero type
self.type_map = self.map["types"]
# bibtex: zotero field
self.field_map = self.map["fields"]
# Check for user maps
try:
self.user_map = sublime.decode_value(sublime.load_resource("Packages/User/LaTeXing/zotero.map"))
self.type_map.update(self.user_map["types"] if "types" in self.user_map else {})
self.field_map.update(self.user_map["fields"] if "fields" in self.user_map else {})
except:
pass
self.status = "Ok"
self.items = []
self.items_no_key = {}
开发者ID:LaTeXing,项目名称:LaTeXing,代码行数:30,代码来源:zotero.py
示例9: fixup_docs_action
def fixup_docs_action(self):
docs_path = os.path.join(
os.path.dirname(os.path.dirname(__file__)),
'NeoVintageous/res/doc')
def set_utf8_encoding_save_and_close(view):
view.run_command('set_encoding', {'encoding': 'utf-8'})
view.run_command('save')
view.close()
for f in os.listdir(docs_path):
if f.endswith('.txt'):
resource = 'Packages/NeoVintageous/res/doc/%s' % f
try:
load_resource(resource)
except Exception as e:
print(' Error: ' + resource + ' ' + str(e))
file = packages_path() + '/NeoVintageous/res/doc/%s' % f
print(' Fixing resource encoding for \'{}\''.format(file))
view = self.window.open_file(file)
set_timeout_async(functools.partial(set_utf8_encoding_save_and_close, view), 200)
开发者ID:gerardroche,项目名称:sublimefiles,代码行数:25,代码来源:user_neovintageous.py
示例10: reload_settings
def reload_settings(self):
self.settings_default = sublime.decode_value(sublime.load_resource(from_package('Mediawiker.sublime-settings')))
self.settings = sublime.load_settings('Mediawiker.sublime-settings')
try:
self.settings_user = sublime.decode_value(sublime.load_resource(from_package('Mediawiker.sublime-settings', name='User')))
except IOError:
self.settings_user = {}
开发者ID:tosher,项目名称:Mediawiker,代码行数:7,代码来源:mw_properties.py
示例11: copy_filename_root_changed
def copy_filename_root_changed(self,root):
self.root_folder = root
self.saveRoot(root,
sublime.load_resource('Packages/FileActions/Side Bar.sublime-menu'),
os.path.join(sublime.packages_path(), 'User', 'FileActions', 'Side Bar.sublime-menu'))
self.saveRoot(root,
sublime.load_resource('Packages/FileActions/Context.sublime-menu'),
os.path.join(sublime.packages_path(), 'User', 'FileActions', 'Context.sublime-menu'))
开发者ID:cnlevy,项目名称:sublimetext-file-actions,代码行数:8,代码来源:FileActions.py
示例12: run
def run(self, edit, view_name):
popup_max_width = 600
popup_max_height = 600
css = sublime.load_resource("Packages/GitSavvy/popups/style.css")
html = sublime.load_resource("Packages/GitSavvy/popups/" + view_name + ".html").format(
css=css, super_key=util.super_key
)
self.view.show_popup(html, 0, -1, popup_max_width, popup_max_height)
开发者ID:gwenzek,项目名称:GitSavvy,代码行数:8,代码来源:ui.py
示例13: _plugin_loaded
def _plugin_loaded():
global PREVIEW_TEMPLATE, PAGINATION_TEMPLATE
root_path = "Packages/" + utils.get_plugin_name() + "/templates"
PREVIEW_TEMPLATE = sublime.load_resource(
root_path + "/method_preview.html"
).replace("\r", "")
PAGINATION_TEMPLATE = sublime.load_resource(root_path + "/pagination.html").replace(
"\r", ""
)
开发者ID:thomasrotter,项目名称:sublimetext-cfml,代码行数:9,代码来源:method_preview.py
示例14: exists_resource
def exists_resource(resource_file_path):
if sublime.version() >= "3000":
try:
sublime.load_resource(resource_file_path)
return True
except:
return False
else:
filename = os.path.join(os.path.dirname(sublime.packages_path()), resource_file_path)
return os.path.isfile(filename)
开发者ID:robinboening,项目名称:sublimetext-markdown-preview,代码行数:10,代码来源:MarkdownPreview.py
示例15: _get_user_css
def _get_user_css():
"""Get user css."""
css = None
user_css = _get_setting('mdpopups.user_css', DEFAULT_USER_CSS)
try:
css = clean_css(sublime.load_resource(user_css))
except Exception:
css = clean_css(sublime.load_resource(DEFAULT_CSS))
return css if css else ''
开发者ID:Zet-Web,项目名称:Package-ST3-packages,代码行数:10,代码来源:__init__.py
示例16: open_gist
def open_gist(gist_url):
gist = api_request(gist_url)
# print('Gist:', gist)
files = sorted(gist['files'].keys())
for gist_filename in files:
# if gist['files'][gist_filename]['type'].split('/')[0] != 'text':
# continue
view = sublime.active_window().new_file()
gistify_view(view, gist, gist_filename)
if PY3:
view.run_command('append', {
'characters': gist['files'][gist_filename]['content'],
})
else:
edit = view.begin_edit()
view.insert(edit, 0, gist['files'][gist_filename]['content'])
view.end_edit(edit)
if settings.get('supress_save_dialog'):
view.set_scratch(True)
if not "language" in gist['files'][gist_filename]:
continue
language = gist['files'][gist_filename]['language']
if language is None:
continue
if language == 'C':
new_syntax = os.path.join('C++', "{0}.tmLanguage".format(language))
else:
new_syntax = os.path.join(language, "{0}.tmLanguage".format(language))
if PY3:
new_syntax_path = os.path.join('Packages', new_syntax)
if sublime.platform() == 'windows':
new_syntax_path = new_syntax_path.replace('\\', '/')
try:
sublime.load_resource(new_syntax_path)
view.set_syntax_file(new_syntax_path)
except:
pass
else:
new_syntax_path = os.path.join(sublime.packages_path(), new_syntax)
if os.path.exists(new_syntax_path):
view.set_syntax_file(new_syntax_path)
开发者ID:linkarys,项目名称:Gist,代码行数:54,代码来源:gist.py
示例17: set_syntax
def set_syntax(self, path, file_name=False):
if not file_name:
file_name = path
file_name = file_name + '.tmLanguage'
new_syntax = sublime_format_path('/'.join(['Packages', path, file_name]))
current_syntax = self.view.settings().get('syntax')
if new_syntax != current_syntax:
sublime.load_resource(new_syntax)
self.view.set_syntax_file(new_syntax)
开发者ID:tamura,项目名称:SublimeDataConverter,代码行数:12,代码来源:DataConverter.py
示例18: get_code
def get_code(self, type):
settings = self.get_settings()
custom_path = settings.get('custom_path', '')
code = ''
user_file_name = "%s.user.tmpl" % type
file_name = "%s.tmpl" % type
isIOError = False
if custom_path:
tmpl_dir = custom_path;
else:
if IS_GTE_ST3:
tmpl_dir = 'Packages/' + PACKAGE_NAME + '/' + TMLP_DIR + '/'
# tmpl_dir = os.path.join('Packages', PACKAGE_NAME , TMLP_DIR)
else:
tmpl_dir = os.path.join(PACKAGES_PATH, PACKAGE_NAME, TMLP_DIR)
self.user_tmpl_path = os.path.join(tmpl_dir, user_file_name)
self.tmpl_path = os.path.join(tmpl_dir, file_name)
if IS_GTE_ST3:
if custom_path:
if os.path.isfile(self.user_tmpl_path):
code = self.open_file(self.user_tmpl_path);
elif os.path.isfile(self.tmpl_path):
code = self.open_file(self.tmpl_path);
else:
isIOError = True
else:
try:
code = sublime.load_resource(self.user_tmpl_path)
except IOError:
try:
code = sublime.load_resource(self.tmpl_path)
except IOError:
isIOError = True
else:
if os.path.isfile(self.user_tmpl_path):
code = self.open_file(self.user_tmpl_path);
elif os.path.isfile(self.tmpl_path):
code = self.open_file(self.tmpl_path);
else:
isIOError = True
# print(self.tmpl_path)
if isIOError:
sublime.message_dialog('[Warning] No such file: ' + self.tmpl_path)
return self.format_tag(code)
开发者ID:imlgm,项目名称:SublimeTmpl,代码行数:49,代码来源:sublime-tmpl.py
示例19: get_track_data
def get_track_data(self):
track_script = sublime.load_resource("Packages/iTunes/scripts/track.scpt")
artist_script = sublime.load_resource("Packages/iTunes/scripts/artist.scpt")
track_p = subprocess.Popen("osascript -l JavaScript -e " + shlex.quote(track_script), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
track_name, err = track_p.communicate()
if err:
return
artist_p = subprocess.Popen("osascript -l JavaScript -e " + shlex.quote(artist_script), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
artist_name, err = artist_p.communicate()
if err:
return
return {
"name": track_name.decode().strip(),
"artist": artist_name.decode().strip()
}
开发者ID:spywhere,项目名称:Sublime-iTunes,代码行数:15,代码来源:itunes.py
示例20: run
def run(self, edit):
# html = sublime.load_resource("Packages/sandbox/html/phantom.html")
css = sublime.load_resource("Packages/sandbox/html/ui.css")
html = sublime.load_resource("Packages/sandbox/html/ui.html").format(css=css)
v = self.view.window().new_file()
v.settings().set('gutter', False)
v.settings().set('margin', 0)
v.set_read_only(True)
v.set_scratch(True)
sel = v.sel()
sel.clear()
# LAYOUT_INLINE
# LAYOUT_BELOW
# LAYOUT_BLOCK
v.add_phantom("test", self.view.sel()[0], html, sublime.LAYOUT_INLINE)
开发者ID:aziz,项目名称:sublime-mini-ui,代码行数:15,代码来源:html_ui.py
注:本文中的sublime.load_resource函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论