Beispiel #1
0
    def get_item(self, name):
        ext = os.path.splitext(name)[1].lstrip('.')
        backend_classes = []

        if ext in DEFAULT_MEDIA_FILTERS and self.should_use_default_filter(ext):
            ext_class = DEFAULT_MEDIA_FILTERS[ext]
            if isinstance(ext_class, basestring):
                backend_classes.append(load_backend(DEFAULT_MEDIA_FILTERS[ext]))
            elif isinstance(ext_class, tuple):
                backend_classes.append(FilterPipe)
                for pipe_entry in ext_class:
                    backend_classes.append(load_backend(pipe_entry))
        else:
            backend_classes.append(self.file_filter)


        backends = []
        for backend_class in backend_classes:
            config = backend_class.from_default(name)
            config.setdefault('filter',
                '%s.%s' % (backend_class.__module__, backend_class.__name__))
            config.setdefault('filetype', self.input_filetype)
            config['bundle'] = self.bundle
            # This is added to make really sure we don't instantiate the same
            # filter in an endless loop. Normally, the child class should
            # take care of this in should_use_default_filter().
            config.setdefault('_from_default', ext)
            backends.append(backend_class(**config))

        backend = backends.pop(0)
        for pipe_entry in backends:
            backend.grow_pipe(pipe_entry)

        return backend
Beispiel #2
0
def _process_includes(bundles):
    ret = []
    for bundle in bundles:
        if bundle[0] == 'include':
            # each bundle in MEDIA_BUNDLES can contain tuples ('bundle', 'path.to.included.bundle')
            # the bundle at 'path.to.included.bundle' will be extended into this one
            ret.extend(load_backend(bundle[1]))
        else:
            ret.append(bundle)
    return ret
Beispiel #3
0
def _load_root_filter_uncached(bundle):
    if bundle in MEDIA_BUNDLES:
        input = MEDIA_BUNDLES.get(bundle)
    else:
        raise ValueError('Could not find media bundle "%s"' % bundle)
    filetype = os.path.splitext(bundle)[-1].lstrip('.')
    root_filters = _get_root_filters_list(filetype)
    backend_class = load_backend(root_filters[-1])
    for filter in reversed(root_filters[:-1]):
        input = [{'filter': filter, 'input': input}]

    return backend_class(filter=root_filters[-1], filetype=filetype,
                         bundle=bundle, input=input)
def _load_root_filter_uncached(bundle):
    for items in MEDIA_BUNDLES:
        if items[0] == bundle:
            input = items[1:]
            break
    else:
        raise ValueError('Could not find media bundle "%s"' % bundle)
    filetype = os.path.splitext(bundle)[-1].lstrip(".")
    root_filters = _get_root_filters_list(filetype)
    backend_class = load_backend(root_filters[-1])
    for filter in reversed(root_filters[:-1]):
        input = [{"filter": filter, "input": input}]

    return backend_class(filter=root_filters[-1], filetype=filetype, bundle=bundle, input=input)
Beispiel #5
0
    def get_item(self, name):
        ext = os.path.splitext(name)[1].lstrip('.')
        backend_classes = []

        if ext in DEFAULT_MEDIA_FILTERS and self.should_use_default_filter(
                ext):
            ext_class = DEFAULT_MEDIA_FILTERS[ext]
            if isinstance(ext_class, basestring):
                backend_classes.append(load_backend(
                    DEFAULT_MEDIA_FILTERS[ext]))
            elif isinstance(ext_class, tuple):
                backend_classes.append(FilterPipe)
                for pipe_entry in ext_class:
                    backend_classes.append(load_backend(pipe_entry))
        else:
            backend_classes.append(self.file_filter)

        backends = []
        for backend_class in backend_classes:
            config = backend_class.from_default(name)
            config.setdefault(
                'filter',
                '%s.%s' % (backend_class.__module__, backend_class.__name__))
            config.setdefault('filetype', self.input_filetype)
            config['bundle'] = self.bundle
            # This is added to make really sure we don't instantiate the same
            # filter in an endless loop. Normally, the child class should
            # take care of this in should_use_default_filter().
            config.setdefault('_from_default', ext)
            backends.append(backend_class(**config))

        backend = backends.pop(0)
        for pipe_entry in backends:
            backend.grow_pipe(pipe_entry)

        return backend
Beispiel #6
0
def _load_root_filter_uncached(bundle):
    for items in _get_media_bundles():
        if items[0] == bundle:
            input = items[1:]
            break
    else:
        raise ValueError('Could not find media bundle "%s"' % bundle)
    filetype = os.path.splitext(bundle)[-1].lstrip('.')
    root_filters = _get_root_filters_list(filetype)
    backend_class = load_backend(root_filters[-1])
    for filter in reversed(root_filters[:-1]):
        input = [{'filter': filter, 'input': input}]

    return backend_class(filter=root_filters[-1], filetype=filetype,
                         bundle=bundle, input=input)
Beispiel #7
0
def _load_root_filter_uncached(bundle):
    if bundle in MEDIA_BUNDLES:
        input = MEDIA_BUNDLES.get(bundle)
    else:
        raise ValueError('Could not find media bundle "%s"' % bundle)
    filetype = os.path.splitext(bundle)[-1].lstrip('.')
    root_filters = _get_root_filters_list(filetype)
    backend_class = load_backend(root_filters[-1])
    for filter in reversed(root_filters[:-1]):
        input = [{'filter': filter, 'input': input}]

    return backend_class(filter=root_filters[-1],
                         filetype=filetype,
                         bundle=bundle,
                         input=input)
Beispiel #8
0
    def get_item(self, name):
        ext = os.path.splitext(name)[1].lstrip('.')
        if ext in DEFAULT_MEDIA_FILTERS and self.should_use_default_filter(ext):
            backend_class = load_backend(DEFAULT_MEDIA_FILTERS[ext])
        else:
            backend_class = self.file_filter

        config = backend_class.from_default(name)
        config.setdefault('filter',
            '%s.%s' % (backend_class.__module__, backend_class.__name__))
        config.setdefault('filetype', self.input_filetype)
        # This is added to make really sure we don't instantiate the same
        # filter in an endless loop. Normally, the child class should
        # take care of this in should_use_default_filter().
        config.setdefault('_from_default', ext)
        return backend_class(**config)
Beispiel #9
0
    def get_item(self, name):
        ext = os.path.splitext(name)[1].lstrip('.')
        if ext in DEFAULT_MEDIA_FILTERS and self.should_use_default_filter(ext):
            backend_class = load_backend(DEFAULT_MEDIA_FILTERS[ext])
        else:
            backend_class = self.file_filter

        config = backend_class.from_default(name)
        config.setdefault('filter',
            '%s.%s' % (backend_class.__module__, backend_class.__name__))
        config.setdefault('filetype', self.input_filetype)
        config['bundle'] = self.bundle
        # This is added to make really sure we don't instantiate the same
        # filter in an endless loop. Normally, the child class should
        # take care of this in should_use_default_filter().
        config.setdefault('_from_default', ext)
        return backend_class(**config)
Beispiel #10
0
 def get_filter(self, config):
     backend_class = load_backend(config.get('filter'))
     return backend_class(filetype=self.input_filetype,
                          bundle=self.bundle,
                          **config)
Beispiel #11
0
 def get_filter(self, config):
     backend_class = load_backend(config.get('filter'))
     return backend_class(filetype=self.input_filetype, bundle=self.bundle,
                          **config)