Skip to content

Commit 3788e55

Browse files
committed
updated the python script..
1 parent f9f7659 commit 3788e55

File tree

1 file changed

+4
-40
lines changed

1 file changed

+4
-40
lines changed

scripts/copy_spec.py

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,14 @@
11
#!/usr/bin/env python3
22
import os
33
import sys
4-
import json
5-
import yaml
64
import boto3
75
from pathlib import Path
86
from botocore.exceptions import ClientError
97

10-
def convert_yaml_to_json(yaml_path: Path, output_dir: Path) -> Path:
11-
"""Convert YAML file to JSON and return output file path."""
12-
try:
13-
with open(yaml_path, "r") as yf:
14-
data = yaml.safe_load(yf)
15-
except Exception as e:
16-
print(f"Error reading YAML file {yaml_path}: {e}")
17-
raise
18-
19-
json_filename = yaml_path.stem + ".json"
20-
output_path = output_dir / json_filename
21-
22-
try:
23-
with open(output_path, "w") as jf:
24-
json.dump(data, jf, indent=2)
25-
except Exception as e:
26-
print(f"Error writing JSON file {output_path}: {e}")
27-
raise
28-
29-
print(f"[OK] Converted {yaml_path}{output_path}")
30-
return output_path
31-
32-
338
def upload_to_s3(file_path: Path, bucket_name: str, folder_name: str):
349
"""Upload one file to the given S3 bucket under folder_name/."""
3510
s3 = boto3.client("s3")
36-
key = f"{folder_name}/{file_path.name}"
11+
key = f"{folder_name}/{file_path}"
3712

3813
try:
3914
s3.upload_file(str(file_path), bucket_name, key)
@@ -53,22 +28,11 @@ def main(bucket_name: str, repo_name: str, working_directory:str):
5328
cmdNew = os.getcwd()
5429
print("New working directory:", cmdNew)
5530

56-
#spec_dir = f"{repo_name}/Specification"
57-
58-
#print(f"[INFO] Checking for Specification folder at: {spec_dir}")
59-
60-
#if not spec_dir.exists():
61-
# print("[SKIP] No Specification folder found — skipping all processing.")
62-
# return 0
63-
64-
#json_file = list(Path(working_directory).glob("*.json"))
65-
66-
#print(json_file)
67-
68-
#if json_file:
69-
7031
json_file = f"{repo_name}.json"
7132
print(f"[INFO] Found JSON file: {json_file}")
33+
34+
35+
7236
upload_to_s3(json_file, bucket_name, repo_name)
7337

7438
print("[DONE] Processing complete.")

0 commit comments

Comments
 (0)