Esempio n. 1
0
 def __get_opf_file_path(self):
     """
     Finds and returns OPF file path
     :return OPF file path:
     """
     container_data = xml2obj(open(os.path.join(self.__cache_path, "META-INF/container.xml"), "r"))
     return container_data.rootfiles.rootfile.full_path
Esempio n. 2
0
    def __get_metadata(self):
        """
        Creates and returns metadata object
        :return metadata object:
        """

        # Gets OPF file path
        opf_file_path = self.__get_opf_file_path
        # Loads OPF file and parse it
        return xml2obj(open(os.path.join(self.__cache_path, opf_file_path), "r"))
Esempio n. 3
0
    def __load_titles_and_files(self):
        """
        Loads titles and chapter file paths
        """
        ncx_file_path = self.__get_ncx_file_path
        metadata = self.__get_metadata
        self.chapter_links = []
        chapter_order = []
        for x in metadata.spine.itemref:
            self.files.append(
                [y.href for y in metadata.manifest.item if y.id == x.idref][0])

        self.titles = []
        if os.access(ncx_file_path, os.R_OK):  # Checks if NCX is accessible
            # Parse NCX file
            ncx_tree = xml2obj(open(ncx_file_path))
            self.index = NavPoint(self.files, ncx_tree.navMap)