本文整理汇总了Python中contact.Contact.get_tuple方法的典型用法代码示例。如果您正苦于以下问题:Python Contact.get_tuple方法的具体用法?Python Contact.get_tuple怎么用?Python Contact.get_tuple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类contact.Contact
的用法示例。
在下文中一共展示了Contact.get_tuple方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from contact import Contact [as 别名]
# 或者: from contact.Contact import get_tuple [as 别名]
def main(args):
sys.argv=args
args= docopt(__doc__)
contact = Contact()
# contact.set_bday(args["--bday"])
schema = Schema({
'--contact_id': Or(None,And(Use(int),Use(contact.set_cid, error='id is not correct, it should be integer number'))),
'--first_name': Or(None,Use(contact.set_fname, error='fname is not correct')),
'--last_name': Or(None,Use(contact.set_lname, error='lname is not correct')),
'--middle_name': Or(None,Use(contact.set_mname, error='mname is not correct')),
'--phone': Or(None,Use(contact.set_phone, error='phone is not correct')),
'--bday': Or(None,Use(contact.set_bday, error='birtday is not correct it should be one of the formats ' + str(contact.bday_types))),
'--data': Or(None,Use(set_data, error='name was not correct')),
'--reverse': Or(None,True,False),
'--replace': Or(None,True,False),
'--sort': Or(None,"fname","lname","mname","phone","bday", error="--sort should be one of the fname,lname,mname,phone,bday"),
'add': Or(False,True),
'del': Or(False, True),
'find': Or(False,True),
'list': Or(False,True),
})
try:
schema.validate(args)
except SchemaError as e:
exit(e)
try:
connection = sqlite3.connect(database)
c = connection.cursor()
c.execute("create table contacts(id integer primary key autoincrement, fname text, lname text, mname text, phone text, bday text)")
print("new database " + database + " was created")
except sqlite3.Error as e:
print("Existing database " + database)
if args["add"]:
added, phoneexist, comment = contact.add(contact, c, args)
if added:
print(comment+" " + str(contact.get_tuple()))
else:
print(comment)
elif args["find"]:
finded=contact.find(contact, c)
if finded:
print(tabulate(finded, headers=["Id","first name","last name","middle name","phone","birthday date"]))
else:
print("there is no any contact "+(("like:"+str(contact)) if str(contact) else ""))
elif args["del"]:
result, string=contact.delete(contact, c)
print(string)
if result:
for r in result:
print(r)
else:
sys.exit(-1)
elif args["list"]:
result = contact.lst(args, c)
if result:
print(tabulate(result, headers=["ID","first name","last name","middle name","phone","birthday date"]))
else:
print("there is empty database="+database)
else:
remind=contact.reminder(c)
print("This contact will have their birthdays in this and next months:")
if remind:
print(tabulate(remind, headers=["Id","first name","last name","middle name","phone","birthday date"]))
connection.commit()
connection.close()