add get_resource function

Allow to load the last version of a resource when extracted
This commit is contained in:
Mathieu PATUREL
2017-03-07 08:28:56 +11:00
parent 76f580ba29
commit 05c471b5d9

View File

@ -128,5 +128,12 @@ def get_style(color_scheme):
with open(USER_STYLE_FILE) as fp: with open(USER_STYLE_FILE) as fp:
css += '\n' + fp.read() + '\n' css += '\n' + fp.read() + '\n'
if color_scheme: if color_scheme:
css += pygments_from_theme(sublime.load_resource(color_scheme)) css += pygments_from_theme(get_resource(color_scheme))
return ''.join([line.strip() + ' ' for line in css.splitlines()]) return ''.join([line.strip() + ' ' for line in css.splitlines()])
def get_resource(resource):
if os.path.exists(os.path.join(sublime.packages_path(), '..', resource)):
with open(resource) as fp:
return fp.read()
else:
return sublime.load_resource(resource)