Skip to content

Commit 124a651

Browse files
Merge pull request #20 from Anas-Elhounsri/dev
Release 0.1.1
2 parents 1056e2b + 86d5578 commit 124a651

File tree

1,805 files changed

+2597
-894493
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,805 files changed

+2597
-894493
lines changed

src/metacheck/cli.py

Lines changed: 73 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,74 @@
1-
import argparse
2-
import os
3-
from pathlib import Path
4-
from metacheck.run_somef import run_somef_batch
5-
from metacheck.run_analyzer import run_analysis
6-
7-
8-
def cli():
9-
parser = argparse.ArgumentParser(description="Detect metadata pitfalls in software repositories using SoMEF.")
10-
parser.add_argument(
11-
"--input",
12-
nargs="+",
13-
required=True,
14-
help="One or more JSON files containing repositories (e.g., GitHub, GitLab) OR existing SoMEF output files when using --skip-somef."
15-
)
16-
parser.add_argument(
17-
"--skip-somef",
18-
action="store_true",
19-
help="Skip SoMEF execution and analyze existing SoMEF output files directly. --input should point to SoMEF JSON files."
20-
)
21-
parser.add_argument(
22-
"--pitfalls-output",
23-
default=os.path.join(os.getcwd(), "pitfalls_outputs"),
24-
help="Directory to store pitfall JSON-LD files (default: ./pitfalls_outputs)."
25-
)
26-
parser.add_argument(
27-
"--analysis-output",
28-
default=os.path.join(os.getcwd(), "analysis_results.json"),
29-
help="File path for summary results (default: ./analysis_results.json)."
30-
)
31-
parser.add_argument(
32-
"--threshold",
33-
type=float,
34-
default=0.8,
35-
help="SoMEF confidence threshold (default: 0.8). Only used when running SoMEF."
36-
)
37-
38-
args = parser.parse_args()
39-
40-
if args.skip_somef:
41-
print(f"Skipping SoMEF execution. Analyzing {len(args.input)} existing SoMEF output files...")
42-
43-
somef_json_paths = []
44-
for json_path in args.input:
45-
if not os.path.exists(json_path):
46-
print(f"Warning: File not found, skipping: {json_path}")
47-
continue
48-
somef_json_paths.append(Path(json_path))
49-
50-
if not somef_json_paths:
51-
print("Error: No valid SoMEF output files found.")
52-
return
53-
54-
print(f"Analyzing {len(somef_json_paths)} SoMEF output files...")
55-
run_analysis(somef_json_paths, args.pitfalls_output, args.analysis_output)
56-
57-
else:
58-
threshold = args.threshold
59-
somef_output_dir = os.path.join(os.getcwd(), "somef_outputs")
60-
61-
print(f"Detected {len(args.input)} input files:")
62-
for json_path in args.input:
63-
if not os.path.exists(json_path):
64-
print(f"Skipping missing file: {json_path}")
65-
continue
66-
print(f"Processing repositories from {json_path}")
67-
run_somef_batch(json_path, somef_output_dir, threshold)
68-
69-
run_analysis(somef_output_dir, args.pitfalls_output, args.analysis_output)
70-
71-
72-
if __name__ == "__main__":
1+
import argparse
2+
import os
3+
from pathlib import Path
4+
from metacheck.run_somef import run_somef_batch
5+
from metacheck.run_analyzer import run_analysis
6+
7+
8+
def cli():
9+
parser = argparse.ArgumentParser(description="Detect metadata pitfalls in software repositories using SoMEF.")
10+
parser.add_argument(
11+
"--input",
12+
nargs="+",
13+
required=True,
14+
help="One or more JSON files containing repositories (e.g., GitHub, GitLab) OR existing SoMEF output files when using --skip-somef."
15+
)
16+
parser.add_argument(
17+
"--skip-somef",
18+
action="store_true",
19+
help="Skip SoMEF execution and analyze existing SoMEF output files directly. --input should point to SoMEF JSON files."
20+
)
21+
parser.add_argument(
22+
"--pitfalls-output",
23+
default=os.path.join(os.getcwd(), "pitfalls_outputs"),
24+
help="Directory to store pitfall JSON-LD files (default: ./pitfalls_outputs)."
25+
)
26+
parser.add_argument(
27+
"--analysis-output",
28+
default=os.path.join(os.getcwd(), "analysis_results.json"),
29+
help="File path for summary results (default: ./analysis_results.json)."
30+
)
31+
parser.add_argument(
32+
"--threshold",
33+
type=float,
34+
default=0.8,
35+
help="SoMEF confidence threshold (default: 0.8). Only used when running SoMEF."
36+
)
37+
38+
args = parser.parse_args()
39+
40+
if args.skip_somef:
41+
print(f"Skipping SoMEF execution. Analyzing {len(args.input)} existing SoMEF output files...")
42+
43+
somef_json_paths = []
44+
for json_path in args.input:
45+
if not os.path.exists(json_path):
46+
print(f"Warning: File not found, skipping: {json_path}")
47+
continue
48+
somef_json_paths.append(Path(json_path))
49+
50+
if not somef_json_paths:
51+
print("Error: No valid SoMEF output files found.")
52+
return
53+
54+
print(f"Analyzing {len(somef_json_paths)} SoMEF output files...")
55+
run_analysis(somef_json_paths, args.pitfalls_output, args.analysis_output)
56+
57+
else:
58+
threshold = args.threshold
59+
somef_output_dir = os.path.join(os.getcwd(), "somef_outputs")
60+
61+
print(f"Detected {len(args.input)} input files:")
62+
for json_path in args.input:
63+
if not os.path.exists(json_path):
64+
print(f"Skipping missing file: {json_path}")
65+
continue
66+
print(f"Processing repositories from {json_path}")
67+
run_somef_batch(json_path, somef_output_dir, threshold)
68+
69+
run_analysis(somef_output_dir, args.pitfalls_output, args.analysis_output)
70+
71+
72+
if __name__ == "__main__":
73+
print("!!!THIS IS THE CORRECT TEST VERSION (MSR26) FIXING ONLY W003!!!")
7374
cli()

0 commit comments

Comments
 (0)