I/O with zip archives

Krang allows to export a package that encloses in one place everything needed to reproduce the circuit. A bare JSON, in fact, contains all the topological information, but references such as csv loadprofile files, DecisionModels for the smart components and the likes are not included. In order to save/load a full pack, the following functions can be used:



Packs a ckt archive with all the information needed to reproduce the Krang. If a valid path string is passed, a file will be created, and None will be returned; if None is passed as path, a Binary buffered I/O (io.BytesIO) with the exact same information as the file will be returned instead.


classmethod Krang.open_ckt(path, strict=True)

Loads a ckt package saved through Krang.pack_ckt() and returns a Krang.

The files saved are zip archives that contain, aside from the main JSON file, other archives and pickle-files with all the necessary information.

md5 hash

On save and load, the Krang is hashed with the fingerprint method in order to verify correctness. The hash can be seen in a .md5 file present in the ckt archive.