def insert_narrator_index(narrator_index: NarratorIndex):
    obj = {
        "index": 'people',
        "kind": "person_list",
        'data': jsonable_encoder(narrator_index.id_name)
    }
    write_file("/people/narrators/index", obj)
def insert_narrators(narrators: Dict[int, Narrator]):
    for narrator in narrators.values():
        obj = {
            "index": narrator.index,
            "kind": "person_content",
            'data': jsonable_encoder(narrator)
        }
        write_file(f"/people/narrators/{narrator.index}", obj)
def init_kafi():
    book = build_kafi()

    insert_chapter(book)

    write_file("/books/complete/al-kafi",
               fastapi.encoders.jsonable_encoder(book))

    pprint(SEQUENCE_ERRORS)
def link_quran_kafi():
    quran = load_chapter("/books/complete/quran")
    kafi = load_chapter("/books/complete/al-kafi")

    process_chapter(quran, kafi)

    insert_chapter(kafi)
    insert_chapter(quran)
    write_file("/books/complete/al-kafi", jsonable_encoder(kafi))
    write_file("/books/complete/quran", jsonable_encoder(quran))
Exemple #5
0
def init_books():
    data_root = {
        "titles": {
            Language.EN.value: "Books",
        },
        "descriptions": {
            Language.EN.value: "The two weighty things at your fingertips!"
        },
        "chapters": [
            {
                "index": QURAN_INDEX,
                "path": BOOK_PATH + QURAN_INDEX,
                "titles": {
                    Language.EN.value: "The Holy Quran",
                    Language.AR.value: "القرآن الكريم"
                }
            },
            {
                "index": KAFI_INDEX,
                "path": BOOK_PATH + KAFI_INDEX,
                "titles": {
                    Language.EN.value: "Al-Kafi",
                    Language.AR.value: "الكافي"
                }
            },
        ]
    }

    obj_in = {"index": BOOK_INDEX, "kind": "chapter_list", "data": data_root}
    book = write_file("/books/books", obj_in)
    logger.info("Inserted books list into book_part ID %s with index %s",
                book.id, book.index)
def add_kafi_sarwar():
    kafi = load_chapter("/books/complete/al-kafi")
    add_content(kafi.chapters[0], get_path("chapter\\1\\"))
    add_content(kafi.chapters[1], get_path("chapter\\2\\"))
    add_content(kafi.chapters[2], get_path("chapter\\3\\"))
    add_content(kafi.chapters[3], get_path("chapter\\4\\"))
    add_content(kafi.chapters[4], get_path("chapter\\5\\"))
    add_content(kafi.chapters[5], get_path("chapter\\6\\"))
    add_content(kafi.chapters[6], get_path("chapter\\7\\"))
    add_content(kafi.chapters[7], get_path("chapter\\8\\"))

    set_index(kafi, [0, 0, 0, 0], 0)
    insert_chapter(kafi)
    write_file("/books/complete/al-kafi", jsonable_encoder(kafi))

    pprint(SEQUENCE_ERRORS, width=240)
def init_quran():
    quran = build_quran()
    insert_chapter(quran)
    write_file("/books/complete/quran",
               fastapi.encoders.jsonable_encoder(quran))