mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-29 11:09:54 +00:00
22 lines
508 B
Python
22 lines
508 B
Python
|
"""OpenAPI core content models module"""
|
||
|
import fnmatch
|
||
|
|
||
|
from six import iteritems
|
||
|
|
||
|
from openapi_core.schema.content.exceptions import MimeTypeNotFound
|
||
|
|
||
|
|
||
|
class Content(dict):
|
||
|
|
||
|
def __getitem__(self, mimetype):
|
||
|
try:
|
||
|
return super(Content, self).__getitem__(mimetype)
|
||
|
except KeyError:
|
||
|
pass
|
||
|
|
||
|
for key, value in iteritems(self):
|
||
|
if fnmatch.fnmatch(mimetype, key):
|
||
|
return value
|
||
|
|
||
|
raise MimeTypeNotFound("{0} mimetype not found")
|