-
Notifications
You must be signed in to change notification settings - Fork 358
/
generate_sqlite.py
44 lines (35 loc) · 1.63 KB
/
generate_sqlite.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
import sys
import os
# Check for SQLite dependency
try:
import sqlite3
except ImportError:
print("SQLite is not installed. Please install it using the following command:")
print("pip install pysqlite3")
sys.exit(1)
# Add the parent directory to the system path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from generators.sqlite.sqlite_generator import SQLiteGenerator
def list_options(options, prompt):
for i, option in enumerate(options, 1):
print(f"{i}. {option}")
choice = int(input(prompt)) - 1
return options[choice]
def main():
# Set base directories relative to the script location
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
source_directory = os.path.join(base_dir, 'sources')
format_directory = os.path.join(base_dir, 'formats')
# Step 1: Select Language
languages = [d for d in os.listdir(source_directory) if os.path.isdir(os.path.join(source_directory, d))]
print("Choose your language:")
language = list_options(languages, "Enter the number corresponding to your language: ")
# Step 2: Select Translation
translations = [d for d in os.listdir(os.path.join(source_directory, language)) if os.path.isdir(os.path.join(source_directory, language, d))]
print(f"Choose your translation for {language}:")
translation = list_options(translations, "Enter the number corresponding to your translation: ")
# Step 3: Generate SQLite Database
sqlite_generator = SQLiteGenerator(source_directory, format_directory)
sqlite_generator.generate(language, translation)
if __name__ == "__main__":
main()