Did I find the right examples for you? yes no

All Samples(11)  |  Call(9)  |  Derive(0)  |  Import(2)
Bundle sorted resources together.

resources is expected to be a list previously sorted by sorted_resources.

Returns a list of renderable resources, which can include several
resources bundled together into Bundles.

        def bundle_resources(resources):
    """Bundle sorted resources together.

    resources is expected to be a list previously sorted by sorted_resources.

    Returns a list of renderable resources, which can include several
    resources bundled together into Bundles.
    """
    result = []
    bundle = Bundle()
    for resource in resources:
        if bundle.fits(resource):
            bundle.append(resource)
        else:
            # add the previous bundle to the list and create new bundle
            bundle.add_to_list(result)
            bundle = Bundle()
            if resource.dont_bundle:
                result.append(resource)
            else:
                bundle.append(resource)
    # add the last bundle to the list
    bundle.add_to_list(result)
    return result
        


src/f/a/fanstatic-1.0a5/tests/test_bundle.py   fanstatic(Download)
from fanstatic import Library, Resource, NeededResources, bundle_resources, sort_resources
from fanstatic import Inclusion
 
from fanstatic.core import Bundle
 
    x2 = Resource(foo, 'b.css')
 
    bundle = bundle_resources([x1, x2])
    assert len(bundle) == 1
    assert isinstance(bundle[0], Bundle)
 
    x3 = Resource(foo, 'c.css', dont_bundle=True)
    # x3 is not bundle safe.
    bundle = bundle_resources([x1, x3])
    # x2 and x1 are not bundled because x3 is in the way.
    # (sort_resources in NeededResources fixes the sorting)
    bundle = bundle_resources([x1, x3, x2])
    assert bundle == [x1, x3, x2]
 
    # The resources are sorted by renderer order, library dependencies
    # and resource dependencies.
    bundle = bundle_resources(sort_resources([x1, x3, x2]))

src/f/a/fanstatic-tools-0.2/fanstatic/test_core.py   fanstatic-tools(Download)
import six
 
from fanstatic import (Library,
                       Resource,
                       NeededResources,
    needed.need(b)
 
    resources = bundle_resources(needed.resources())
    assert len(resources) == 1
    bundle = resources[0]
    needed.need(c)
 
    resources = bundle_resources(needed.resources())
    assert len(resources) == 2
    assert resources[0].resources() == [a, b]
    needed.need(c)
 
    resources = bundle_resources(needed.resources())
    assert len(resources) == 2
    assert resources[0] is a