本文整理汇总了Python中thumbor.loaders.http_loader.validate函数的典型用法代码示例。如果您正苦于以下问题:Python validate函数的具体用法?Python validate怎么用?Python validate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validate函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_with_allowed_sources
def test_with_allowed_sources(self):
config = Config()
config.ALLOWED_SOURCES = [
's.glbimg.com',
re.compile(r'https://www\.google\.com/img/.*')
]
ctx = Context(None, config, None)
expect(
loader.validate(
ctx,
'http://www.google.com/logo.jpg'
)
).to_be_false()
expect(
loader.validate(
ctx,
'http://s2.glbimg.com/logo.jpg'
)
).to_be_false()
expect(
loader.validate(
ctx,
'/glob=:sfoir%20%20%3Co-pmb%20%20%20%20_%20%20%20%200%20%20g.-%3E%3Ca%20hplass='
)
).to_be_false()
expect(
loader.validate(
ctx,
'https://www.google.com/img/logo.jpg'
)
).to_be_true()
expect(
loader.validate(ctx, 'http://s.glbimg.com/logo.jpg')).to_be_true()
示例2: test_with_allowed_sources
def test_with_allowed_sources(self):
config = Config()
config.ALLOWED_SOURCES = ["s.glbimg.com"]
ctx = Context(None, config, None)
expect(loader.validate(ctx, "http://www.google.com/logo.jpg")).to_be_false()
expect(loader.validate(ctx, "http://s2.glbimg.com/logo.jpg")).to_be_false()
expect(
loader.validate(ctx, "/glob=:sfoir%20%20%3Co-pmb%20%20%20%20_%20%20%20%200%20%20g.-%3E%3Ca%20hplass=")
).to_be_false()
expect(loader.validate(ctx, "http://s.glbimg.com/logo.jpg")).to_be_true()
示例3: validate
def validate(context, url):
return http_loader.validate(context, url, normalize_url_func=_normalize_url)
示例4: test_without_allowed_sources
def test_without_allowed_sources(self):
config = Config()
config.ALLOWED_SOURCES = []
ctx = Context(None, config, None)
is_valid = loader.validate(ctx, 'http://www.google.com/logo.jpg')
expect(is_valid).to_be_true()
示例5: topic
def topic(self):
config = Config()
config.ALLOWED_SOURCES = ['s.glbimg.com']
ctx = Context(None, config, None)
is_valid = loader.validate(ctx, 'http://s.glbimg.com/logo.jpg')
return is_valid
示例6: validate
def validate(context, url):
if url.startswith('http://'):
return False
return http_loader.validate(context, url, normalize_url_func=_normalize_url)
示例7: _validate
def _validate(context, url, normalize_url_func):
if _use_http_loader(context, url):
return http_loader.validate(context, url, normalize_url_func=http_loader._normalize_url)
bucket, key = _get_bucket_and_key(context, url)
return _validate_bucket(context, bucket)
示例8: topic
def topic(self):
old_sources = options.ALLOWED_SOURCES
options.ALLOWED_SOURCES = []
is_valid = loader.validate('http://www.google.com/logo.jpg')
options.ALLOWED_SOURCES = old_sources
return is_valid
示例9: topic
def topic(self):
return loader.validate("http://www.google.com/logo.jpg")