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

Unified · Split

scripts/dtc/dt-extract-compatibles+11−8
@@ -49,6 +49,14 @@ def print_compat(filename, compatibles): · 48 unmodified lines
49 else:49 else:
50 print(*compatibles, sep='\n')50 print(*compatibles, sep='\n')
51 51
52def 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
52show_filename = False60show_filename = False
53 61
54if __name__ == "__main__":62if __name__ == "__main__":
@@ -59,11 +67,6 @@ if __name__ == "__main__": · 4 unmodified lines
59 67
60 show_filename = args.with_filename68 show_filename = args.with_filename
61 69
62 for f in args.cfile:70 for f in files_to_parse(args.cfile):
63 if os.path.isdir(f):71 compat_list = parse_compatibles(f)
64 for filename in glob.iglob(f + "/**/*.c", recursive=True):72 print_compat(f, compat_list)
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)