Esempio n. 1
0
def export_keys_book(session, langid, target_version, folder, local_audio_dir):
    session.trace_msg("Keys book export for AMIS Version %s" % target_version)

    if target_version == "3.0":
        xmlfile = "amisAccessibleUi30.xml"
    else:
        xmlfile = "amisAccessibleUi31.xml"

    # the xml file that acts as a template for exports
    xml_filepath = daisylion.db.modules.amis.templates.__path__[0]
    xml_filepath = os.path.join(xml_filepath, xmlfile)
    """generate a DAISY book of the keyboard commands"""
    table = session.make_table_name(langid)

    # get the menus based on the XML file structure
    menus = __calculate_menus(session, langid, xml_filepath)

    title_chapter, organized_by_menu_chapter, other_commands_chapter = \
        __make_predetermined_chapters(session, table)

    dir = "ltr"
    if session.is_rtl(langid): dir = "rtl"

    # fill in the NCC template
    nav = templates.ncc.ncc()
    nav.langid = langid
    nav.menus = menus
    nav.title_chapter = title_chapter
    nav.organized_by_menu_chapter = organized_by_menu_chapter
    nav.other_commands_chapter = other_commands_chapter
    nav.dir = dir
    navstring = nav.respond()

    # for menu in menus:
    #         for m in menu:
    #             session.trace_msg("*****menu item")
    #             session.trace_msg(m.caption.text)
    #             session.trace_msg(m.caption.id)
    #             session.trace_msg(m.caption.audio)
    #             session.trace_msg(m.shortcut.id)
    #         session.trace_msg("---")
    #
    # fill in the text template
    txt = templates.xhtml_daisy_text.xhtml_daisy_text()
    txt.langid = langid
    txt.menus = menus
    txt.title_chapter = title_chapter
    txt.organized_by_menu_chapter = organized_by_menu_chapter
    txt.other_commands_chapter = other_commands_chapter
    txt.dir = dir
    textfile = txt.respond()
    textfilename = "amiskeys.html"

    # for each menu item, fill in a smil template.  watch the numbering.
    smiles = []
    smil = templates.smil.smil()
    smil.langid = langid
    smil.title_text = title_chapter[0].caption.text
    smil.textfile = textfilename

    audio_files = []
    smil_objects = []
    # the title chapter
    smil.menuitems = title_chapter
    smiles.append(smil.respond())
    smil_objects.append(smil.menuitems)

    # the "organized by menu" chapter
    smil.menuitems = organized_by_menu_chapter
    smiles.append(smil.respond())
    smil_objects.append(smil.menuitems)

    # all the menus
    for menu in menus:
        smil.menuitems = menu
        smiles.append(smil.respond())
        smil_objects.append(smil.menuitems)

    smil.menuitems = other_commands_chapter
    smiles.append(smil.respond())
    smil_objects.append(smil.menuitems)

    # collect the audio files
    for s in smil_objects:
        for item in s:
            if item.caption != None:
                audio_files.append(item.caption.audio)
            if item.shortcut != None:
                audio_files.append(item.shortcut.audio)

    __write_to_disk(folder, textfilename, navstring, textfile, smiles)
    __copy_audio_files(session, local_audio_dir, audio_files, folder)
Esempio n. 2
0
def export_keys_book(session, xmlfile, langid, folder, local_audio_dir):
    """generate a DAISY book of the keyboard commands"""
    table = session.make_table_name(langid)
    
    # get the menus based on the XML file structure
    menus = __calculate_menus(session, langid, xmlfile)
    
    title_chapter, organized_by_menu_chapter, other_commands_chapter = \
        __make_predetermined_chapters(session, table)
    
    # fill in the NCC template
    nav = templates.ncc.ncc()
    nav.langid = langid
    nav.menus = menus
    """for menu in menus:
        for m in menu:
            session.trace_msg(m.caption.text)
            session.trace_msg(m.caption.id)
            session.trace_msg(m.caption.audio)
        session.trace_msg("---")
    """
    nav.title_chapter = title_chapter
    nav.organized_by_menu_chapter = organized_by_menu_chapter
    nav.other_commands_chapter = other_commands_chapter
    navstring = nav.respond()
    
    
    # fill in the text template
    txt = templates.xhtml_daisy_text.xhtml_daisy_text()
    txt.langid = langid
    txt.menus = menus
    txt.title_chapter = title_chapter
    txt.organized_by_menu_chapter = organized_by_menu_chapter
    txt.other_commands_chapter = other_commands_chapter
    textfile = txt.respond()
    textfilename = "amiskeys.html"

    # for each menu item, fill in a smil template.  watch the numbering.
    smiles = []
    smil = templates.smil.smil()
    smil.langid = langid
    smil.title_text = title_chapter[0].caption.text
    smil.textfile = textfilename
    
    audio_files = []
    smil_objects = []
    # the title chapter
    smil.menuitems = title_chapter
    smiles.append(smil.respond())
    smil_objects.append(smil.menuitems)
    
    # the "organized by menu" chapter
    smil.menuitems = organized_by_menu_chapter
    smiles.append(smil.respond())
    smil_objects.append(smil.menuitems)
    
    # all the menus
    for menu in menus:
        smil.menuitems = menu
        smiles.append(smil.respond())
        smil_objects.append(smil.menuitems)
    
    smil.menuitems = other_commands_chapter
    smiles.append(smil.respond())
    smil_objects.append(smil.menuitems)
    
    # collect the audio files
    for s in smil_objects:
        for item in s:
            if item.caption != None: 
                audio_files.append(item.caption.audio)
            if item.shortcut != None:
                audio_files.append(item.shortcut.audio)
    
    __write_to_disk(folder, textfilename, navstring, textfile, smiles)
    __copy_audio_files(local_audio_dir, audio_files, folder)
