當前位置: 首頁>>代碼示例>>Python>>正文


Python Image.select方法代碼示例

本文整理匯總了Python中app.models.Image.select方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.select方法的具體用法?Python Image.select怎麽用?Python Image.select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app.models.Image的用法示例。


在下文中一共展示了Image.select方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: page_image

# 需要導入模塊: from app.models import Image [as 別名]
# 或者: from app.models.Image import select [as 別名]
def page_image(title_id, page_num):

    """Get archive file corresponding to title ID
    and member file corresponding to page number
    
    Returns extracted image to browser"""

    # Get title information
    try:
        volume = Volume.get(Volume.id == title_id)
    except Volume.DoesNotExist:
        abort(404)

    # Get page information
    try:
        page = Image.select().join(Volume).where((Volume.id == title_id)
                                                 & (Image.page == page_num)).get()
    except Image.DoesNotExist:
        abort(404)

    if volume.filetype == 'zip':

        # TODO: Error check on archive open
        z = zipfile.ZipFile(INPUT_PATH+volume.filename)

        # Get page binary data
        # TODO: Error checking
        zf = z.read(page.filename)

        z.close()

        # Return extracted image to browser
        return send_file(BytesIO(zf), mimetype=page.mimetype)

    elif volume.filetype == 'rar':

        # TODO: Error check on archive open
        rar = rarfile.RarFile(INPUT_PATH+volume.filename)

        # Get page binary data
        # TODO: Error checking
        rardata = rar.read(page.filename)

        rar.close()

    # Return extracted image to browser
        return send_file(BytesIO(rardata), mimetype=page.mimetype)

    # unrecognised archive type
    else:
        abort(500)
開發者ID:KyubiSystems,項目名稱:Yomiko,代碼行數:53,代碼來源:views.py

示例2: slide

# 需要導入模塊: from app.models import Image [as 別名]
# 或者: from app.models.Image import select [as 別名]
def slide(title_id):
    """Test template for Unslider display, displays Title title_id"""

    # Get title information
    try:
        volume = Volume.get(Volume.id == title_id)
    except Volume.DoesNotExist:
        abort(404)

    # Get list of images for this title
    pages = Image.select(Image, Volume).join(Volume).where(
        Volume.id == title_id).order_by(Image.page)

    # Pass volume and page details to Unslider template
    return render_template("slider.html", title_id=title_id, volume=volume, pages=pages)
開發者ID:KyubiSystems,項目名稱:Yomiko,代碼行數:17,代碼來源:views.py

示例3: title

# 需要導入模塊: from app.models import Image [as 別名]
# 或者: from app.models.Image import select [as 別名]
def title(title_id):

    """
    Render title (grid of thumbnails).
    Image 0 as blurred CSS background?
    """

    # Get title information
    try:
        volume = Volume.get(Volume.id == title_id)
    except Volume.DoesNotExist:
        abort(404)

    # Get list of images for this title
    thumbs = Image.select(Image, Volume).join(Volume).where(Volume.id == title_id).order_by(Image.page)

    # Get list of tags for this title
    tags = Tag.select(Tag, TagRelation, Volume).join(TagRelation).join(Volume).where(Volume.id == title_id).order_by(Tag.name)
    
    # pass list of thumbnails to template
    return render_template("title.html", title=volume.title,
                           id=str(title_id), thumbs=thumbs, tags=tags)
開發者ID:KyubiSystems,項目名稱:Yomiko,代碼行數:24,代碼來源:views.py


注:本文中的app.models.Image.select方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。