bag.io

This package provides all IO related functionalities for BAG.

Most importantly, this module sorts out all the bytes v.s. unicode differences and simplifies writing python2/3 compatible code.

Submodules

Package Contents

Functions

fix_string(obj)

Fix the given potential string object to ensure python 2/3 compatibility.

to_bytes(my_str)

Convert the given string to raw bytes.

set_encoding(new_encoding)

Sets the BAG input/output encoding.

get_encoding()

Returns the BAG input/output encoding.

set_error_policy(new_policy)

Sets the error policy on encoding/decoding errors.

get_error_policy()

Returns the current BAG encoding/decoding error policy.

load_sim_results(save_dir)

Load exported simulation results from the given directory.

save_sim_results(results, fname[, compression])

Saves the given simulation results dictionary as a HDF5 file.

load_sim_file(fname)

Read simulation results from HDF5 file.

read_file(→ str)

Read the given file and return content as string.

read_resource(→ str)

Read the given resource file and return content as string.

read_yaml(→ Any)

Read the given file using YAML.

readlines_iter(→ Iterable[str])

Iterate over lines in a file.

write_file(→ None)

Writes the given content to file.

make_temp_dir(→ str)

Create a new temporary directory.

open_temp(→ TextIO)

Opens a new temporary file for writing with unicode interface.

open_file(→ TextIO)

Opens a file with the correct encoding interface.