Skip to content

vtf textbuffer bufferreader

srccircumflex edited this page Apr 24, 2023 · 4 revisions

↑ vtf-textbuffer

bufferreader

class bufferreader.Reader(IO)

Independent io object to read from a TextBuffer.

Reader has, apart from the known reading methods, methods to read lines by a number, a number of rows or specific data ranges. A line is defined as the content between two line breaks + final line break, a row corresponds to one _Row in the TextBuffer.

To assign different endings to the rows during reading, a dictionary can be passed via the endings parameter, which contains the different replacements. The keys can be selected from None (no ending), "\n" (newline) and "" (unbroken newline) and the value can be assigned as bytes.

To create Reader as a binary read object, an encoding or True (UTF8) can be specified by the parameter bin_mode.

Set tabs_to_blanks to a tab size or to True (same size as in TextBuffer) to convert tab shifts to blanks when reading or replace the tab characters via replace_tabs, the replacement is specified as bytes.

Define progress to set an approximate starting point (starts at the beginning of the applicable row) or define the data ranges to be read with dat_ranges as a sorted list [ [<start>, <stop>], ... ]. The progress attribute is NOT updated during reading.

buffer: AnyStr

progress: int

__enter__() -> Reader

Reader

__exit__(exc_type, exc_val, exc_tb) -> None

Execute the close method of Reader

__init__(__buffer__, *, bin_mode=False, endings=None, tabs_to_blanks=False, replace_tabs=None, progress=0, dat_ranges=None)

__iter__() -> Iterator[str]

row iterator

__next__() -> str

next row

close() -> None

Delete the internal buffer attributes of Reader and thus free memory (subsequent read processes will raise AttributeError).
@property
closed() -> bool
Whether the reader buffer is deleted.
@property
encoding() -> str
@property
eof() -> bool
Whether the end of the data has been reached.

fileno() -> int

pass

flush() -> None

pass

isatty() -> bool

False
@property
mode() -> str
"r" | "rb"
@property
name() -> str
""

read(__lim=None) -> AnyStr

Read all data in TextBuffer or until a character limit is reached.

raises:
  • EOFError: End of data reached.

readable() -> bool

True

readiteration(__lim=None) -> AnyStr

Read the next iteration (the next data range if configured, otherwise the next row) completely or until a character limit is reached.

raises:
  • EOFError: End of data reached.

readiterations(__n, __hint=None) -> list[AnyStr]

Read a number of iterations (data ranges if configured, otherwise the rows) or until the iterations read include the character hint.

raises:
  • EOFError: End of data reached.

readline(__lim=None) -> AnyStr

Read until the next real line break or at most until the character limit is reached.

raises:
  • EOFError: End of data reached.

readlines(__hint=None) -> list[AnyStr]

Read all lines in the TextBuffer or until the lines read include the character hint and keep "\n".

raises:
  • EOFError: End of data reached.

readnlines(__n, __hint=None) -> list[AnyStr]

Read a number of lines or until the lines read include the character hint and keep "\n".

raises:
  • EOFError: End of data reached.

readrow(__lim=None) -> AnyStr

Read the next row into the reader buffer if it is empty and return the entire buffer or up to the character limit (corresponds to the remaining characters or an entire row).

raises:
  • EOFError: End of data reached.

readrows(__n, __hint=None) -> list[AnyStr]

Read a number of rows or until the rows read include the character hint.

raises:
  • EOFError: End of data reached.

seek(__offset, __whence=...) -> int

Raises NotImplementedError.

seekable() -> bool

False

tell() -> int

progress

truncate(__size=...) -> int

Raises NotImplementedError.

writable() -> bool

False

write(__s) -> int

Raises UnsupportedOperation.

writelines(__lines) -> None

Raises UnsupportedOperation.

Date: 21 Dec 2022
Version: 0.1
Author: Adrian Hoefflin [srccircumflex]
Doc-Generator: "pyiStructure-RSTGenerator" <prototype>

Clone this wiki locally