8
8
import os .path
9
9
import subprocess
10
10
import sys
11
- from typing import NotRequired , TypedDict , List , Callable , Optional
11
+ from typing import Required , TypedDict , List , Callable , Optional
12
12
from concurrent .futures import ThreadPoolExecutor , as_completed
13
13
import time
14
14
import argparse
15
- import json
16
- import requests
17
15
import zipfile
18
16
import tarfile
19
17
import shutil
20
18
19
+ def missing_module (module_name : str ) -> None :
20
+ print (f"ERROR: { module_name } is not installed. Please install it with 'pip install { module_name } '." )
21
+ sys .exit (1 )
22
+
21
23
try :
22
24
import yaml
23
25
except ImportError :
24
- print (
25
- "ERROR: PyYAML is not installed. Please install it with 'pip install pyyaml'."
26
- )
27
- sys .exit (1 )
26
+ missing_module ("pyyaml" )
27
+
28
+ try :
29
+ import requests
30
+ except ImportError :
31
+ missing_module ("requests" )
28
32
29
33
import generate_mad as mad
30
34
37
41
38
42
39
43
# A project to generate models for
40
- class Project (TypedDict ):
41
- """
42
- Type definition for projects (acquired via a GitHub repo) to model.
43
-
44
- Attributes:
45
- name: The name of the project
46
- git_repo: URL to the git repository
47
- git_tag: Optional Git tag to check out
48
- """
49
-
50
- name : str
51
- git_repo : NotRequired [str ]
52
- git_tag : NotRequired [str ]
53
- with_sinks : NotRequired [bool ]
54
- with_sinks : NotRequired [bool ]
55
- with_summaries : NotRequired [bool ]
56
-
44
+ Project = TypedDict ("Project" , {
45
+ "name" : Required [str ],
46
+ "git-repo" : str ,
47
+ "git-tag" : str ,
48
+ "with-sinks" : bool ,
49
+ "with-sources" : bool ,
50
+ "with-summaries" : bool ,
51
+ }, total = False )
57
52
58
53
def should_generate_sinks (project : Project ) -> bool :
59
54
return project .get ("with-sinks" , True )
@@ -72,14 +67,14 @@ def clone_project(project: Project) -> str:
72
67
Shallow clone a project into the build directory.
73
68
74
69
Args:
75
- project: A dictionary containing project information with 'name', 'git_repo ', and optional 'git_tag ' keys.
70
+ project: A dictionary containing project information with 'name', 'git-repo ', and optional 'git-tag ' keys.
76
71
77
72
Returns:
78
73
The path to the cloned project directory.
79
74
"""
80
75
name = project ["name" ]
81
- repo_url = project ["git_repo " ]
82
- git_tag = project .get ("git_tag " )
76
+ repo_url = project ["git-repo " ]
77
+ git_tag = project .get ("git-tag " )
83
78
84
79
# Determine target directory
85
80
target_dir = os .path .join (build_dir , name )
@@ -178,7 +173,7 @@ def build_database(
178
173
Args:
179
174
language: The language for which to build the database (e.g., "rust").
180
175
extractor_options: Additional options for the extractor.
181
- project: A dictionary containing project information with 'name' and 'git_repo ' keys.
176
+ project: A dictionary containing project information with 'name' and 'git-repo ' keys.
182
177
project_dir: Path to the CodeQL database.
183
178
184
179
Returns:
0 commit comments