本文整理汇总了Python中models.Member.add方法的典型用法代码示例。如果您正苦于以下问题:Python Member.add方法的具体用法?Python Member.add怎么用?Python Member.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Member
的用法示例。
在下文中一共展示了Member.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_members_to_db
# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import add [as 别名]
def add_members_to_db(fin=members_json):
from PyQt4 import QtCore
from models import Member
from assets.validators import valid_email, valid_phone
with open(fin, 'r') as members_file:
data = members_file.read()
data = json.loads(data)
sheets = data.keys()
for s in sheets:
print s
for member in data[s]:
if len(member) != 5:
print 'invalid member'
return
mob = member[0]
mob = mob if valid_phone(mob) else None
email = member[1]
email = email if valid_email(email) else None
grade = member[2]
name = member[3]
num = member[4]
if name and num.isdigit():
m = Member.add(name=name, mob=mob, email=email, note=grade)
if type(m) in [str, QtCore.QString]:
print m, name, num