def _read(filepath_or_buffer: FilePathOrBuffer, kwds):
encoding = kwds.get('<STR_LIT>', None)<EOL>if encoding is not None:<EOL><INDENT>encoding = re.sub('<STR_LIT:_>', '<STR_LIT:->', encoding).lower()<EOL>kwds['<STR_LIT>'] = encoding<EOL><DEDENT>compression = kwds.get('<STR_LIT>', '<STR_LIT>')<EOL>compression = _infer_compression(filepath_or_buffer, compression)<EOL>fp_or_buf, _, compression, should_close = get_filepath_or_buffer(<EOL>filepath_or_buffer, encoding, compression)<EOL>kwds['<STR_LIT>'] = compression<EOL>if kwds.get('<STR_LIT>', None) is not None:<EOL><INDENT>if isinstance(kwds['<STR_LIT>'], bool):<EOL><INDENT>kwds['<STR_LIT>'] = True<EOL><DEDENT><DEDENT>iterator = kwds.get('<STR_LIT>', False)<EOL>chunksize = _validate_integer('<STR_LIT>', kwds.get('<STR_LIT>', None), <NUM_LIT:1>)<EOL>nrows = kwds.get('<STR_LIT>', None)<EOL>_validate_names(kwds.get("<STR_LIT>", None))<EOL>parser = TextFileReader(fp_or_buf, **kwds)<EOL>if chunksize or iterator:<EOL><INDENT>return parser<EOL><DEDENT>try:<EOL><INDENT>data = parser.read(nrows)<EOL><DEDENT>finally:<EOL><INDENT>parser.close()<EOL><DEDENT>if should_close:<EOL><INDENT>try:<EOL><INDENT>fp_or_buf.close()<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return data<EOL>
Generic reader of line files.