def tweak_theme():
view = sublime.active_window().active_view()
theme = view.settings().get('theme')
if theme is None:
print("Can't guess current theme.")
return
theme_path = os.path.join(sublime.packages_path(), 'User', theme)
if os.path.exists(theme_path):
with open(theme_path, mode='r', encoding='utf-8') as f:
theme_text = f.read()
if PYTEST_MARKERS.search(theme_text):
print("Already patched")
return
safety_path = os.path.join(
sublime.packages_path(), 'User', 'Original-' + theme)
with open(safety_path, mode='w', encoding='utf-8') as f:
f.write(theme_text)
theme = sublime.decode_value(theme_text)
else:
theme = []
theme.extend(PYTEST_RULES)
tweaked_theme = sublime.encode_value(theme, True)
with open(theme_path, mode='w', encoding='utf-8') as f:
f.write(tweaked_theme)
print('Done tweaking!')
# sublime.active_window().open_file(theme_path)
评论列表
文章目录