本文整理汇总了Python中models.Person.room方法的典型用法代码示例。如果您正苦于以下问题:Python Person.room方法的具体用法?Python Person.room怎么用?Python Person.room使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Person
的用法示例。
在下文中一共展示了Person.room方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_persons
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import room [as 别名]
def load_persons():
persons = []
managers = {}
# TEAMS
existing_teams = {}
teams = Team.query.all()
for team in teams:
existing_teams[team.name] = team
print(existing_teams)
# ROOMS
existing_rooms = {}
rooms = Room.query.all()
for room in rooms:
existing_rooms[room.name] = room
print(existing_rooms)
# We try to use a custom persons file if it exists. If not, default file
if (path.isfile(config.DATABASE_PERSONS_FILE)):
persons_file = config.DATABASE_PERSONS_FILE
else:
persons_file = config.DATABASE_PERSONS_DEFAULT_FILE
with io.open(persons_file, 'r', encoding='utf8') as f:
for line in f:
if (len(line) > 1 and line[0] != '#'):
neo = Person()
split = line[:-1].split(';')
neo.login = split[2].strip().lower()
neo.surname = split[3]
neo.name = split[4]
neo.birthday = datetime.datetime.fromtimestamp(float(format_date(split[5])))
neo.arrival = datetime.datetime.fromtimestamp(float(format_date(split[6])))
neo.job = split[7]
neo.email = split[8]
neo.skype = split[9]
neo.fixe = split[10]
neo.mobile = split[11]
team = split[1]
manager = split[12]
room = split[13]
if manager in managers:
managers[manager].append(neo)
else:
managers[manager] = [neo]
if (team in existing_teams):
neo.team = existing_teams[team]
if (room in existing_rooms):
neo.room = existing_rooms[room]
else:
print('Error: Missing team ' + team + ' for ' + neo.login)
persons.append(neo)
for person in persons:
# We link the managers
if person.login in managers:
person.subordinates = managers[person.login]
db.session.add(person)
db.session.commit()