def parse(self, filename_or_file, initialize=True):
        """ Load manifest from file or file object """
        if isinstance(filename_or_file, (str, unicode)):
            filename = filename_or_file
        else:
            filename = filename_or_file.name
        try:
            domtree = minidom.parse(filename_or_file)
        except xml.parsers.expat.ExpatError, e:
            args = [e.args[0]]
            if isinstance(filename, unicode):
                filename = filename.encode(sys.getdefaultencoding(), "replace")
            args.insert(0, '\n  File "%s"\n   ' % filename)
            raise ManifestXMLParseError(" ".join([str(arg) for arg in args]))
        if initialize:
            self.__init__()
        self.filename = filename
        self.load_dom(domtree, False)
def parse ( self , filename_or_file , initialize = True ) : if isinstance ( filename_or_file , ( str , unicode ) ) : filename = filename_or_file else : filename = filename_or_file . name try : domtree = minidom . parse ( filename_or_file ) except xml . parsers . expat . ExpatError , e : args = [ e . args [ 0 ] ] if isinstance ( filename , unicode ) : filename = filename . encode ( sys . getdefaultencoding ( ) , "replace" ) args . insert ( 0 , '\n  File "%s"\n   ' % filename ) raise ManifestXMLParseError ( " " . join ( [ str ( arg ) for arg in args ] ) ) if initialize : self . __init__ ( ) self . filename = filename self . load_dom ( domtree , False )
Load manifest from file or file object