jazzband / django-pipeline

Pipeline is an asset packaging library for Django.
https://django-pipeline.readthedocs.io/
MIT License
1.52k stars 371 forks source link

Specify Files Recursively with ** wildcard #208

Open ilovett opened 11 years ago

ilovett commented 11 years ago

This would essentially allow for recursive inclusion of files in all subfolders.

For example, currently would have to include files

"path/*/*.js",
"path/*/*/*.js",
"path/*/*/*/*.js"

This would be simplified with:

"path/**/*.js"
gcko commented 11 years ago

Is this not supported by using a double star wildcard?

cyberdelia commented 11 years ago

Pipeline use a very similar to python glob implementation, so double star should work.

ilovett commented 11 years ago

I will retest when I get a chance in a week or 2.

On Apr 28, 2013, at 7:13 PM, Timothée Peignier notifications@github.com wrote:

Pipeline use a very similar to python glob implementation, so double star should work.

— Reply to this email directly or view it on GitHub.

ilovett commented 11 years ago

Got a chance to re-test. Double star **/*.js will include folder/file.js but will not recursively include folder/folder/file.js

In order to get folder/folder/file.js , I need to set up **/**/*.js

Is double star intended to include recursively? Or just 1 directory deep wildcard inclusion?

rickeyvisinski-kanban commented 10 years ago

@ilovett are you on OSX by an chance?

ilovett commented 10 years ago

@rickeyvisinski-kanban running on ubuntu...

Looks like I have misunderstood use of ** by fluke it was just acting as a single *.

Update: It is my understanding now that ** should universally mean "recursive subfolders". It looks like the glob documentation which @cyberdelia mentioned only supports single *. I see some discussion opened in adding it to python glob here.

We would essentially need to setup ** to mean recursive folder and implement this way

rickeyvisinski-kanban commented 10 years ago

Its not a fluke, its the way python's globbing currently works, eg they haven't implemented the globstar match.

Even if they had, pipeline uses default storage for static assets, we have no access to os.walk, basically only exists and listdir.

I took a stab at implementing the globstar on my branch https://github.com/rickeyvisinski-kanban/django-pipeline/tree/globstar; however, now that path/*/.js works, it broke the original globbing so I have some more work to do.

cdimoulis commented 10 years ago

I have been searching for this for a while and am just wondering if there are plans for this recursive function to be implemented any time soon. Instead of having to list all potential subdirectories it would be nice to just list a directory and include all of its subdirectories.

cyberdelia commented 10 years ago

I've been using thing like views/**/*.coffee for a while :expressionless:

cdimoulis commented 10 years ago

Hmm so what am I missing? My directory structure is

And my PIPELINE_JS is

PIPELINE_JS = {
  'views': {
    'source_filenames': (
      'coffee/views/**/*.coffee',
    ),
    'output_filename': 'js/views/views.js,
  }
}

However only first.coffee and second.coffee get compiled to js and appear on my page. However subone.coffee is never seen. What would I be missing since the first level of directories are reached, but not the second level?

EDIT

Forgot about this. If it ends up mattering I'm using django 1.6.6 and Python 3.4.1. Let me know if that would be the issue.

ilovett commented 10 years ago

@cdimoulis ** doesn't work recursively, you have use if for each depth IE:

'coffee/views/**/*.coffee',
'coffee/views/**/**/*.coffee',
cyberdelia commented 10 years ago

Oh god :confused:

arve0 commented 9 years ago

For other finding this through google: https://pypi.python.org/pypi/glob2

sabapathim commented 3 years ago

Make does not offer a recursive wildcard function, so here's one:

rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))

How to recursively find all files with the same name in a given folder ALL_MAKEFILES := $(call rwildcard,src/,Makefile.mk)

How to recursively find all files that match a pattern SUBDIRS = $(call rwildcard,src/,.mk)