def open(self, encoding=None):
try:<EOL><INDENT>if IS_GZIPPED_FILE.search(self._filename):<EOL><INDENT>_file = gzip.open(self._filename, '<STR_LIT:rb>')<EOL><DEDENT>else:<EOL><INDENT>if encoding:<EOL><INDENT>_file = io.open(self._filename, '<STR_LIT:r>', encoding=encoding, errors='<STR_LIT:replace>')<EOL><DEDENT>elif self._encoding:<EOL><INDENT>_file = io.open(self._filename, '<STR_LIT:r>', encoding=self._encoding, errors='<STR_LIT:replace>')<EOL><DEDENT>else:<EOL><INDENT>_file = io.open(self._filename, '<STR_LIT:r>', errors='<STR_LIT:replace>')<EOL><DEDENT><DEDENT><DEDENT>except IOError as e:<EOL><INDENT>self._log_warning(str(e))<EOL>_file = None<EOL>self.close()<EOL><DEDENT>return _file<EOL>
Opens the file with the appropriate call