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


Python Person.select方法代码示例

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


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

示例1: check_transfers_per_person

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import select [as 别名]
def check_transfers_per_person():
    for p in Person.select():
        # Each person should have only one incoming and one outgoing transfer
        in_transfers = p.transfers.where(Transfer.from_facility >> None)
        out_transfers = p.transfers.where(Transfer.to_facility >> None)
        if in_transfers.count() > 1:
            print "More than one incoming transfer for person %d" % (p.trac_id)
            print list(in_transfers)

        if out_transfers.count() > 1:
            print "More than one outgoing transfer for person %d" % (p.trac_id)
            print list(out_transfers)
开发者ID:ghing,项目名称:iceage-data,代码行数:14,代码来源:check_transfers.py

示例2: check_total_transfers

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import select [as 别名]
def check_total_transfers():
    num_people = Person.select().count()
    total_incoming = Transfer.select().where(Transfer.from_facility >> None).count()
    total_outgoing = Transfer.select().where(Transfer.to_facility >> None).count()
    if total_incoming == num_people and total_outgoing == num_people:
        print "Looks good"
        return True

    if total_incoming != num_people:
        print "Incoming transfers don't match: %d != %d" % (total_incoming, num_people)

    if total_outgoing != num_people:
        print "Outgoing transfers don't match: %d != %d" % (total_outgoing, num_people)

    return False
开发者ID:ghing,项目名称:iceage-data,代码行数:17,代码来源:check_transfers.py

示例3: get_characters

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import select [as 别名]
def get_characters():
    characters = []
    for trac_id in CHARACTER_IDS:
        person = Person.select().where(Person.trac_id == trac_id).get()
        if trac_id in MEN:
            gender = 'male'
        else:
            gender = 'female'
        characters.append({
            'trac_id': person.trac_id,
            'gender': gender,
            'nationality': person.nationality.strip().lower()
        })

    return characters
开发者ID:ghing,项目名称:iceage-data,代码行数:17,代码来源:export_characters.py

示例4: index

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import select [as 别名]
def index():
    request.foo = 'bar'
    persons = Person.select()
    # print(request.foo)
    welcome = 'Keep calm and carry on!'
    motto = ['醒醒我们回家了', '世界是我的表象', '向死而生', '凡人所有的我都有']
    # print('host', request.host)
    # print('host-port', request.host_port)
    # print('path', request.path)
    # print('fullpath', request.full_path)
    # print('script-root', request.script_root)
    # print('url', request.url)
    # print('base-url', request.base_url)
    # print('url-root', request.url_root)
    # print('host-url', request.host_url)
    # print('host', request.host)
    return render('index.html', motto=motto, welcome=welcome, persons=persons)
开发者ID:cymoo,项目名称:minim,代码行数:19,代码来源:views.py

示例5: get_timelines

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import select [as 别名]
def get_timelines():
    timelines = {}
    for person in Person.select().where(Person.trac_id << CHARACTER_IDS):
        for transfer in person.transfers:
            transfer_date = transfer.date.isoformat()
            if transfer_date not in timelines:
                timelines[transfer_date] = {}
            reason = transfer.reason.strip()
            if transfer.from_facility is None:
                # Work around some facilities not having "Official Names"
                facility_name = transfer.to_facility.official_name or transfer.to_facility.name
                message = "Detained and sent to %s" % (facility_name)
            elif reason == "Transferred":
                message = "Transferred to %s" % (transfer.to_facility.official_name)
            elif transfer.reason == "Removed":
                message = "Deported"
            else:
                message = "Left ICE custody (%s)" % (reason)
            timelines[transfer_date][person.trac_id] = message
    return timelines
开发者ID:ghing,项目名称:iceage-data,代码行数:22,代码来源:export_character_timelines.py

示例6: main

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import select [as 别名]
def main(argv):
    db.connect()
    try:
        Person.drop_table()
    except sqlite3.OperationalError:
        pass
    Person.create_table()

    with open(argv[1]) as f:
        csv_file = DictReader(f)
        for line in csv_file:
            attrs = {
                'trac_id': float(line['TRAC Assigned Identifier for Individual'].strip()),
                'nationality': line['Nationality'].strip(),
                'gender': line['Gender'].strip(),
            }
            try:
                person = Person.select().where((Person.trac_id == attrs['trac_id']) & (Person.nationality == attrs['nationality'])).get()
            except Person.DoesNotExist:
                person = Person.create(**attrs)
开发者ID:ghing,项目名称:iceage-data,代码行数:22,代码来源:import_people.py

示例7: main

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import select [as 别名]
def main(argv):
    db.connect()
    try:
        Detention.drop_table()
    except sqlite3.OperationalError:
        pass
    Detention.create_table()

    with open(argv[1]) as f:
        date_format = '%d-%b-%y'
        csv_file = DictReader(f)
        for line in csv_file:
            person = Person.select().where(Person.trac_id == line['TRAC Assigned Identifier for Individual'].strip()).get()
            facility = Facility.select().where(Facility.name == line['Detention Facility'].strip()).get()
            attrs = {
                'person': person,
                'facility': facility,
                'book_in_date': datetime.strptime(line['Book-In Date'].strip(), date_format).date(),
                'book_out_date': datetime.strptime(line['Book-Out Date'].strip(), date_format).date(),
                'book_out_reason': line['Reason for Book-Out'].strip(),
            }
            Detention.create(**attrs)
开发者ID:ghing,项目名称:iceage-data,代码行数:24,代码来源:import_chronology.py

示例8: index

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import select [as 别名]
def index():
    people = Person.select()
    form = PersonForm()

    return render_template('index.html', people=people, form=form)
开发者ID:auswm85,项目名称:peoplecrudsample,代码行数:7,代码来源:app.py

示例9: get

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import select [as 别名]
 def get(self):
     current_qq = self.current_user
     self.render('index.html', 
                 qq = current_qq,
                 persons = Person.select())
     LoginInfo.create(login_time = datetime.now(), qq = current_qq)
开发者ID:yuejd,项目名称:class6,代码行数:8,代码来源:admin.py


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