Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic file selection #45

Closed
octaflop opened this issue May 18, 2011 · 3 comments
Closed

dynamic file selection #45

octaflop opened this issue May 18, 2011 · 3 comments

Comments

@octaflop
Copy link

This is just a feature request/help for implementing a function to automagically bundle all files of a certain type in a directory. I tried writing my own function:

def make_css_bundle(media_root, dir):
    files = os.listdir(os.path.join(media_root, dir))
    files.sort()
    files = [os.path.join(dir, f) for f in files]
    return files

and calling it like this:

css_all = Bundle(
                make_css_bundle(STATIC_ROOT, 'verbena/css'),
                make_css_bundle(STATIC_ROOT, 'verbena/diversifist/css'),
                filters='cssmin', output='gen/all.css')

but I'm running into errors because the Bundle._build function doesn't support lists (I'm not that great of a programmer, so I gave up). I think this feature is important as it will allow a user to use Pinax css folders without hand-coding each file.

@miracle2k
Copy link
Owner

This should work (with the git version anyway, not sure about the release):

css_all = Bundle('verbena/css/*.css', 'verbena/diversifist/css/*', filters=....)

@miracle2k
Copy link
Owner

FWIW, to make your approach work, you'd need to concat everything to a single list, and then use Python's * syntax to pass the list items as individual arguments:

file_list = make_css_bundle() + make_css_bundle() + ['a', 'b', 'c']
Bundle(*file_list, filters=...)

@octaflop
Copy link
Author

Thanks for your help! Great plugin, keep up the good work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants