#NEWLINE# def getPluginDir( plugin_name ) : #NEWLINE# #INDENT# 'Gets the directory of the given plugin' #NEWLINE# filename = None #NEWLINE# try : #NEWLINE# #INDENT# filename = sys . modules [ plugin_name ] . __file__ #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# if ( filename == None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# filename = sys . modules [ ( 'supybot.plugins.' + plugin_name ) ] . __file__ #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# filename = sys . modules [ 'plugin' ] . __file__ #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# filename = sys . modules [ '__main__' ] . __file__ #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if filename . endswith ( '.pyc' ) : #NEWLINE# #INDENT# filename = filename [ 0 : ( - 1 ) ] #NEWLINE# #UNINDENT# allowed_files = [ '__init__.py' , 'config.py' , 'plugin.py' , 'test.py' ] #NEWLINE# for allowed_file in allowed_files : #NEWLINE# #INDENT# if filename . endswith ( allowed_file ) : #NEWLINE# #INDENT# return filename [ 0 : ( - len ( plugin_name ) ) ] #NEWLINE# #UNINDENT# #UNINDENT# raise PluginNotFound ( )