本文整理汇总了Python中sublime.cache_path函数的典型用法代码示例。如果您正苦于以下问题:Python cache_path函数的具体用法?Python cache_path怎么用?Python cache_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cache_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clean_cache
def clean_cache():
"""Delete cache"""
for fl in os.listdir(sublime.cache_path() + os.path.sep + 'Xkcd'):
try:
os.remove(sublime.cache_path() + os.path.sep + 'Xkcd' + os.path.sep + fl)
except OSError as e:
raise IOError('Could not remove previous files.')
示例2: run
def run(self, edit):
decoder = json.JSONDecoder()
platform = sublime.platform()
if platform == 'linux' or platform == 'osx':
path = sublime.cache_path() + '/CodeIniter/config.json'
else:
path = sublime.cache_path() + '\CodeIniter\config.json'
fobj = open(path, 'r')
s = fobj.read()
db = decoder.decode(s)
file_name = self.view.file_name()
index = int(file_name.rfind('.')) + 1
file_type = file_name[index:]
fobj.close()
self.view.insert(edit, 0, db[file_type])
示例3: on_load_async
def on_load_async(self, view):
platform = sublime.platform()
path = sublime.cache_path()
if platform == 'linux' or platform == 'osx':
path = path + '/CodeIniter'
else:
path = path + '\CodeIniter'
if os.path.exists(path):
print()
else:
os.makedirs(path)
if platform == 'linux' or platform == 'osx':
path = path + '/config.json'
else:
path = path + '\config.json'
if os.path.isfile(path):
print()
else:
fobj = open(path, 'w')
data = {}
data['cpp'] = '#include <iostream>\nusing namespace std\nint main() {\n}'
data['java'] = 'import java.util.*;\nimport java.io.*;\nclass {\npublic static void main(String[] args) {\n}'
data['py'] = 'import os'
fobj.write(json.dumps(data))
fobj.close()
示例4: cache_bibsonomy
def cache_bibsonomy():
settings = tools.load_settings("LaTeXing", cache={"bibsonomy": 24}, bibsonomy=False)
if not settings["bibsonomy"] or not "bibsonomy" in settings["cache"] or not settings["cache"]["bibsonomy"]:
if os.path.exists(os.path.join(sublime.cache_path(), "LaTeXing", "bibsonomy.cache")):
CACHE.clear_cache("bibsonomy.cache", False)
return
# Get BibsonomyFile
f = BibsonomyFile()
bibsonomy_data = CACHE.get_cache_data("bibsonomy.cache")
if CACHE.is_cache_outdated("bibsonomy.cache", settings["cache"]["bibsonomy"]):
f.run(cache=False, save=True)
if f.status == "Error":
log.error("error while caching")
# CACHE.clear_cache("bibsonomy.cache", True)
elif f.status == "Ok":
bibsonomy_data = f.data
CACHE.set_cache_data("bibsonomy.cache", bibsonomy_data, True)
else:
log.debug("up to date")
# Rebuild Keys
for item in bibsonomy_data["cites"]:
item["cite_key"] = f.build_cite_key(item)
# Set the new cache
CACHE.set_cache_data("bibsonomy.cache", bibsonomy_data, True)
示例5: _get_cache
def _get_cache():
if _ST3:
cache_path = os.path.normpath(
os.path.join(sublime.cache_path(), "LaTeXTools"))
else:
cache_path = os.path.normpath(
os.path.join(sublime.packages_path(), "User"))
pkg_cache_file = os.path.normpath(
os.path.join(cache_path, 'pkg_cache.cache'
if _ST3 else 'latextools_pkg_cache.cache'))
cache = None
if not os.path.exists(pkg_cache_file):
gen_cache = sublime.ok_cancel_dialog(
"Cache files for installed packages, "
"classes and bibliographystyles do not exists, "
"would you like to generate it? After generating complete, "
"please re-run this completion action!"
)
if gen_cache:
sublime.active_window().run_command("latex_gen_pkg_cache")
else:
with open(pkg_cache_file) as f:
cache = json.load(f)
return cache
示例6: cache_zotero
def cache_zotero():
settings = tools.load_settings("LaTeXing", cache={"zotero": 24}, zotero=False)
if not settings["zotero"] or not "zotero" in settings["cache"] or not settings["cache"]["zotero"]:
if os.path.exists(os.path.join(sublime.cache_path(), "LaTeXing", "zotero.cache")):
CACHE.clear_cache("zotero.cache", False)
return
# Get ZoteroFile
f = ZoteroFile()
zotero_data = CACHE.get_cache_data("zotero.cache")
if CACHE.is_cache_outdated("zotero.cache", settings["cache"]["zotero"]):
f.run(cache=False, save=True)
if f.status == "Error":
log.error("error while caching")
# CACHE.clear_cache("zotero.cache", True)
elif f.status == "Ok":
zotero_data = f.data
CACHE.set_cache_data("zotero.cache", zotero_data, True)
else:
log.debug("rebuild cite_key")
# Rebuild Keys
for item in zotero_data["cites"]:
item["cite_key"] = f.build_cite_key(item)
# Set the new cache
CACHE.set_cache_data("zotero.cache", zotero_data, True)
示例7: plugin_loaded
def plugin_loaded():
"""Called directly from sublime on plugin load."""
try:
os.makedirs(sublime.cache_path() + os.path.sep + 'Xkcd')
except OSError as e:
if e.errno != errno.EEXIST:
raise IOError('Error encountered during file creation.')
示例8: cache_mendeley
def cache_mendeley():
settings = tools.load_settings("LaTeXing", cache={"mendeley": 24}, mendeley=False)
if not settings["mendeley"] or not "mendeley" in settings["cache"] or not settings["cache"]["mendeley"]:
if os.path.exists(os.path.join(sublime.cache_path(), "LaTeXing", "mendeley.cache")):
CACHE.clear_cache("mendeley.cache", False)
return
# Get MendeleyFile
f = MendeleyFile()
# Get Cache data an rebuild cahce if necessary
mendeley_data = CACHE.get_cache_data("mendeley.cache")
if CACHE.is_cache_outdated("mendeley.cache", settings["cache"]["mendeley"]):
f = MendeleyFile()
f.run(cache=False, save=True)
if f.status == "Error":
log.error("error while caching")
# CACHE.clear_cache("mendeley.cache", True)
elif f.status == "Ok":
mendeley_data = f.data
CACHE.set_cache_data("mendeley.cache", mendeley_data, True)
else:
log.debug("up to date")
# Rebuild Keys
for item in mendeley_data["cites"]:
item["cite_key"] = f.build_cite_key(item)
# Set the new cache
CACHE.set_cache_data("mendeley.cache", mendeley_data, True)
示例9: clean
def clean():
dir_path = os.path.join(sublime.packages_path(), "LaTeXing3")
if os.path.isdir(dir_path):
sublime.message_dialog("Please remove your old LaTeXing installation. Close Sublime Text and delete the following directory: %s!" % dir_path)
file_path = os.path.join(sublime.installed_packages_path(), "LaTeXing3.sublime-package")
if os.path.isfile(file_path):
sublime.message_dialog("Please remove your old LaTeXing installation. Close Sublime Text and delete the following file: %s!" % file_path)
dir_path = os.path.join(sublime.cache_path(), "LaTeXing3")
if os.path.isdir(dir_path):
shutil.rmtree(dir_path)
dir_path = os.path.join(sublime.cache_path(), "LaTeXing ST3")
if os.path.isdir(dir_path):
shutil.rmtree(dir_path)
示例10: install_languages_async
def install_languages_async():
plugin_dir = os.path.dirname(os.path.dirname(__file__))
for language in ['HTML']:
# See if our version of the language already exists in Packages
src_dir = os.path.join(plugin_dir, language)
version_file = os.path.join(src_dir, 'sublimelinter.version')
if os.path.isdir(src_dir) and os.path.isfile(version_file):
with open(version_file, encoding='utf8') as f:
my_version = int(f.read().strip())
dest_dir = os.path.join(sublime.packages_path(), language)
version_file = os.path.join(dest_dir, 'sublimelinter.version')
if os.path.isdir(dest_dir):
if os.path.isfile(version_file):
with open(version_file, encoding='utf8') as f:
try:
other_version = int(f.read().strip())
except ValueError:
other_version = 0
copy = my_version > other_version
else:
copy = sublime.ok_cancel_dialog(
'An existing {} language package exists, '.format(language) +
'and SublimeLinter wants to overwrite it with its version. ' +
'Is that okay?')
if copy:
try:
shutil.rmtree(dest_dir)
except OSError as ex:
from . import persist
persist.printf(
'could not remove existing {} language package: {}'
.format(language, str(ex))
)
copy = False
else:
copy = True
if copy:
from . import persist
try:
cached = os.path.join(sublime.cache_path(), language)
if os.path.isdir(cached):
shutil.rmtree(cached)
shutil.copytree(src_dir, dest_dir)
persist.printf('copied {} language package'.format(language))
except OSError as ex:
persist.printf(
'could not copy {} language package: {}'
.format(language, str(ex))
)
示例11: save
def save():
for file_name in mode if mode else CACHE_NAMES:
if file_name in self.cache_data:
str_json = sublime.encode_value(self.cache_data[file_name])
with open(os.path.join(sublime.cache_path(), "LaTeXing", file_name), 'w', encoding="utf-8") as f:
log.trace("%s", f)
f.write(str_json)
log.info("%s (%s)" % (file_name, tools.size_of_string(str_json)))
示例12: run
def run(self):
plugin_helpers.DebugLogMessage("--> " + __name__ + ": " + type(self).__name__ + "." + sys._getframe().f_code.co_name)
# sublime.active_window().run_command("new_window")
# sublime.active_window().run_command("wam_project_init")
print(sublime.cache_path())
plugin_helpers.DebugLogMessage("<-- " + __name__ + ": " + type(self).__name__ + "." + sys._getframe().f_code.co_name)
示例13: plugin_loaded
def plugin_loaded():
try:
cache_dir = os.path.join(sublime.cache_path(), 'Zip Browser')
except:
cache_dir = os.path.join(sublime.packages_path(), '..', 'Cache', 'Zip Browser')
if os.path.exists(cache_dir):
shutil.rmtree(cache_dir)
cleanup_temp_dir()
示例14: get_cache_dir
def get_cache_dir(*name):
try:
p = os.path.join(sublime.cache_path(), PLUGIN_NAME, *name)
except:
p = os.path.normpath(os.path.join(sublime.packages_path(), '..', PLUGIN_NAME, *name))
if not os.path.exists(p):
os.makedirs(p)
return p
示例15: _global_cache_path
def _global_cache_path():
# For ST3, put the cache files in cache dir
# and for ST2, put it in the user packages dir
if _ST3:
cache_path = os.path.join(sublime.cache_path(), "LaTeXTools")
else:
cache_path = os.path.join(sublime.packages_path(),
"User",
ST2_GLOBAL_CACHE_FOLDER)
return os.path.normpath(cache_path)