Erik Grinaker is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

erikg / Revelation

Revelation is a password manager for the GNOME desktop, released under the GNU GPL license. It stores all your accounts and passwords in a single, secure place, and gives you access to it through a user-friendly graphical interface.

Clone this repository (size: 2.1 MB): HTTPS / SSH
hg clone https://bitbucket.org/erikg/revelation
hg clone ssh://hg@bitbucket.org/erikg/revelation

Issues

#12 CSV exporter (implementation attached)

Reported anonymously

I hacked together a CSV exporter, thought you might find it useful. I made it for version 0.4.11-3.1ubuntu2.

Status: resolved Responsible: nobody Type: enhancement Priority: major
Milestone: none Component: none Version: none

Attachments

No attachments added for this issue yet.

Comments and changes

  1. #1 Anonymous

    written

    Ok, I cannot find the attach button...

    # Gergely Nagy <greg@gnome.hu>
    #
    import base
    from revelation import data, entry
    
    import time
    import csv
    from cStringIO import StringIO
    
    
    class CSV(base.DataHandler):
    	"Data handler for CSV files"
    
    	name		= "Comma Separated Values (CSV)"
    	importer	= False
    	exporter	= True
    	encryption	= False
    
    
    	def export_data(self, entrystore, password = None):
    		"Exports data to a CSV file"
    
    		# fetch and sort entries
    		entries = []
    		iter = entrystore.iter_nth_child(None, 0)
    
    		while iter is not None:
    			e = entrystore.get_entry(iter)
    
    			if type(e) != entry.FolderEntry:
    				entries.append(e)
    
    			iter = entrystore.iter_traverse_next(iter)
    
    		entries.sort(lambda x,y: cmp(x.name.lower(), y.name.lower()))
    
    		
    		stringwriter = StringIO()
    		csvwriter = csv.writer(stringwriter, dialect="excel")
    
    		keys = set()
    		for e in entries:
    			for f in e.fields:
    				keys.add(f.name)
    
    		# 'Email', 'Hostname', 'Password', 'URL', 'Username'
    		keys = sorted(keys)
    
    		csvwriter.writerow(['Name', 'Type', 'Description', 'Updated'] + keys)
    
    		for e in entries:
    
    			values = []
    			for key in keys:
    				value = ''
    				for field in e.fields:
    					if key == field.name:
    						value = field.value
    				values.append(value)
    
    			updated = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(e.updated))
    			csvwriter.writerow([e.name, e.typename, e.description, updated] + values)
    
    
    		return stringwriter.getvalue()
    
    
    
  2. #2 Anonymous

    written

    This is a good enhancement. Any chance this could be added to a new release?

  3. #3 Anonymous

    written

    Bump!

  4. #4 Mikel Olasagasti Uranga

    written

    • Changed status from new to resolved.

    Applied on master, will be on next release. Thanks Gergely!

Add comment / attachment

Verification: Please write the text from the image in the box (letters only)

captcha

Is that you, Humanoid? Is this me?