diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-08-09 16:12:06 -0500 |
---|---|---|
committer | Rodney Ewing <ewing.rj@gmail.com> | 2013-08-16 15:30:16 -0700 |
commit | 4ba5bdd96ef3703d8da216ca3dd92f080214f164 (patch) | |
tree | a35212fa04861edcabbb398c707f8ef97ce805d8 /mediagoblin/processing/__init__.py | |
parent | 7a414c8d42d63685655c0142345dcae6c66726af (diff) | |
download | mediagoblin-4ba5bdd96ef3703d8da216ca3dd92f080214f164.tar.lz mediagoblin-4ba5bdd96ef3703d8da216ca3dd92f080214f164.tar.xz mediagoblin-4ba5bdd96ef3703d8da216ca3dd92f080214f164.zip |
Steps toward working "run" reprocessing command.
This commit sponsored by Philippe Casteleyn. Thank you!
Diffstat (limited to 'mediagoblin/processing/__init__.py')
-rw-r--r-- | mediagoblin/processing/__init__.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/mediagoblin/processing/__init__.py b/mediagoblin/processing/__init__.py index 9e77d2b2..6ef203cb 100644 --- a/mediagoblin/processing/__init__.py +++ b/mediagoblin/processing/__init__.py @@ -126,7 +126,7 @@ class MediaProcessor(object): raise NotImplementedError @classmethod - def media_is_eligibile(cls, media_entry): + def media_is_eligible(cls, media_entry): raise NotImplementedError ############################### @@ -146,6 +146,11 @@ class MediaProcessor(object): ########################################## +class ProcessingKeyError(Exception): pass +class ProcessorDoesNotExist(ProcessingKeyError): pass +class ProcessorNotEligible(ProcessingKeyError): pass + + class ProcessingManager(object): """Manages all the processing actions available for a media type @@ -183,6 +188,25 @@ class ProcessingManager(object): # Got to figure out what actually goes here before I can write this properly pass + def get_processor(self, key, entry=None): + """ + Get the processor with this key. + + If entry supplied, make sure this entry is actually compatible; + otherwise raise error. + """ + try: + processor = self.processors[key] + except KeyError: + raise ProcessorDoesNotExist( + "'%s' processor does not exist for this media type" % key) + + if entry and not processor.media_is_eligible(entry): + raise ProcessorNotEligible( + "This entry is not eligible for processor with name '%s'" % key) + + return processor + def process(self, entry, directive, request): """ Process a media entry. |