diff --git a/django/contrib/staticfiles/finders.py b/django/contrib/staticfiles/finders.py
index 7b4c7c8..30986e9 100644
|
|
|
class BaseFinder(object):
|
| 28 | 28 | """ |
| 29 | 29 | raise NotImplementedError() |
| 30 | 30 | |
| 31 | | def list(self, ignore_patterns): |
| | 31 | def list(self, ignore_patterns, include_patterns): |
| 32 | 32 | """ |
| 33 | 33 | Given an optional list of paths to ignore, this should return |
| 34 | 34 | a two item iterable consisting of the relative path and storage |
| … |
… |
class FileSystemFinder(BaseFinder):
|
| 96 | 96 | if os.path.exists(path): |
| 97 | 97 | return path |
| 98 | 98 | |
| 99 | | def list(self, ignore_patterns): |
| | 99 | def list(self, ignore_patterns, include_patterns): |
| 100 | 100 | """ |
| 101 | 101 | List all files in all locations. |
| 102 | 102 | """ |
| 103 | 103 | for prefix, root in self.locations: |
| 104 | 104 | storage = self.storages[root] |
| 105 | | for path in utils.get_files(storage, ignore_patterns): |
| | 105 | for path in utils.get_files(storage, ignore_patterns, include_patterns): |
| 106 | 106 | yield path, storage |
| 107 | 107 | |
| 108 | 108 | |
| … |
… |
class AppDirectoriesFinder(BaseFinder):
|
| 128 | 128 | self.apps.append(app) |
| 129 | 129 | super(AppDirectoriesFinder, self).__init__(*args, **kwargs) |
| 130 | 130 | |
| 131 | | def list(self, ignore_patterns): |
| | 131 | def list(self, ignore_patterns, include_patterns): |
| 132 | 132 | """ |
| 133 | 133 | List all files in all app storages. |
| 134 | 134 | """ |
| 135 | 135 | for storage in self.storages.itervalues(): |
| 136 | 136 | if storage.exists(''): # check if storage location exists |
| 137 | | for path in utils.get_files(storage, ignore_patterns): |
| | 137 | for path in utils.get_files(storage, ignore_patterns, include_patterns): |
| 138 | 138 | yield path, storage |
| 139 | 139 | |
| 140 | 140 | def find(self, path, all=False): |
| … |
… |
class BaseStorageFinder(BaseFinder):
|
| 203 | 203 | return match |
| 204 | 204 | return [] |
| 205 | 205 | |
| 206 | | def list(self, ignore_patterns): |
| | 206 | def list(self, ignore_patterns, include_patterns): |
| 207 | 207 | """ |
| 208 | 208 | List all files of the storage. |
| 209 | 209 | """ |
| 210 | | for path in utils.get_files(self.storage, ignore_patterns): |
| | 210 | for path in utils.get_files(self.storage, ignore_patterns, include_patterns): |
| 211 | 211 | yield path, self.storage |
| 212 | 212 | |
| 213 | 213 | |
diff --git a/django/contrib/staticfiles/management/commands/collectstatic.py b/django/contrib/staticfiles/management/commands/collectstatic.py
index 18f8893..9f6005c 100644
|
|
|
Type 'yes' to continue, or 'no' to cancel: """
|
| 116 | 116 | |
| 117 | 117 | found_files = [] |
| 118 | 118 | for finder in finders.get_finders(): |
| 119 | | for path, storage in finder.list(self.ignore_patterns): |
| | 119 | for path, storage in finder.list(self.ignore_patterns, None): |
| 120 | 120 | # Prefix the relative path if the source storage contains it |
| 121 | 121 | if getattr(storage, 'prefix', None): |
| 122 | 122 | prefixed_path = os.path.join(storage.prefix, path) |
diff --git a/django/contrib/staticfiles/utils.py b/django/contrib/staticfiles/utils.py
index f500ed6..21e979b 100644
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
| 6 | 6 | def matches_patterns(path, patterns=None): |
| 7 | 7 | """ |
| 8 | 8 | Return True or False depending on whether the ``path`` should be |
| 9 | | ignored (if it matches any pattern in ``ignore_patterns``). |
| | 9 | ignored (if it matches any pattern in ``patterns``). |
| 10 | 10 | """ |
| 11 | 11 | if patterns is None: |
| 12 | 12 | patterns = [] |
| … |
… |
def matches_patterns(path, patterns=None):
|
| 15 | 15 | return True |
| 16 | 16 | return False |
| 17 | 17 | |
| 18 | | def get_files(storage, ignore_patterns=None, location=''): |
| | 18 | def get_files(storage, ignore_patterns=None, include_patterns=None, location=''): |
| 19 | 19 | """ |
| 20 | 20 | Recursively walk the storage directories yielding the paths |
| 21 | 21 | of all files that should be copied. |
| 22 | 22 | """ |
| 23 | 23 | if ignore_patterns is None: |
| 24 | 24 | ignore_patterns = [] |
| | 25 | if include_patterns is None: |
| | 26 | include_patterns = [] |
| 25 | 27 | directories, files = storage.listdir(location) |
| 26 | 28 | for fn in files: |
| | 29 | if location: |
| | 30 | fn = os.path.normpath(os.path.join(location, fn)).replace('\\', '/') |
| 27 | 31 | if matches_patterns(fn, ignore_patterns): |
| 28 | 32 | continue |
| 29 | | if location: |
| 30 | | fn = os.path.join(location, fn) |
| | 33 | if include_patterns and not matches_patterns(fn, include_patterns): |
| | 34 | continue |
| 31 | 35 | yield fn |
| 32 | 36 | for dir in directories: |
| | 37 | if location: |
| | 38 | dir = os.path.normpath(os.path.join(location, dir)).replace('\\', '/') |
| 33 | 39 | if matches_patterns(dir, ignore_patterns): |
| 34 | 40 | continue |
| 35 | | if location: |
| 36 | | dir = os.path.join(location, dir) |
| 37 | | for fn in get_files(storage, ignore_patterns, dir): |
| | 41 | for fn in get_files(storage, ignore_patterns, include_patterns, dir): |
| 38 | 42 | yield fn |
| 39 | 43 | |
| 40 | 44 | def check_settings(base_url=None): |