Esempio n. 3
0
def export_keys_book(session, langid, target_version, folder, local_audio_dir):
    session.trace_msg("Keys book export for AMIS Version %s" % target_version)
    
    if target_version == "3.0":
        xmlfile = "amisAccessibleUi30.xml"
    else:
        xmlfile = "amisAccessibleUi31.xml"
    
    # the xml file that acts as a template for exports
    xml_filepath = daisylion.db.modules.amis.templates.__path__[0]
    xml_filepath = os.path.join(xml_filepath, xmlfile)
    
    """generate a DAISY book of the keyboard commands"""
    table = session.make_table_name(langid)
    
    # get the menus based on the XML file structure
    menus = __calculate_menus(session, langid, xml_filepath)
    
    title_chapter, organized_by_menu_chapter, other_commands_chapter = \
        __make_predetermined_chapters(session, table)
    
    dir = "ltr"
    if session.is_rtl(langid): dir = "rtl"
    
    # fill in the NCC template
    nav = templates.ncc.ncc()
    nav.langid = langid
    nav.menus = menus
    nav.title_chapter = title_chapter
    nav.organized_by_menu_chapter = organized_by_menu_chapter
    nav.other_commands_chapter = other_commands_chapter
    nav.dir = dir
    navstring = nav.respond()
    
    # for menu in menus:
    #         for m in menu:
    #             session.trace_msg("*****menu item")
    #             session.trace_msg(m.caption.text)
    #             session.trace_msg(m.caption.id)
    #             session.trace_msg(m.caption.audio)
    #             session.trace_msg(m.shortcut.id)
    #         session.trace_msg("---")
    #     
    # fill in the text template
    txt = templates.xhtml_daisy_text.xhtml_daisy_text()
    txt.langid = langid
    txt.menus = menus
    txt.title_chapter = title_chapter
    txt.organized_by_menu_chapter = organized_by_menu_chapter
    txt.other_commands_chapter = other_commands_chapter
    txt.dir = dir
    textfile = txt.respond()
    textfilename = "amiskeys.html"

    # for each menu item, fill in a smil template.  watch the numbering.
    smiles = []
    smil = templates.smil.smil()
    smil.langid = langid
    smil.title_text = title_chapter[0].caption.text
    smil.textfile = textfilename
    
    audio_files = []
    smil_objects = []
    # the title chapter
    smil.menuitems = title_chapter
    smiles.append(smil.respond())
    smil_objects.append(smil.menuitems)
    
    # the "organized by menu" chapter
    smil.menuitems = organized_by_menu_chapter
    smiles.append(smil.respond())
    smil_objects.append(smil.menuitems)
    
    # all the menus
    for menu in menus:
        smil.menuitems = menu
        smiles.append(smil.respond())
        smil_objects.append(smil.menuitems)
    
    smil.menuitems = other_commands_chapter
    smiles.append(smil.respond())
    smil_objects.append(smil.menuitems)
    
    # collect the audio files
    for s in smil_objects:
        for item in s:
            if item.caption != None: 
                audio_files.append(item.caption.audio)
            if item.shortcut != None:
                audio_files.append(item.shortcut.audio)
    
    __write_to_disk(folder, textfilename, navstring, textfile, smiles)
    __copy_audio_files(session, local_audio_dir, audio_files, folder)