Esempio n. 1
0
def get_checkable_file_names(container):
    file_names = [name for name, linear in container.spine_names
                  ] + [container.opf_name]
    toc = find_existing_toc(container)
    if toc is not None and container.exists(toc):
        file_names.append(toc)
    return file_names, toc
Esempio n. 2
0
def get_all_words(container, book_locale):
    words = defaultdict(list)
    file_names = [name for name, linear in container.spine_names] + [container.opf_name]
    toc = find_existing_toc(container)
    if toc is not None and container.exists(toc):
        file_names.append(toc)
    for file_name in file_names:
        if not container.exists(file_name):
            continue
        root = container.parsed(file_name)
        if file_name == container.opf_name:
            read_words_from_opf(root, words, file_name, book_locale)
        elif file_name == toc:
            read_words_from_ncx(root, words, file_name, book_locale)
        else:
            read_words_from_html(root, words, file_name, book_locale)

    return {k:group_sort(v) for k, v in words.iteritems()}
Esempio n. 3
0
def get_all_words(container, book_locale):
    words = defaultdict(list)
    file_names = [name for name, linear in container.spine_names
                  ] + [container.opf_name]
    toc = find_existing_toc(container)
    if toc is not None and container.exists(toc):
        file_names.append(toc)
    for file_name in file_names:
        if not container.exists(file_name):
            continue
        root = container.parsed(file_name)
        if file_name == container.opf_name:
            read_words_from_opf(root, words, file_name, book_locale)
        elif file_name == toc:
            read_words_from_ncx(root, words, file_name, book_locale)
        else:
            read_words_from_html(root, words, file_name, book_locale)

    return {k: group_sort(v) for k, v in words.iteritems()}
Esempio n. 4
0
 def delete_requested(self, spine_items, other_items):
     self.commit_all_editors_to_container()
     self.add_savepoint(_('Delete files'))
     c = current_container()
     c.remove_from_spine(spine_items)
     for name in other_items:
         c.remove_item(name)
     self.set_modified()
     self.gui.file_list.delete_done(spine_items, other_items)
     spine_names = [x for x, remove in spine_items if remove]
     for name in spine_names + list(other_items):
         if name in editors:
             self.close_editor(name)
     if not editors:
         self.gui.preview.clear()
     if remove_names_from_toc(current_container(), spine_names + list(other_items)):
         self.gui.toc_view.update_if_visible()
         toc = find_existing_toc(current_container())
         if toc and toc in editors:
             editors[toc].replace_data(c.raw_data(toc))
Esempio n. 5
0
def get_checkable_file_names(container):
    file_names = [name for name, linear in container.spine_names] + [container.opf_name]
    toc = find_existing_toc(container)
    if toc is not None and container.exists(toc):
        file_names.append(toc)
    return file_names, toc