PhfStream¶
- class photonforge.PhfStream(filename, mode='r', set_config=True)¶
Create a PhfStream object for writing or loading phf files.
- Parameters:
filename (str) – Phf file name.
mode (Literal["r", "w"]) – Either
"r"or"w"to open the file for reading or writing, respectively.set_config (bool) – If
Trueandmode == 'r', set the following configuration attributes with values loaded from the file:config.grid,config.tolerance.
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.
Attributes
Object properties.
- close()¶
Close the stream.
- contents(only_explicit=True)¶
Index of the stream contents.
- Parameters:
only_explicit (bool) – If set, only explicitly written component and technology entries are returned (excludes automatically included dependencies).
- Returns:
dict[Literal[“components”, “technologies”], set[str] | set[tuple[str, str]]] 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 (str | None) – If given, only the named component is returned, otherwise all components in the stream.
only_explicit (bool) – If set, only explicitly stored components are returned. This argument is ignored if name is given.
- Returns:
Loaded components.
- Return type:
list[Component]
- load_technology(name=None, version=None, only_explicit=True)¶
Load technologies from this stream.
- Parameters:
name (str | None) – If given, only technologies with this name are returned, otherwise all technologies in the stream.
version (str | None) – If given, only technologies with this version are returned, otherwise all technologies in the stream.
only_explicit (bool) – If set, only explicitly stored technologies are returned. This argument is ignored if both name and version are given.
- Returns:
Loaded technologies.
- Return type:
list[Technology]
- properties¶
Object properties.
- Type:
- write(*args)¶
Write components and technologies through this stream.
- Parameters:
*args (Component | Technology) – Components and technologies to be written.
- Returns:
This object.
- Return type: