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))
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", [])
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))
def _format(v): yield [("highlight", "Form data:\n")] yield from base.format_dict(multidict.MultiDict(v))
def _format(v): yield [("highlight", "Form data:\n")] for message in base.format_dict(multidict.MultiDict(v)): yield message