Esempio n. 1
0
 def find(self):
     """
         Find a contact by it's name
     """
     ac=AgendaController()
     name=raw_input('NAME:').strip()
     contact=ac.lookup(name)
     if contact==False:
         print "CONTACT NOT FOUND"
     else:
         print 'Phone Number:',contact.getPhoneNr()
Esempio n. 2
0
 def addToFile(self):
     """
         Save the name and the number of the contacts to a text file
     """
     ac=AgendaController()
     group=raw_input('Group:').strip()
     while group<>'Family' and group<>'Friends' and group<>'Others':
         print 'INVALID GROUP'
         group=raw_input('Group:').strip()
     list=ac.lookUpAll(group)
     outFile=raw_input('FileName:').strip()
     try:
         ac.exportCSV(group, outFile)
     except IOError:
         print "File not found"
Esempio n. 3
0
 def showGroup(self):
     """
         Show all the contacts from the group
     """
     ac=AgendaController()
     group=raw_input('Group:').strip()
     while group<>'Family' and group<>'Friends' and group<>'Others':
         print 'INVALID GROUP'
         group=raw_input('Group:').strip()
     list=ac.lookUpAll(group)
     if list==[]:
         print 'EMPTY GROUP'
     else:
         for i in list:
             print i.getName(),': ',i.getPhoneNr()
Esempio n. 4
0
 def add(self):
     """
         Add a new contact to the database
     """
     ac=AgendaController()
     name=raw_input('    Name:').strip()
     ok=False
     while ok==False:
         ok=True
         try:
             id=int(raw_input('    ID:'))
         except ValueError:
             print "Give a numerical ID"
             ok=False
     nr=raw_input('    Phone Number:').strip()
     group=raw_input('    Group:').strip()
     i=ac.addContact(id,name,nr,group)
     if i==False:
         print "INVALID CONTACT!!!"
         self.add()