def load_history(rev=True, as_dict=False):
"""Returns list of past requests. Raises exception if history file doesn't
exist.
"""
history_file = sublime.load_settings('Requester.sublime-settings').get('history_file', None)
if not history_file:
raise KeyError
history_path = os.path.join(sublime.packages_path(), 'User', history_file)
with open(history_path, 'r') as f:
rh = json.loads(f.read() or '{}', object_pairs_hook=OrderedDict)
if as_dict:
return rh
requests = list(rh.items())
if rev:
requests.reverse()
return requests
评论列表
文章目录