Skip to content

Instantly share code, notes, and snippets.

@mitnk
Last active January 24, 2017 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitnk/d9385c60e113eef14e41d42509846a5c to your computer and use it in GitHub Desktop.
Save mitnk/d9385c60e113eef14e41d42509846a5c to your computer and use it in GitHub Desktop.
xonsh migrate history items
from xonsh.history.json import JsonHistory
from xonsh.history.sqlite import SqliteHistory
hist_json = JsonHistory(gc=False)
# if you want to have a check first
print('have {} json items'.format(len(list(hist_json.all_items())))) # may very slow here
hist_db = SqliteHistory(gc=False)
for item in hist_json.all_items():
if 'inp' not in item:
continue
if 'rtn' not in item:
item['rtn'] = 0
hist_db.append(item)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment