diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-08-07 15:01:46 -0500 |
---|---|---|
committer | Rodney Ewing <ewing.rj@gmail.com> | 2013-08-16 15:30:15 -0700 |
commit | 14565fb72022e015ee9ba64cf087befb33516b71 (patch) | |
tree | f655ed1f51f60fe3d59c67b97e67b4614e1e2edd /mediagoblin/processing/__init__.py | |
parent | c541fb71f7f92ce13783400cf9b22083f38ae189 (diff) | |
download | mediagoblin-14565fb72022e015ee9ba64cf087befb33516b71.tar.lz mediagoblin-14565fb72022e015ee9ba64cf087befb33516b71.tar.xz mediagoblin-14565fb72022e015ee9ba64cf087befb33516b71.zip |
started coding basics of new processing code
Diffstat (limited to 'mediagoblin/processing/__init__.py')
-rw-r--r-- | mediagoblin/processing/__init__.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/mediagoblin/processing/__init__.py b/mediagoblin/processing/__init__.py index 5ce9281b..95f346d2 100644 --- a/mediagoblin/processing/__init__.py +++ b/mediagoblin/processing/__init__.py @@ -74,6 +74,58 @@ class FilenameBuilder(object): ext=self.ext) + + +class MediaProcessor(object): + # You MUST override this in the child MediaProcessor! + name = None + + def __init__(self, manager): + self.manager = manager + + def media_is_eligibile(self, media_entry): + raise NotImplementedError + + def process(self): + raise NotImplementedError + + def generate_parser(self): + raise NotImplementedError + + +class ProcessingManager(object): + def __init__(self, entry): + self.entry = entry + # May merge these two classes soon.... + self.state = ProcessingState(entry) + + # Dict of all MediaProcessors of this media type + self.processors = {} + + def add_processor(self, processor): + """ + Add a processor class to this media type + """ + name = processor.name + if name is None: + raise AttributeError("Processor class's .name attribute not set") + + self.processors[name] = processor + + def list_eligible_processors(self): + """ + List all processors that this media entry is eligible to be processed + for. + """ + return [ + processor + for processor in self.processors.keys() + if processor.media_is_eligible(self.entry)] + + def process(self, processor): + pass + + class ProcessingState(object): """ The first and only argument to the "processor" of a media type |