PhfStream¶
- class photonforge.PhfStream(filename, mode='r', set_config=True)¶
Create a PhfStream object for writing or loading phf files.
- Parameters:
filename – Phf file name.
mode – Either
"r"or"w"to open the file for reading or writing, respectively.set_config – If
Trueandmode == 'r', setconfig.gridandconfig.tolerancewith values loaded from the file.
Methods
close()Close the stream.
contents([only_explicit])Index of the stream contents.
load_component([name, only_explicit])Load components from this stream.
load_technology([name, version, only_explicit])Load technologies from this stream.
write(*args)Write components and technologies through this stream.
- close()¶
Close the stream.
- Returns:
None.
- contents(only_explicit=True)¶
Index of the stream contents.
- Parameters:
only_explicit – If set, only explicitly written component and technology entries are returned (excludes automatically included dependencies).
- Returns:
Dictionary with keys
"components"and"technologies". The former holds a set ofComponentnames, and the latter a set of tuples withTechnologynames and versions.
- load_component(name=None, only_explicit=True)¶
Load components from this stream.
- Parameters:
name – If given, only the named component is returned, otherwise all components in the stream.
only_explicit – If set, only explicitly stored components are returned. This argument is ignored if name is given.
- Returns:
List of
Component.
- load_technology(name=None, version=None, only_explicit=True)¶
Load technologies from this stream.
- Parameters:
name – If given, only technologies with this name are returned, otherwise all technologies in the stream.
version – If given, only technologies with this version are returned, otherwise all technologies in the stream.
only_explicit – If set, only explicitly stored technologies are returned. This argument is ignored if both name and version are given.
- Returns:
List of
Technology.
- write(*args)¶
Write components and technologies through this stream.
- Parameters:
*args – Components and technologies to be written. Must be instances of
ComponentorTechnology.- Returns:
This object.