aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElrond <elrond+mediagoblin.org@samba-tng.org>2013-03-08 20:51:32 +0100
committerElrond <elrond+mediagoblin.org@samba-tng.org>2013-04-17 12:08:53 +0200
commite8676fa383975b37ac26e0908ec35da44afbc30a (patch)
tree2248f34dfdbea9861bb7206297737d1a5a3f0b9d
parent2077d6ed933773e0b44a7d1efa603453ea196fe3 (diff)
downloadmediagoblin-e8676fa383975b37ac26e0908ec35da44afbc30a.tar.lz
mediagoblin-e8676fa383975b37ac26e0908ec35da44afbc30a.tar.xz
mediagoblin-e8676fa383975b37ac26e0908ec35da44afbc30a.zip
MediaManager: Use .foo instead of ['foo'].
To make .media_fetch_order work, create a property.
-rw-r--r--mediagoblin/db/mixin.py2
-rw-r--r--mediagoblin/media_types/__init__.py9
-rw-r--r--mediagoblin/processing/task.py2
3 files changed, 7 insertions, 6 deletions
diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py
index db08dfd2..388bac89 100644
--- a/mediagoblin/db/mixin.py
+++ b/mediagoblin/db/mixin.py
@@ -149,7 +149,7 @@ class MediaEntryMixin(GenerateSlugMixin):
or, if not found, None.
"""
- fetch_order = self.media_manager.get("media_fetch_order")
+ fetch_order = self.media_manager.media_fetch_order
# No fetching order found? well, give up!
if not fetch_order:
diff --git a/mediagoblin/media_types/__init__.py b/mediagoblin/media_types/__init__.py
index 745e05ef..81acaee8 100644
--- a/mediagoblin/media_types/__init__.py
+++ b/mediagoblin/media_types/__init__.py
@@ -48,8 +48,9 @@ class CompatMediaManager(object):
def __contains__(self, i):
return (i in self.mm_dict)
- def get(self, *args, **kwargs):
- return self.mm_dict.get(*args, **kwargs)
+ @property
+ def media_fetch_order(self):
+ return self.mm_dict.get('media_fetch_order')
def __getattr__(self, i):
return self.mm_dict[i]
@@ -74,7 +75,7 @@ def sniff_media(media):
for media_type, manager in get_media_managers():
_log.info('Sniffing {0}'.format(media_type))
if 'sniff_handler' in manager and \
- manager['sniff_handler'](media_file, media=media):
+ manager.sniff_handler(media_file, media=media):
_log.info('{0} accepts the file'.format(media_type))
return media_type, manager
else:
@@ -119,7 +120,7 @@ def get_media_type_and_manager(filename):
for media_type, manager in get_media_managers():
# Omit the dot from the extension and match it against
# the media manager
- if ext[1:] in manager['accepted_extensions']:
+ if ext[1:] in manager.accepted_extensions:
return media_type, manager
else:
_log.info('File {0} has no file extension, let\'s hope the sniffers get it.'.format(
diff --git a/mediagoblin/processing/task.py b/mediagoblin/processing/task.py
index aec50aab..9af192ed 100644
--- a/mediagoblin/processing/task.py
+++ b/mediagoblin/processing/task.py
@@ -89,7 +89,7 @@ class ProcessMedia(task.Task):
with mgg.workbench_manager.create() as workbench:
proc_state.set_workbench(workbench)
# run the processing code
- entry.media_manager['processor'](proc_state)
+ entry.media_manager.processor(proc_state)
# We set the state to processed and save the entry here so there's
# no need to save at the end of the processing stage, probably ;)