-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathadd_vendordep.py
More file actions
37 lines (27 loc) · 1.04 KB
/
add_vendordep.py
File metadata and controls
37 lines (27 loc) · 1.04 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
import json
import argparse
from pathlib import Path
import shutil
def add_vendordep(vendordep_filename):
vendordep_contents = json.loads(vendordep_filename.read_bytes())
year = vendordep_contents["frcYear"]
metadata_filename = Path(f"{year}_metadata.json")
metadata_contents = json.loads(metadata_filename.read_bytes())
for metadata_lib in metadata_contents:
if metadata_lib["uuid"] == vendordep_contents["uuid"]:
break
else:
raise Exception(
"This appears to be a new library that does not have metadata associated with it. Can not automatically update"
)
vendordep_destination = Path(f"{year}/{vendordep_filename.name}")
shutil.copy(vendordep_filename, vendordep_destination)
def main():
parser = argparse.ArgumentParser(
"Generates one or more vendordep repository bundles for publication"
)
parser.add_argument("--vendordep_file", type=Path)
args = parser.parse_args()
add_vendordep(args.vendordep_file)
if __name__ == "__main__":
main()