History

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.

Nícolas F. R. A. Prado committed 3 years ago

Commit eb2139f1 parent 0bb80ec1 file · +11 −8Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/dtc/dt-extract-compatibles+11−8
@@ -49,6 +49,14 @@ def print_compat(filename, compatibles): · 48 unmodified lines
4949 else:
5050 print(*compatibles, sep='\n')
5151
52+def files_to_parse(path_args):
53+ for f in path_args:
54+ if os.path.isdir(f):
55+ for filename in glob.iglob(f + "/**/*.c", recursive=True):
56+ yield filename
57+ else:
58+ yield f
59+
5260 show_filename = False
5361
5462 if __name__ == "__main__":
@@ -59,11 +67,6 @@ if __name__ == "__main__": · 4 unmodified lines
5967
6068 show_filename = args.with_filename
6169
62− for f in args.cfile:
63− if os.path.isdir(f):
64− for filename in glob.iglob(f + "/**/*.c", recursive=True):
65− compat_list = parse_compatibles(filename)
66− print_compat(filename, compat_list)
67− else:
68− compat_list = parse_compatibles(f)
69− print_compat(f, compat_list)
70+ for f in files_to_parse(args.cfile):
71+ compat_list = parse_compatibles(f)
72+ print_compat(f, compat_list)