#NEWLINE# def _gen_open( f ) : #NEWLINE# #INDENT# if isinstance ( f , int ) : #NEWLINE# #INDENT# return io . open ( f , 'rb' , closefd = False ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not isinstance ( f , six . string_types ) ) : #NEWLINE# #INDENT# raise TypeError ( ( 'expected {str, int, file-like}, got %s' % type ( f ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# ( _ , ext ) = os . path . splitext ( f ) #NEWLINE# if ( ext == '.gz' ) : #NEWLINE# #INDENT# import gzip #NEWLINE# return gzip . open ( f , 'rb' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ext == '.bz2' ) : #NEWLINE# #INDENT# from bz2 import BZ2File #NEWLINE# return BZ2File ( f , 'rb' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return open ( f , 'rb' )