/usr/lib/python2.7/dist-packages/pipeline/finders.py is in python-django-pipeline 1.5.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | from itertools import chain
from django.contrib.staticfiles.storage import staticfiles_storage
from django.contrib.staticfiles.finders import BaseFinder, BaseStorageFinder, find, \
AppDirectoriesFinder as DjangoAppDirectoriesFinder, FileSystemFinder as DjangoFileSystemFinder
from django.utils._os import safe_join
from pipeline.conf import settings
class PipelineFinder(BaseStorageFinder):
storage = staticfiles_storage
def find(self, path, all=False):
if not settings.PIPELINE_ENABLED:
return super(PipelineFinder, self).find(path, all)
else:
return []
def list(self, ignore_patterns):
return []
class ManifestFinder(BaseFinder):
def find(self, path, all=False):
"""
Looks for files in PIPELINE_CSS and PIPELINE_JS
"""
matches = []
for elem in chain(settings.PIPELINE_CSS.values(), settings.PIPELINE_JS.values()):
if elem['output_filename'] == path:
match = safe_join(settings.PIPELINE_ROOT, path)
if not all:
return match
matches.append(match)
return matches
def list(self, *args):
return []
class CachedFileFinder(BaseFinder):
def find(self, path, all=False):
"""
Work out the uncached name of the file and look that up instead
"""
try:
start, _, extn = path.rsplit('.', 2)
except ValueError:
return []
path = '.'.join((start, extn))
return find(path, all=all) or []
def list(self, *args):
return []
class PatternFilterMixin(object):
ignore_patterns = []
def get_ignored_patterns(self):
return list(set(self.ignore_patterns))
def list(self, ignore_patterns):
if ignore_patterns:
ignore_patterns = ignore_patterns + self.get_ignored_patterns()
return super(PatternFilterMixin, self).list(ignore_patterns)
class AppDirectoriesFinder(PatternFilterMixin, DjangoAppDirectoriesFinder):
"""
Like AppDirectoriesFinder, but doesn't return any additional ignored
patterns.
This allows us to concentrate/compress our components without dragging
the raw versions in via collectstatic.
"""
ignore_patterns = [
'*.js',
'*.css',
'*.less',
'*.scss',
'*.styl',
]
class FileSystemFinder(PatternFilterMixin, DjangoFileSystemFinder):
"""
Like FileSystemFinder, but doesn't return any additional ignored patterns
This allows us to concentrate/compress our components without dragging
the raw versions in too.
"""
ignore_patterns = [
'*.js',
'*.css',
'*.less',
'*.scss',
'*.styl',
'*.sh',
'*.html',
'*.md',
'*.markdown',
'*.php',
'*.txt',
'README*',
'LICENSE*',
'*examples*',
'*test*',
'*bin*',
'*samples*',
'*docs*',
'*build*',
'*demo*',
'Makefile*',
'Gemfile*',
'node_modules',
]
|