<s> """<STR_LIT>""" <EOL> import codecs <EOL> import gzip <EOL> import io <EOL> import tarfile <EOL> import six <EOL> def open_ ( filename , mode = '<STR_LIT:r>' , encoding = None ) : <EOL> """<STR_LIT>""" <EOL> if filename . endswith ( '<STR_LIT>' ) : <EOL> if six . PY2 : <EOL> zf = io . BufferedReader ( gzip . open ( filename , mode ) ) <EOL> if encoding : <EOL> return codecs . getreader ( encoding ) ( zf ) <EOL> else : <EOL> return zf <EOL> else : <EOL> return io . BufferedReader ( gzip . open ( filename , mode , <EOL> encoding = encoding ) ) <EOL> if six . PY2 : <EOL> if encoding : <EOL> return codecs . open ( filename , mode , encoding = encoding ) <EOL> else : <EOL> return open ( filename , mode ) <EOL> else : <EOL> return open ( filename , mode , encoding = encoding ) <EOL> def tar_open ( f ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( f , six . string_types ) : <EOL> return tarfile . open ( name = f ) <EOL> else : <EOL> return tarfile . open ( fileobj = f ) </s>
