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


Python Url.generate_options方法代码示例

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


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

示例1: test_usage_new_format

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_usage_new_format():
    key = "my-security-key"
    image = "s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg"

    thumbor_signer = Signer(key)
    thumbor_url = Url.generate_options(
        width=300,
        height=200,
        smart=True,
        adaptive=False,
        fit_in=False,
        horizontal_flip=False,
        vertical_flip=False,
        halign='center',
        valign='middle',
        crop_left=0,
        crop_top=0,
        crop_right=0,
        crop_bottom=0,
        filters=[]
    )
    thumbor_url = ('%s/%s' % (thumbor_url, image)).lstrip('/')
    thumbor_url = '/%s/%s' % (thumbor_signer.signature(thumbor_url), thumbor_url)

    crypto = CryptoURL(key=key)
    url = crypto.generate(
        width=300,
        height=200,
        smart=True,
        image_url=image
    )

    assert url == thumbor_url
开发者ID:gerasim13,项目名称:libthumbor,代码行数:35,代码来源:test_libthumbor.py

示例2: test_url_generate_with_alignments

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_url_generate_with_alignments():
    url = Url.generate_options(
        halign='left',
        valign='top'
    )

    assert url == "0x0/left/top", url
开发者ID:rootart,项目名称:thumbor,代码行数:9,代码来源:test_urls.py

示例3: test_can_generate_url

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
    def test_can_generate_url(self):
        url = Url.generate_options(
            debug=True,
            width=300,
            height=200,
            smart=True,
            meta=True,
            trim=True,
            adaptive=True,
            full=True,
            fit_in=True,
            horizontal_flip=True,
            vertical_flip=True,
            halign='left',
            valign='top',
            crop_left=100,
            crop_top=100,
            crop_right=400,
            crop_bottom=400,
            filters='brightness(100)'
        )

        expect(url).to_equal(
            'debug/meta/trim/100x100:400x400/adaptive-full-fit-in/-300x-200/left/top/smart/filters:brightness(100)'
        )
开发者ID:5um1th,项目名称:thumbor,代码行数:27,代码来源:test_url.py

示例4: test_url_generate_min

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_url_generate_min():
    url = Url.generate_options(
        width=300,
        height=200
    )

    assert url == "300x200"
开发者ID:rootart,项目名称:thumbor,代码行数:9,代码来源:test_urls.py

示例5: encrypt

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
    def encrypt(self, 
                width,
                height,
                smart,
                fit_in,
                flip_horizontal,
                flip_vertical,
                halign,
                valign,
                crop_left,
                crop_top,
                crop_right,
                crop_bottom,
                image):

        url = "%s/%s" % (Url.generate_options(width,
                                              height,
                                              smart,
                                              False,
                                              fit_in,
                                              flip_horizontal,
                                              flip_vertical,
                                              halign,
                                              valign,
                                              crop_left,
                                              crop_top,
                                              crop_right,
                                              crop_bottom),
                        hashlib.md5(image).hexdigest())

        pad = lambda s: s + (16 - len(s) % 16) * "{"
        cipher = AES.new(self.salt)
        encrypted = base64.urlsafe_b64encode(cipher.encrypt(pad(url)))

        return encrypted
开发者ID:douglas,项目名称:thumbor,代码行数:37,代码来源:crypto.py

示例6: test_url_generate_with_smart

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_url_generate_with_smart():
    url = Url.generate_options(
        width=300,
        height=200,
        smart=True
    )

    assert url == "300x200/smart"
开发者ID:rootart,项目名称:thumbor,代码行数:10,代码来源:test_urls.py

示例7: test_url_generate_with_flipping

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_url_generate_with_flipping():
    url = Url.generate_options(
        width=300,
        height=200,
        smart=True,
        horizontal_flip=True,
        vertical_flip=True
    )

    assert url == "-300x-200/smart"
开发者ID:rootart,项目名称:thumbor,代码行数:12,代码来源:test_urls.py

示例8: test_url_generate_with_manual_crop

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_url_generate_with_manual_crop():
    url = Url.generate_options(
        width=300,
        height=200,
        crop_left=10,
        crop_top=11,
        crop_right=12,
        crop_bottom=13
    )

    assert url == "10x11:12x13/300x200"
