add2db.py
author viric <viriketo@gmail.com>
Sun, 13 Feb 2011 08:27:44 +0100
changeset 4 a3d29fb016c3
parent 0 6371497b4e53
permissions -rwxr-xr-x
Adding handling of tab and enter
viric@0
     1
#!/usr/bin/python
viric@0
     2
# -*- coding: utf-8 -*-
viric@0
     3
viric@0
     4
viric@0
     5
import sys,shelve
viric@0
     6
viric@0
     7
dbase = shelve.open('vortoj-ru-ca.sdb')
viric@0
     8
viric@0
     9
print "Showing keys:"
viric@0
    10
for a in dbase.keys():
viric@0
    11
	print a
viric@0
    12
viric@0
    13
print("Tajpu vorton por aldoni al la listo:"),
viric@0
    14
key = raw_input()
viric@0
    15
viric@0
    16
if key == "":
viric@0
    17
	print "Fino."
viric@0
    18
	sys.exit()
viric@0
    19
viric@0
    20
print("Tajpu tradukon por %s:" % key),
viric@0
    21
traduko = raw_input()
viric@0
    22
viric@0
    23
dbase[key] = traduko
viric@0
    24
viric@0
    25
print "Showing new keys:"
viric@0
    26
for a in dbase.keys():
viric@0
    27
	print a
viric@0
    28
dbase.close()