Last active
November 20, 2015 13:00
-
-
Save SamuelMarks/73943159ab4b80092e7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
from sys import argv | |
from os import path | |
with open(argv[1]) as f: | |
s = f.readlines() | |
session = json.loads(s[4]) | |
no_windows_session = {k:v for k,v in session.iteritems() if k not in {'windows', '_closedWindows'}} | |
no_windows_session['_closedWindows'] = {} | |
fds = tuple(open(path.join(path.dirname(argv[1]), '{}.session'.format(num)), 'wt') for num in xrange(len(session['windows']))) | |
windows = tuple(dict(windows=[session['windows'][i]], **no_windows_session) for i in xrange(len(session['windows']))) | |
tuple(fds[i].writelines(s[0:4]+[json.dumps(windows[i])]) for i in xrange(len(fds))) | |
tuple(f.close() for f in fds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment