Exemplo n.º 1
0
def assets_in_paths(app, segments):
    """
    Select some assets from all of the static paths in the app which match the
    given segments, and return the available basenames.

    Useful for getting a list of options for random selections of banners or
    other images.
    """

    names = []

    for path in app.static_paths:
        root = FilePath(path)
        fp = root.descendant(segments)

        # Get some banners, if they exist.
        if fp.exists():
            names.extend([p.basename() for p in fp.children()])

    return names