-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathupdate_client_versions.py
More file actions
55 lines (47 loc) · 1.75 KB
/
update_client_versions.py
File metadata and controls
55 lines (47 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
Copyright (C) Microsoft Corporation.
Copyright (C) 2025 IAMAI CONSULTING CORP
MIT License.
Update client version in repo files listed in the template directory
"""
import argparse
import pathlib
import projectairsimpp
def get_template_placeholder_files(path_root):
# Walk directory subtree and note each file
return path_root.resolve().glob("**/*")
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Apply the client version specification to the repo."
)
parser.add_argument(
"template_directory",
help="directory with files to be preprocessed to create the updated versions of the corresponding repo files",
type=str,
nargs="?",
default="templates",
)
args = parser.parse_args()
# Identify the template files
path_root = pathlib.Path(args.template_directory).resolve()
template_paths = get_template_placeholder_files(path_root)
template_files = []
for path in template_paths:
if path.is_file():
template_files.append(path)
# Identify the target files
path_cwd = pathlib.Path.cwd()
target_files = {}
for path in template_files:
target_files[path] = path_cwd / path.relative_to(path_root)
# Preprocess the template files to the target files
print(f'Processing template directory "{path_root}":')
for template_path, target_path in target_files.items():
target_exists = target_path.exists()
print(f" {template_path}", end="", flush=True)
projectairsimpp.preprocess_file(
filename_input=str(template_path),
filename_output=str(target_path),
log_level="info",
)
print(f" --> {target_path} ({'replaced' if target_exists else 'new'})")