autojson: handle recursion
In order to allow the configurations directory to have vendor
subdirectories, modify the script slightly for directory traversal
to handle subdirectories.
Tested:
After performing a `git mv`, the subdirectory files show up in the
`format-code` output.
```
...
formatting file configurations/meta/terminus_2x100g_nic_tsff.json
...
```
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ib8cea8053d558c60e0a89dd6dcddbc4bc0d970fb
diff --git a/scripts/autojson.py b/scripts/autojson.py
index afbe696..263336e 100755
--- a/scripts/autojson.py
+++ b/scripts/autojson.py
@@ -87,13 +87,15 @@
return "\n".join(result)
-files = argv[1:]
+files = []
-for file in files[:]:
- if os.path.isdir(file):
- files.remove(file)
- for f in os.listdir(file):
- files.append(os.path.join(file, f))
+for file in argv[1:]:
+ if not os.path.isdir(file):
+ files.append(file)
+ continue
+ for root, _, filenames in os.walk(file):
+ for f in filenames:
+ files.append(os.path.join(root, f))
for file in files:
if not file.endswith(".json"):