forked from HerodotusDev/integrity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.py
50 lines (39 loc) · 1.6 KB
/
configure.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import argparse
import sys
import inquirer
from pathlib import Path
from utils import process_file
LAYOUT_TYPES = ("dex", "recursive", "recursive_with_poseidon", "small", "starknet", "starknet_with_keccak")
HASH_TYPES = ("keccak", "blake2s")
def select_types() -> str:
"""Prompts the user to select a type."""
questions = [
inquirer.List("layout_type", message="Select layout", choices=LAYOUT_TYPES),
inquirer.List("hash_type", message="Select hash", choices=HASH_TYPES),
]
answers = inquirer.prompt(questions)
return (answers["layout_type"], answers["hash_type"])
def main(layout_type=None, hash_type=None):
"""Main function for processing files."""
if layout_type is None or hash_type is None:
layout_type, hash_type = select_types()
if layout_type.lower() not in LAYOUT_TYPES:
print(f"Invalid layout type: {layout_type}")
sys.exit(1)
if hash_type.lower() not in HASH_TYPES:
print(f"Invalid hash type: {hash_type}")
sys.exit(1)
current_directory = Path("src")
for file_path in current_directory.rglob("*.cairo"):
if file_path.is_file():
process_file(file_path, [layout_type.upper(), hash_type.upper()])
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Process files based on block type.")
parser.add_argument(
"-l", "--layout_type", type=str, help=f"Type of layouts {LAYOUT_TYPES}"
)
parser.add_argument(
"-s", "--hash_type", type=str, help=f"Type of hashes {HASH_TYPES}"
)
args = parser.parse_args()
main(args.layout_type, args.hash_type)