88import os .path
99import subprocess
1010import sys
11- from typing import NotRequired , TypedDict , List , Callable , Optional
11+ from typing import Required , TypedDict , List , Callable , Optional
1212from concurrent .futures import ThreadPoolExecutor , as_completed
1313import time
1414import argparse
15- import json
16- import requests
1715import zipfile
1816import tarfile
1917import shutil
2018
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+
2123try :
2224 import yaml
2325except 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" )
2832
2933import generate_mad as mad
3034
3741
3842
3943# 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 )
5752
5853def should_generate_sinks (project : Project ) -> bool :
5954 return project .get ("with-sinks" , True )
@@ -72,14 +67,14 @@ def clone_project(project: Project) -> str:
7267 Shallow clone a project into the build directory.
7368
7469 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.
7671
7772 Returns:
7873 The path to the cloned project directory.
7974 """
8075 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 " )
8378
8479 # Determine target directory
8580 target_dir = os .path .join (build_dir , name )
@@ -178,7 +173,7 @@ def build_database(
178173 Args:
179174 language: The language for which to build the database (e.g., "rust").
180175 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.
182177 project_dir: Path to the CodeQL database.
183178
184179 Returns:
0 commit comments