#NEWLINE# def _addon_details( self , addon_path ) : #NEWLINE# #INDENT# "\n            returns a dictionary of details about the addon\n            - addon_path : path to the addon directory\n            Returns:\n            {'id': 'rainbow@colors.org', # id of the addon\n            'version': '1.4', # version of the addon\n            'name': 'Rainbow', # name of the addon\n            'unpack': False } # whether to unpack the addon\n        " #NEWLINE# details = { #NEWLINE# #INDENT# 'id' : None , #NEWLINE# 'name' : None , #NEWLINE# 'unpack' : True , #NEWLINE# 'version' : None , #NEWLINE# #UNINDENT# } #NEWLINE# def get_namespace_id( doc , url ) : #NEWLINE# #INDENT# attributes = doc . documentElement . attributes #NEWLINE# namespace = '' #NEWLINE# for i in range ( attributes . length ) : #NEWLINE# #INDENT# if ( attributes . item ( i ) . value == url ) : #NEWLINE# #INDENT# if ( ':' in attributes . item ( i ) . name ) : #NEWLINE# #INDENT# namespace = ( attributes . item ( i ) . name . split ( ':' ) [ 1 ] + ':' ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return namespace #NEWLINE# #UNINDENT# def get_text( element ) : #NEWLINE# #INDENT# 'Retrieve the text value of a given node' #NEWLINE# rc = [ ] #NEWLINE# for node in element . childNodes : #NEWLINE# #INDENT# if ( node . nodeType == node . TEXT_NODE ) : #NEWLINE# #INDENT# rc . append ( node . data ) #NEWLINE# #UNINDENT# #UNINDENT# return '' . join ( rc ) . strip ( ) #NEWLINE# #UNINDENT# doc = minidom . parse ( os . path . join ( addon_path , 'install.rdf' ) ) #NEWLINE# em = get_namespace_id ( doc , 'http://www.mozilla.org/2004/em-rdf#' ) #NEWLINE# rdf = get_namespace_id ( self , 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' ) #NEWLINE# description = doc . getElementsByTagName ( ( rdf + 'Description' ) ) . item ( 0 ) #NEWLINE# for node in description . childNodes : #NEWLINE# #INDENT# entry = node . nodeName . replace ( em , '' ) #NEWLINE# if ( entry in details . keys ( ) ) : #NEWLINE# #INDENT# details . update ( { #NEWLINE# #INDENT# entry : get_text ( node ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# return details