original_docstring: 
      Extracts assemblies from a given xll built with Excel-DNA
      :param xll_path:  path to Excel-DNA XLL file
      :param only_external: bool indicates if only external assemblies will be extracted,
                            otherwise the framework's assemblies will be extracted as well
      :return: a dictionary that maps an assembly name to its contents
      
docstring: Extracts assemblies from a given xll built with Excel-DNA
docstring_tokens: Extracts assemblies from a given xll built with Excel - DNA
code: def extract_assemblies_from_excel_dna(xll_path: str, only_external: bool=True) -> Dict[str, bytes]:
      """
      Extracts assemblies from a given xll built with Excel-DNA
      :param xll_path:  path to Excel-DNA XLL file
      :param only_external: bool indicates if only external assemblies will be extracted,
                            otherwise the framework's assemblies will be extracted as well
      :return: a dictionary that maps an assembly name to its contents
      """
      pe = PE(xll_path)
      assemblies = {}
      external_libraries = []
      for rsrc in pe.DIRECTORY_ENTRY_RESOURCE.entries:
          # extract assemblies
          if rsrc.name and rsrc.name.decode() in ['ASSEMBLY', 'ASSEMBLY_LZMA']:
              for entry in rsrc.directory.entries:
                  if entry.name:
                      raw_buff = get_resource_buffer(pe, entry)
                      if rsrc.name.decode() == 'ASSEMBLY_LZMA':
                          assemblies[entry.name.decode()] = lzma.decompress(raw_buff)
                      else:
                          assemblies[entry.name.decode()] = raw_buff
  
          # parse the main xml
          elif rsrc.name and rsrc.name.decode() == 'DNA':
              for entry in rsrc.directory.entries:
                  if entry.name and entry.name.decode() == '__MAIN__':
                      main_xml = get_resource_buffer(pe, entry).decode()
                      libs = re.findall('ExternalLibrary.{,200} Path="(.*?)"', main_xml)
                      external_libraries.extend([name.replace('packed:','') for name in libs])
  
      if only_external:
          # filter out non-external assemblies
          assemblies = {name: buff for name, buff in assemblies.items() if name in external_libraries}
  
      return assemblies
code_tokens: def extract_assemblies_from_excel_dna ( xll_path : str , only_external : bool = True ) -> Dict [ str , bytes ] : pe = PE ( xll_path ) assemblies = { } external_libraries = [ ] for rsrc in pe . DIRECTORY_ENTRY_RESOURCE . entries : if rsrc . name and rsrc . name . decode ( ) in [ 'ASSEMBLY' , 'ASSEMBLY_LZMA' ] : for entry in rsrc . directory . entries : if entry . name : raw_buff = get_resource_buffer ( pe , entry ) if rsrc . name . decode ( ) == 'ASSEMBLY_LZMA' : assemblies [ entry . name . decode ( ) ] = lzma . decompress ( raw_buff ) else : assemblies [ entry . name . decode ( ) ] = raw_buff elif rsrc . name and rsrc . name . decode ( ) == 'DNA' : for entry in rsrc . directory . entries : if entry . name and entry . name . decode ( ) == '__MAIN__' : main_xml = get_resource_buffer ( pe , entry ) . decode ( ) libs = re . findall ( 'ExternalLibrary.{,200} Path="(.*?)"' , main_xml ) external_libraries . extend ( [ name . replace ( 'packed:' , '' ) for name in libs ] ) if only_external : assemblies = { name : buff for name , buff in assemblies . items ( ) if name in external_libraries } return assemblies
short_docstring: Extracts assemblies from a given xll built with Excel-DNA
short_docstring_tokens: Extracts assemblies from a given xll built with Excel - DNA
comment: """
      Extracts assemblies from a given xll built with Excel-DNA
      :param xll_path:  path to Excel-DNA XLL file
      :param only_external: bool indicates if only external assemblies will be extracted,
                            otherwise the framework's assemblies will be extracted as well
      :return: a dictionary that maps an assembly name to its contents
      """$SEP$# extract assemblies$SEP$# parse the main xml$SEP$# filter out non-external assemblies