gpsea.util module
- gpsea.util.open_text_io_handle_for_reading(file: IOBase | str, encoding: str = 'utf-8') TextIOWrapper [source]
Open a io.TextIO file handle based on file.
- Parameters:
file – a str or
io.IOBase
to read from. If str, then the input is interpreted as a path to a local file. If fh is an IO wrapper, the function ensures we get a text wrapper that uses given encoding.encoding – encoding used to decode the input (utf-8 by default).
- Returns:
the
io.TextIOWrapper
wrapper.
- gpsea.util.open_text_io_handle_for_writing(file: IOBase | str, encoding: str = 'utf-8') TextIOWrapper [source]
Open a io.TextIO file handle based on file.
- Parameters:
file – a str or
io.IOBase
to write to. If str, then the input is interpreted as a path to a local file. If fh is an IO wrapper, the function ensures we get a text wrapper that uses given encoding.encoding – encoding used to encode the output (utf-8 by default).
- Returns:
the
io.TextIOWrapper
wrapper.
- gpsea.util.open_resource(package: str, path: str) IO[str] [source]
Get an IO handle for reading a package resource on the current platform.
The returned callable expects two arguments: :param package: a str with package name (e.g. gpsea.model.genome) :param path: a str with the file name that is located in the package (e.g. GCF_000001405.25_GRCh37.p13_assembly_report.tsv)