MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / list_files

Function list_files

tools/release/run-clang-format.py:64–95  ·  view source on GitHub ↗
(files, recursive=False, extensions=None, exclude=None)

Source from the content-addressed store, hash-verified

62
63
64def list_files(files, recursive=False, extensions=None, exclude=None):
65 if extensions is None:
66 extensions = []
67 if exclude is None:
68 exclude = []
69
70 out = []
71 for file in files:
72 if recursive and os.path.isdir(file):
73 for dirpath, dnames, fnames in os.walk(file):
74 fpaths = [
75 os.path.relpath(os.path.join(dirpath, fname), os.getcwd())
76 for fname in fnames
77 ]
78 for pattern in exclude:
79 # os.walk() supports trimming down the dnames list
80 # by modifying it in-place,
81 # to avoid unnecessary directory listings.
82 dnames[:] = [
83 x
84 for x in dnames
85 if not fnmatch.fnmatch(os.path.join(dirpath, x), pattern)
86 ]
87 fpaths = [x for x in fpaths if not fnmatch.fnmatch(x, pattern)]
88
89 for f in fpaths:
90 ext = os.path.splitext(f)[1][1:]
91 if ext in extensions:
92 out.append(f)
93 else:
94 out.append(file)
95 return out
96
97
98def make_diff(file, original, reformatted):

Callers 1

mainFunction · 0.85

Calls 2

walkMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected