File size: 1,328 Bytes
434c55b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
This script initializes the abjad.db database with Quran verses.
Run this script once before using the Daily Sura feature.
"""

import logging
import argparse
import os
from quran import initialize_quran_database
try:
    from tqdm import tqdm
except ImportError:
    # If tqdm is not installed, install it
    import subprocess
    print("Installing required package: tqdm")
    subprocess.check_call(["pip", "install", "tqdm"])

# Set up logging
logging.basicConfig(level=logging.INFO, 
                    format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)

def main():
    parser = argparse.ArgumentParser(description='Initialize the Quran database.')
    parser.add_argument('--db-file', default='abjad.db',
                        help='SQLite database file path (default: abjad.db)')
    parser.add_argument('--max-phrase-length', type=int, default=1,
                        help='Maximum phrase length to process (default: 1)')
    
    args = parser.parse_args()
    
    logger.info(f"Starting Quran database initialization with max phrase length: {args.max_phrase_length}")
    initialize_quran_database(args.db_file, args.max_phrase_length)
    logger.info(f"Database initialization completed: {args.db_file}")

if __name__ == "__main__":
    main()