开发者ID:rootart,项目名称:thumbor,代码行数:13,代码来源:test_urls.py

示例9: test_complete_url

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_complete_url():
    url = Url.generate_options(
        width=300,
        height=200,
        smart=True,
        meta=True,
        horizontal_flip=True,
        vertical_flip=True,
        crop_left=10,
        crop_top=11,
        crop_right=12,
        crop_bottom=13
    )

    assert url == "meta/10x11:12x13/-300x-200/smart", url
开发者ID:rootart,项目名称:thumbor,代码行数:17,代码来源:test_urls.py

示例10: encrypt

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
    def encrypt(self,
                width,
                height,
                smart,
                adaptive,
                full,
                fit_in,
                flip_horizontal,
                flip_vertical,
                halign,
                valign,
                trim,
                crop_left,
                crop_top,
                crop_right,
                crop_bottom,
                filters,
                image):

        generated_url = Url.generate_options(
            width=width,
            height=height,
            smart=smart,
            meta=False,
            adaptive=adaptive,
            full=full,
            fit_in=fit_in,
            horizontal_flip=flip_horizontal,
            vertical_flip=flip_vertical,
            halign=halign,
            valign=valign,
            trim=trim,
            crop_left=crop_left,
            crop_top=crop_top,
            crop_right=crop_right,
            crop_bottom=crop_bottom,
            filters=filters
        )

        url = "%s/%s" % (generated_url, hashlib.md5(image).hexdigest())

        def pad(s):
            return s + (16 - len(s) % 16) * "{"

        cipher = AES.new(self.security_key, MODE_ECB)
        encrypted = base64.urlsafe_b64encode(cipher.encrypt(pad(url.encode('utf-8'))))

        return encrypted
开发者ID:okor,项目名称:thumbor,代码行数:50,代码来源:crypto.py

示例11: encrypt

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
    def encrypt(
        self,
        width,
        height,
        smart,
        adaptive,
        fit_in,
        flip_horizontal,
        flip_vertical,
        halign,
        valign,
        crop_left,
        crop_top,
        crop_right,
        crop_bottom,
        filters,
        image,
    ):

        url = "%s/%s" % (
            Url.generate_options(
                width=width,
                height=height,
                smart=smart,
                meta=False,
                adaptive=adaptive,
                fit_in=fit_in,
                horizontal_flip=flip_horizontal,
                vertical_flip=flip_vertical,
                halign=halign,
                valign=valign,
                crop_left=crop_left,
                crop_top=crop_top,
                crop_right=crop_right,
                crop_bottom=crop_bottom,
                filters=filters,
            ),
            hashlib.md5(image).hexdigest(),
        )

        pad = lambda s: s + (16 - len(s) % 16) * "{"
        cipher = AES.new(self.security_key)
        encrypted = base64.urlsafe_b64encode(cipher.encrypt(pad(url.encode("utf-8"))))

        return encrypted
开发者ID:bguided,项目名称:thumbor,代码行数:47,代码来源:crypto.py

示例12: test_default_url

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_default_url():
    url = Url.generate_options()
    assert url == "0x0"
开发者ID:rootart,项目名称:thumbor,代码行数:5,代码来源:test_urls.py

示例13: test_url_generate_with_meta

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_url_generate_with_meta():
    url = Url.generate_options(
        meta=True
    )

    assert url == "meta/0x0"
开发者ID:rootart,项目名称:thumbor,代码行数:8,代码来源:test_urls.py

示例14: test_can_generate_url_with_defaults

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
    def test_can_generate_url_with_defaults(self):
        url = Url.generate_options()

        expect(url).to_be_empty()
开发者ID:5um1th,项目名称:thumbor,代码行数:6,代码来源:test_url.py

示例15: test_can_generate_url_with_fitin

# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
    def test_can_generate_url_with_fitin(self):
        url = Url.generate_options(fit_in=True, adaptive=False, full=False)

        expect(url).to_equal('fit-in')
开发者ID:5um1th,项目名称:thumbor,代码行数:6,代码来源:test_url.py


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