Commit eb2139fc authored by Nícolas F. R. A. Prado's avatar Nícolas F. R. A. Prado Committed by Rob Herring

dt: dt-extract-compatibles: Handle cfile arguments in generator function

Move the handling of the cfile arguments to a separate generator
function to avoid redundancy.
Signed-off-by: default avatarNícolas F. R. A. Prado <nfraprado@collabora.com>
Link: https://lore.kernel.org/r/20230828211424.2964562-2-nfraprado@collabora.comSigned-off-by: default avatarRob Herring <robh@kernel.org>
parent 0bb80ecc
...@@ -49,6 +49,14 @@ def print_compat(filename, compatibles): ...@@ -49,6 +49,14 @@ def print_compat(filename, compatibles):
else: else:
print(*compatibles, sep='\n') print(*compatibles, sep='\n')
def files_to_parse(path_args):
for f in path_args:
if os.path.isdir(f):
for filename in glob.iglob(f + "/**/*.c", recursive=True):
yield filename
else:
yield f
show_filename = False show_filename = False
if __name__ == "__main__": if __name__ == "__main__":
...@@ -59,11 +67,6 @@ if __name__ == "__main__": ...@@ -59,11 +67,6 @@ if __name__ == "__main__":
show_filename = args.with_filename show_filename = args.with_filename
for f in args.cfile: for f in files_to_parse(args.cfile):
if os.path.isdir(f): compat_list = parse_compatibles(f)
for filename in glob.iglob(f + "/**/*.c", recursive=True): print_compat(f, compat_list)
compat_list = parse_compatibles(filename)
print_compat(filename, compat_list)
else:
compat_list = parse_compatibles(f)
print_compat(f, compat_list)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment