@staticmethod<EOL><INDENT>def _open(filespec, mode='<STR_LIT:rb>'):<DEDENT>
close_it = False<EOL>if isinstance(filespec, string_types):<EOL><INDENT>close_it = True<EOL>if mode[<NUM_LIT:0>] == '<STR_LIT:r>':<EOL><INDENT>if not os.path.isfile(filespec):<EOL><INDENT>if os.path.isfile(filespec+'<STR_LIT>'):<EOL><INDENT>filespec = filespec + '<STR_LIT>'<EOL><DEDENT>elif os.path.isfile(filespec+'<STR_LIT>'):<EOL><INDENT>filespec = filespec + '<STR_LIT>'<EOL><DEDENT>elif os.path.isfile(filespec+'<STR_LIT>'):<EOL><INDENT>filespec = filespec + '<STR_LIT>'<EOL><DEDENT><DEDENT>if filespec.endswith('<STR_LIT>'):<EOL><INDENT>import gzip<EOL>stream = gzip.open(filespec, mode)<EOL><DEDENT>elif filespec.endswith('<STR_LIT>'):<EOL><INDENT>import bz2<EOL>stream = bz2.BZ2File(filespec, '<STR_LIT:rb>')<EOL><DEDENT>else:<EOL><INDENT>stream = open(filespec, mode)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if filespec[-<NUM_LIT:4>:] != '<STR_LIT>':<EOL><INDENT>filespec = filespec + '<STR_LIT>'<EOL><DEDENT>stream = open(filespec, mode)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>stream = filespec<EOL><DEDENT>return stream, close_it<EOL>
Return an open file stream for reading based on source.  If source is
a file name, open it (after trying to find it with mtx and gzipped mtx
extensions).  Otherwise, just return source.