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


Python Photo.select方法代码示例

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


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

示例1: list_photos

# 需要导入模块: from photos.models import Photo [as 别名]
# 或者: from photos.models.Photo import select [as 别名]
def list_photos(args):
    tmpl1 = '{id:<3}  {chksum:<32}  {date}'
    tmpl2 = '         {comment:<30}  {added}'

    desc = dict(id='Id', chksum='Checksum', date='Date', comment='Comment', added='Added')

    head1 = tmpl1.format(**desc)
    head2 = tmpl2.format(**desc)
    print(head1)
    print(head2)
    print('-' * (max(len(head1), len(head2))  + 12))


    for p in Photo.select().dicts():
        print(tmpl1.format(**p))
        print(tmpl2.format(**p))
开发者ID:eikevons,项目名称:yorik-photos,代码行数:18,代码来源:manage-photos.py

示例2: test_init

# 需要导入模块: from photos.models import Photo [as 别名]
# 或者: from photos.models.Photo import select [as 别名]
def test_init(args):
    users = [('viewer 1', '[email protected]', 'pass1', False),
             ('viewer 2', '[email protected]', 'pass2', False),
             ('uploader 1', '[email protected]', 'uppass1', True),
             ('uploader 2', '[email protected]', 'uppass2', True)]

    photos = [('111', '2014-06-07T20:21:19', 'photo 111'),
              ('12345', '2014-06-05T20:21:19', 'photo 12345'),
              ('222', '2014-06-04T20:21:19', 'photo 222'),
              ('333', '2014-06-07T22:21:19', 'photo 333'),
              ('444', '2014-06-05T20:21:19', '444'),
              ('555', '2014-06-01T20:21:19', 'photo 555'),
              ('666', '2014-06-05T14:21:19', 'photo 666'),
              ('abcde', '2014-05-02T20:21:19', 'photo abcde'),
              ('uvw', '2014-03-02T20:21:19', 'photo uvw'),
              ('xyz', '2014-07-02T20:21:19', 'photo xyz'),
              ]


    if User.select().count() == 0:
        for n, e, p, u in users:
            User.create(name=n, email=e, password=generate_password_hash(p), uploader=u)
    else:
        print('User table already contains data')

    str2datetime = lambda s: arrow.get(s).datetime.replace(tzinfo=None)

    if Photo.select().count() == 0:
        for s, d, c in photos:
            kw = dict(chksum=s, date=str2datetime(d), comment=c,
                    added=datetime.utcnow(),
                    mimetype='image/jpeg')
            print(kw)
            Photo.create(**kw)
    else:
        print('Photo table already contains data')
开发者ID:eikevons,项目名称:yorik-photos,代码行数:38,代码来源:manage-photos.py


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