1
0
Fork 0
mirror of https://github.com/correl/openapi-core.git synced 2025-04-05 17:00:11 -09:00
openapi-core/openapi_core/schema/content/models.py
2019-06-18 14:54:02 +01:00

21 lines
511 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(mimetype, list(self.keys()))