Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/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
You can’t perform that action at this time.