MaD generator: apply black formatting to all sources

This commit is contained in:
Paolo Tranquilli
2025-06-13 08:47:07 +02:00
parent 1a36374718
commit 5df292c286
3 changed files with 63 additions and 24 deletions

View File

@@ -14,37 +14,53 @@ addsToTemplate = """ - addsTo:
data:
{2}"""
def remove_dir(dirName):
if os.path.isdir(dirName):
shutil.rmtree(dirName)
print("Removed directory:", dirName)
def run_cmd(cmd, msg="Failed to run command"):
print('Running ' + ' '.join(cmd))
print("Running " + " ".join(cmd))
if subprocess.check_call(cmd):
print(msg)
exit(1)
def readData(workDir, bqrsFile):
generatedJson = os.path.join(workDir, "out.json")
print('Decoding BQRS to JSON.')
run_cmd(['codeql', 'bqrs', 'decode', bqrsFile, '--output', generatedJson, '--format=json'], "Failed to decode BQRS.")
print("Decoding BQRS to JSON.")
run_cmd(
[
"codeql",
"bqrs",
"decode",
bqrsFile,
"--output",
generatedJson,
"--format=json",
],
"Failed to decode BQRS.",
)
with open(generatedJson) as f:
results = json.load(f)
try:
return results['#select']['tuples']
return results["#select"]["tuples"]
except KeyError:
print('Unexpected JSON output - no tuples found')
print("Unexpected JSON output - no tuples found")
exit(1)
def insert_update(rows, key, value):
if key in rows:
rows[key] += value
else:
rows[key] = value
def merge(*dicts):
merged = {}
for d in dicts: