#NEWLINE# def get_database( dialect ) : #NEWLINE# #INDENT# '\n    Returns requested database package with modules that provide additional functionality.\n\n    :param string dialect: (required). Database dialect name.\n    ' #NEWLINE# aliases = { #NEWLINE# #INDENT# ( 'mysql' , ) : 'mysql' , #NEWLINE# ( 'sqlite' , ) : 'sqlite' , #NEWLINE# ( 'pgsql' , 'postgres' , 'postgresql' ) : 'postgresql' , #NEWLINE# #UNINDENT# } #NEWLINE# dialect = next ( ( aliases [ alias ] for alias in aliases if ( dialect in alias ) ) , dialect ) #NEWLINE# names = [ str ( mod [ 1 ] ) for mod in pkgutil . iter_modules ( [ os . path . join ( os . path . dirname ( __file__ ) , dialect ) ] ) ] #NEWLINE# try : #NEWLINE# #INDENT# return __import__ ( '{0}' . format ( dialect ) , globals ( ) , level = 1 , fromlist = names ) #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# raise DatabaseError ( current = dialect , allowed = [ name for ( _ , name , is_pkg ) in pkgutil . iter_modules ( [ os . path . dirname ( __file__ ) ] ) if is_pkg ] )