MCPcopy
hub / github.com/django/django / get_files

Function get_files

django/contrib/staticfiles/utils.py:16–39  ·  view source on GitHub ↗

Recursively walk the storage directories yielding the paths of all files that should be copied.

(storage, ignore_patterns=None, location="")

Source from the content-addressed store, hash-verified

14
15
16def get_files(storage, ignore_patterns=None, location=""):
17 """
18 Recursively walk the storage directories yielding the paths
19 of all files that should be copied.
20 """
21 if ignore_patterns is None:
22 ignore_patterns = []
23 directories, files = storage.listdir(location)
24 for fn in files:
25 # Match only the basename.
26 if matches_patterns(fn, ignore_patterns):
27 continue
28 if location:
29 fn = os.path.join(location, fn)
30 # Match the full file path.
31 if matches_patterns(fn, ignore_patterns):
32 continue
33 yield fn
34 for dir in directories:
35 if matches_patterns(dir, ignore_patterns):
36 continue
37 if location:
38 dir = os.path.join(location, dir)
39 yield from get_files(storage, ignore_patterns, dir)
40
41
42def check_settings(base_url=None):

Callers

nothing calls this directly

Calls 3

matches_patternsFunction · 0.85
listdirMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected