Example #1
0
 def __call__(self, data, **metadata):
     try:
         data = data.decode("ascii", "strict")
     except ValueError:
         return None
     d = url.decode(data)
     return "URLEncoded form", base.format_dict(multidict.MultiDict(d))
Example #2
0
def test_view_query():
    d = ""
    v = full_eval(query.ViewQuery())
    f = v(d, query=multidict.MultiDict([("foo", "bar"), ("foo", "baz")]))
    assert f[0] == "Query"
    assert f[1] == [[("header", "foo: "), ("text", "bar")], [("header", "foo: "), ("text", "baz")]]

    assert v(d) == ("Query", [])
Example #3
0
 def __call__(self, data, **metadata):
     image_type = imghdr.what('', h=data)
     if image_type == 'png':
         image_metadata = image_parser.parse_png(data)
     elif image_type == 'gif':
         image_metadata = image_parser.parse_gif(data)
     elif image_type == 'jpeg':
         image_metadata = image_parser.parse_jpeg(data)
     elif image_type == 'ico':
         image_metadata = image_parser.parse_ico(data)
     else:
         image_metadata = [("Image Format", image_type or "unknown")]
     if image_type:
         view_name = "{} Image".format(image_type.upper())
     else:
         view_name = "Unknown Image"
     return view_name, base.format_dict(multidict.MultiDict(image_metadata))
Example #4
0
 def _format(v):
     yield [("highlight", "Form data:\n")]
     yield from base.format_dict(multidict.MultiDict(v))
Example #5
0
 def _format(v):
     yield [("highlight", "Form data:\n")]
     for message in base.format_dict(multidict.MultiDict(v)):
         yield message