MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / list_files

Function list_files

scripts/run-clang-format.py:37–66  ·  view source on GitHub ↗
(files, recursive=False, extensions=None, exclude=None)

Source from the content-addressed store, hash-verified

35
36
37def list_files(files, recursive=False, extensions=None, exclude=None):
38 if extensions is None:
39 extensions = []
40 if exclude is None:
41 exclude = []
42
43 out = []
44 for file in files:
45 if recursive and os.path.isdir(file):
46 for dirpath, dnames, fnames in os.walk(file):
47 fpaths = [os.path.join(dirpath, fname) for fname in fnames]
48 for pattern in exclude:
49 # os.walk() supports trimming down the dnames list
50 # by modifying it in-place,
51 # to avoid unnecessary directory listings.
52 dnames[:] = [
53 x for x in dnames
54 if
55 not fnmatch.fnmatch(os.path.join(dirpath, x), pattern)
56 ]
57 fpaths = [
58 x for x in fpaths if not fnmatch.fnmatch(x, pattern)
59 ]
60 for f in fpaths:
61 ext = os.path.splitext(f)[1][1:]
62 if ext in extensions:
63 out.append(f)
64 else:
65 out.append(file)
66 return out
67
68
69def make_diff(file, original, reformatted):

Callers 1

mainFunction · 0.85

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected