Last active
December 17, 2015 00:29
-
-
Save jayme-github/5521290 to your computer and use it in GitHub Desktop.
I recently switched from chromium to chrome which results in a new KWallet "Chrome Form Data" folder and the loss of my stored passwords and form data. I thought something like 'okay, I just copy the entries from the old folder' but oops - KWallet GUI does not support this.
So here is a quick and dirty script to copy all entries from one folder …
This file contains 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/python | |
# -*- coding: utf-8 -*- | |
## http://api.kde.org/pykde-4.3-api/kdeui/KWallet.Wallet.html | |
from PyKDE4.kdeui import KWallet | |
from PyQt4.QtGui import QApplication | |
import sys | |
FROM = None | |
TO = None | |
if len(sys.argv) > 1: | |
FROM = sys.argv[1] | |
TO = sys.argv[2] | |
app = QApplication([]) | |
app.setApplicationName("Kwallet folder copy") | |
wallet = KWallet.Wallet.openWallet(KWallet.Wallet.LocalWallet(), 0) | |
if FROM == None or TO == None: | |
for folder in wallet.folderList(): | |
print folder | |
sys.exit(0) | |
if not FROM in wallet.folderList(): | |
print 'Could not find "%s" in wallet' % FROM | |
sys.exit(1) | |
if not TO in wallet.folderList(): | |
wallet.createFolder( TO ) | |
wallet.setFolder( FROM ) | |
# Read all entries from FROM | |
entries = dict() | |
for entry in wallet.entryList(): | |
if not entry in entries: | |
entries[entry] = wallet.readEntry( entry ) | |
# Write all entries to TO | |
wallet.setFolder( TO ) | |
for entry in entries: | |
# if not e in wallet.entryList(): # Don't overwrite existing | |
wallet.writeEntry( entry, entries[entry][1] ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment