Browse files

adds a generic csv importer

  • Loading branch information...
grahl committed Apr 6, 2012
1 parent ff67342 commit 7063d0f5d0c40fa711202c74f3da065d03f63bd2
Showing with 28 additions and 1 deletion.
  1. +28 −1 src/frontends/cmdline/
@@ -24,6 +24,7 @@
import readline
import cmd
import re
import csv
import pygtk
import gtk
@@ -84,7 +85,7 @@ def do_help(self, line):

print "\nCommands:"
print " ".join(("ls", "show", "quit", "add", "save"))
print " ".join(("ls", "show", "quit", "add", "save", "import"))

def do_quit(self, line):
@@ -136,6 +137,32 @@ def do_add(self, line):
self.vault_modified = True
print "User Added, but not saved"

def do_import(self,line):
Adds a CSV importer, based on CSV file
Example: /home/user/data.csv
Columns: Title,User,Password,URL,Group
if not line:
cmd.Cmd.do_help(self, "import")

data = csv.reader(open(line,'rb'))
for row in data:
entry = self.vault.Record.create()
entry.title = row[0]
entry.user = row[1]
entry.passwd = row[2]
entry.url = row[3] = row[4]
self.vault_modified = True
print "Import completed, but not saved."
except csv.Error, e:
sys.exit('file %s, line %d: %s' % (line, data.line_num, e))

def do_ls(self, line):
Show contents of this Vault. If an argument is added a case insensitive

0 comments on commit 7063d0f

Please sign in to comment.