LastPass adds category fields for everything; even things without categories! It will add a "grouping: (none)" for these passwords. This script takes a data.1pif
export file (File -> Export -> All Items in 1password) and strip out this useless extra data. When done, import the data-out.1pif
, and the fields will be removed. Data is updated in-place in 1password, so there will be no duplicates or anything nasty like that (thanks 1password!)
Last active
August 29, 2015 14:19
-
-
Save RickyCook/afd5086b426785b908a3 to your computer and use it in GitHub Desktop.
LastPass to 1password cleanup
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 python3.4 | |
import json | |
from itertools import islice, tee | |
with open('data.1pif') as in_data: | |
with open('data-out.1pif', 'w') as out_data: | |
all_data_iter, all_uuid_iter = tee(in_data) | |
split_data_iter = zip( | |
islice(all_data_iter, 0, None, 2), | |
islice(all_uuid_iter, 1, None, 2) | |
) | |
for data, uuid in split_data_iter: | |
data = json.loads(data) | |
if 'sections' in data['secureContents']: | |
data['secureContents']['sections'] = [ | |
section_data | |
for section_data in data['secureContents']['sections'] | |
if not any(( | |
( | |
field_data['t'] == 'grouping' and | |
field_data['v'] == '(none)' | |
) | |
for field_data in section_data['fields'] | |
)) | |
] | |
if not data['secureContents']['sections']: | |
del data['secureContents']['sections'] | |
json.dump(data, out_data) | |
out_data.write('\n') | |
out_data.write(uuid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment