Commit afa88728 authored by Nicolas Delaby's avatar Nicolas Delaby

Raise explicit Error if no handler is found according given configuration.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@43973 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5b629e44
...@@ -40,6 +40,8 @@ from cloudooo.interfaces.granulate import IImageGranulator ...@@ -40,6 +40,8 @@ from cloudooo.interfaces.granulate import IImageGranulator
from cloudooo.interfaces.granulate import ITextGranulator from cloudooo.interfaces.granulate import ITextGranulator
from fnmatch import fnmatch from fnmatch import fnmatch
class HandlerNotFound(Exception):
pass
def getHandlerObject(source_format, destination_format, def getHandlerObject(source_format, destination_format,
mimetype_registry, handler_dict): mimetype_registry, handler_dict):
...@@ -51,6 +53,8 @@ def getHandlerObject(source_format, destination_format, ...@@ -51,6 +53,8 @@ def getHandlerObject(source_format, destination_format,
if fnmatch(source_mimetype, registry_list[0]) and \ if fnmatch(source_mimetype, registry_list[0]) and \
(fnmatch(destination_mimetype, registry_list[1]) or destination_format is None): (fnmatch(destination_mimetype, registry_list[1]) or destination_format is None):
return handler_dict[registry_list[2]] return handler_dict[registry_list[2]]
raise HandlerNotFound('No Handler found for %r=>%r' % (source_format,
destination_format))
class Manager(object): class Manager(object):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment