Example #1
0
 def __init__(self, href, opf_str = None, container_path = None, package = None):
     '''
     Parameters
     ----------
     href : string
        Absolute file path of this opf through which it is being opened.
     
     Keyword arguments:
         opf_str -- if available the contents of the OPF file itself to parse (Default None)
         container_path -- the path of this opf within the epub container (Default None)
     '''
     
     # The etree root element
     if opf_str:
         self.package_el = etree.fromstring(opf_str)
         
         #check for a title - old versions of eXe made invalid opfs with no title
         if self._get_title_el() is None:
             metadata_el = self.package_el.find(".//{%s}metadata" % EPUBOPF.NAMESPACE_OPF)
             title_el = etree.SubElement(metadata_el, "{%s}title" % EPUBOPF.NAMESPACE_DC)
             title_el.text = "Package"
         
     else:
         self.package_el = None # this could be construction of a blank item
     
     self.href = href
     self.nav_el_id = None
     self.navigation_doc = None
     
     self.container_path = container_path
     self.package = package
     self.resource_manager = EPUBResourceManager(self.package, self)