diff options
| author | John Estabrook <jestabro@vyos.io> | 2026-05-20 10:50:10 -0500 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2026-05-28 08:31:26 -0500 |
| commit | 803dafbaf64dd39f15094c1219b2a59d14f2781c (patch) | |
| tree | 04c6ccc5507c2c12f4a573a44e12db12f42a67db /src/utils | |
| parent | 1f6a55bb039a94f1096a20b2dc11c4912ce8f6ce (diff) | |
| download | vyos-1x-803dafbaf64dd39f15094c1219b2a59d14f2781c.tar.gz vyos-1x-803dafbaf64dd39f15094c1219b2a59d14f2781c.zip | |
T8502: add util for updating config-sync-exclude.json
Diffstat (limited to 'src/utils')
| -rwxr-xr-x | src/utils/add-config-sync-exclude-paths.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/utils/add-config-sync-exclude-paths.py b/src/utils/add-config-sync-exclude-paths.py new file mode 100755 index 000000000..54a209490 --- /dev/null +++ b/src/utils/add-config-sync-exclude-paths.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +import sys +import json +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument('--file', default='data/config-sync-exclude.json') +parser.add_argument('--paths', nargs='+') + +args = parser.parse_args() +paths = args.paths +file = args.file + +try: + with open(file) as f: + exclude_str = json.load(f) +except FileNotFoundError: + print(f'Adding new file: {file}') + exclude_str = [] +except json.JSONDecodeError as e: + sys.exit(e) + +for path in (paths or []): + exclude_str.append(path.split()) + +with open(file, 'w') as f: + json.dump(exclude_str, f, indent=1) + f.write('\n') |
