(self)
return result
Extract metadata and analyze the CHM file
        @return analysis results dictionary
Extract metadata and analyze the CHM file
Extract metadata and analyze the CHM file
def analyze(self):
        """
        Extract metadata and analyze the CHM file
        @return analysis results dictionary
        """
        obj_items = set()
        obj_items_details = {}
        obj_items_summary = []
        locale_desc = ''

        locale_desc = self.chmparse.GetLCID()
        if locale_desc:
            locale_desc = ', '.join(locale_desc)

        #Create a list of items within the CHM
        obj_items.add(self.chmparse.home)
        obj_items.add(self.chmparse.index)
        obj_items.add(self.chmparse.topics)
        obj_items = [x for x in obj_items if x is not None]

        #Analyse objects/pages in CHM
        for item in obj_items:
            fetch = self.chmparse.ResolveObject(item)
            if fetch[0] == 0:
                #Read data for object
                try:
                    item_details = self.chmparse.RetrieveObject(fetch[1])
                    if len(item_details) == 2:
                        data = item_details[1]
                        size = item_details[0]
                        md5_digest = hashlib.md5(data).hexdigest()
                        obj_items_details = {
                            'name':         item,
                            'size':         size,
                            'md5':          md5_digest,
                            'urls':         self.find_urls(data),
                            'detection':    self.find_items(data),
                        }
                        obj_items_summary.append(obj_items_details)
                        self.added_files.append([item, size, md5_digest, data])
                    else:
                        self._error('RetrieveObject() did not return data for "{}".'.format(item))
                except Exception as e:
                    self._error('Analysis of item "{}" failed.'.format(item))
                    continue

        result = {
            'title':                self.chmparse.title,
            'index':                self.chmparse.index,
            'binary_index':         self.chmparse.binaryindex,
            'topics':               self.chmparse.topics,
            'home':                 self.chmparse.home,
            'encoding':             self.chmparse.encoding,
            'locale_id':            self.chmparse.lcid,
            'locale_description':   locale_desc,
            'searchable':           str(self.chmparse.searchable),
            'chm_items':            ', '.join(obj_items),
            'obj_items_summary':    obj_items_summary,
        }
        return result
def analyze ( self ) : obj_items = set ( ) obj_items_details = { } obj_items_summary = [ ] locale_desc = '' locale_desc = self . chmparse . GetLCID ( ) if locale_desc : locale_desc = ', ' . join ( locale_desc ) #Create a list of items within the CHM obj_items . add ( self . chmparse . home ) obj_items . add ( self . chmparse . index ) obj_items . add ( self . chmparse . topics ) obj_items = [ x for x in obj_items if x is not None ] #Analyse objects/pages in CHM for item in obj_items : fetch = self . chmparse . ResolveObject ( item ) if fetch [ 0 ] == 0 : #Read data for object try : item_details = self . chmparse . RetrieveObject ( fetch [ 1 ] ) if len ( item_details ) == 2 : data = item_details [ 1 ] size = item_details [ 0 ] md5_digest = hashlib . md5 ( data ) . hexdigest ( ) obj_items_details = { 'name' : item , 'size' : size , 'md5' : md5_digest , 'urls' : self . find_urls ( data ) , 'detection' : self . find_items ( data ) , } obj_items_summary . append ( obj_items_details ) self . added_files . append ( [ item , size , md5_digest , data ] ) else : self . _error ( 'RetrieveObject() did not return data for "{}".' . format ( item ) ) except Exception as e : self . _error ( 'Analysis of item "{}" failed.' . format ( item ) ) continue result = { 'title' : self . chmparse . title , 'index' : self . chmparse . index , 'binary_index' : self . chmparse . binaryindex , 'topics' : self . chmparse . topics , 'home' : self . chmparse . home , 'encoding' : self . chmparse . encoding , 'locale_id' : self . chmparse . lcid , 'locale_description' : locale_desc , 'searchable' : str ( self . chmparse . searchable ) , 'chm_items' : ', ' . join ( obj_items ) , 'obj_items_summary' : obj_items_summary , } return result