当前位置: 首页>>代码示例>>Python>>正文


Python Person.mobile方法代码示例

本文整理汇总了Python中models.Person.mobile方法的典型用法代码示例。如果您正苦于以下问题:Python Person.mobile方法的具体用法?Python Person.mobile怎么用?Python Person.mobile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Person的用法示例。


在下文中一共展示了Person.mobile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_persons

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import mobile [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()
开发者ID:Mogmi95,项目名称:Trombi,代码行数:68,代码来源:main.py


注:本文中的models.Person.mobile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。