Created
December 16, 2012 23:53
-
-
Save jnothman/4314349 to your computer and use it in GitHub Desktop.
This script renumbers an edited Opera Browser session file. If you remove some tabs/windows from an existing autosave.win (or other .win) file, the numbering becomes non-contiguous. Pipe the edited session file through this script and the numbering will now count from 1 to the required number of windows. However, you must also modify the 'window…
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
import re, sys | |
num_re = re.compile(r'(?<=^\[)[0-9]+') | |
in_n = '' | |
out_n = 0 | |
def sub_cb(match): | |
global in_n, out_n | |
if match.group() != in_n: | |
in_n = match.group() | |
out_n += 1 | |
return str(out_n) | |
for l in sys.stdin: | |
sys.stdout.write(num_re.sub(sub_cb, l)) | |
print >> sys.stderr, 'change window count to:', out_n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment