Overview¶
Path | PyPoE/poe/file/psg.py |
Version | 1.0.0a0 |
Revision | $Id: a426f1cabc7a71a4cc347b3c6971ce2dced06d54 $ |
Author | Omega_K2 |
Description¶
Support for .psg (Passive Skill Graph) file format.
Agreement¶
See PyPoE/LICENSE
Documentation¶
Public API¶
API for common and every day use.
-
class
PyPoE.poe.file.psg.
PSGFile
(passive_skills_dat_file=None, *args, **kwargs)[source]¶ Bases:
PyPoE.poe.file.shared.AbstractFileReadOnly
Representation of a .psg (Passive Skill Tree Graph) file.
Parameters: - _passive_skills (None or DatReader) – reference to the
PyPoE.poe.file.dat.DatReader
if specified - root_passives (list[int] or list[DatRecord]) – list of root (starting class) passive nodes
- groups (list[GraphGroup]) – list of
GraphGroup
instances
-
get_read_buffer
(file_path_or_raw, function, *args, **kwargs)¶ Will attempt to open the given file_path_or_raw in read mode and pass the buffer to the specified function. The function must accept at least one keyword argument called ‘buffer’.
Parameters: - file_path_or_raw (BytesIO | bytes | str) – file path, bytes or buffer to read from
- args – Additional positional arguments to pass to the specified function
- kwargs – Additional keyword arguments to pass to the specified function
Returns: Result of the function
Return type: Raises: TypeError
– if file_path_or_raw has an invalid type
-
read
(file_path_or_raw, *args, **kwargs)¶ Reads the file contents into the specified path or buffer. This will also reset any existing contents of the file.
If a buffer or bytes was given, the data will be read from the buffer or bytes object.
If a file path was given, the resulting data will be read from the specified file.
Parameters: - file_path_or_raw (BytesIO | bytes | str) – file path, bytes or buffer to read from
- args – Additional positional arguments
- kwargs – Additional keyword arguments
Returns: result of the read operation, if any
Return type: Raises: TypeError
– if file_path_or_raw has an invalid type
- _passive_skills (None or DatReader) – reference to the
Internal API¶
API for internal use, but still may be useful to work with more directly.
-
class
PyPoE.poe.file.psg.
GraphGroup
(x, y, id)[source]¶ Bases:
PyPoE.shared.mixins.ReprMixin
Representation of a group in the passive skill tree graph.
Groups are a “circle” in the passive at a given position containing all the relevant nodes.
It is possible that a group only contains one node - this is common for the highway/pathway nodes.
Parameters: - x (float) – x coordinate in the passive skill tree
- y (float) – y coordinate in the passive skill tree
- id (int) – id (index in list) of the this group
- nodes (list[GraphGroupNode]) – list of child
GraphGroupNode
instances
-
__init__
(x, y, id)[source]¶ Parameters: - x (float) – x coordinate in the passive skill tree
- y (float) – y coordinate in the passive skill tree
- id (int) – id (index in list) of the this group
- nodes (list[GraphGroupNode]) – list of child
GraphGroupNode
instances
-
class
PyPoE.poe.file.psg.
GraphGroupNode
(parent, passive_skill, radius, position, connections)[source]¶ Bases:
PyPoE.shared.mixins.ReprMixin
Representation of a single node in a
GraphGroup
.A node contains the actual information about the passive skill value it holds and the connection as well the as the position within the group.
Warning
If the parent
PSGFile
was instantiated with a valid ‘PassiveSkills.dat’PyPoE.poe.file.dat.DatFile
instance, the passive_skill and connections variables contain references to the respective row (i.e. a PyPoE.poe.file.dat.DatRecord instance) instead of the integer id.Parameters: - parent (GraphGroup) – parent
GraphGroup
this node belongs to - passive_skill (int or DatRecord) – passive skill node of this node
- radius (int) – radius from the parent’s x,y-position
- position (int) – position of the node in the group; together with the radius this creates a clockwise rotation from 0 to 11
- connections (list[int] or list[DatRecord]) – list of passive skill nodes this node is connected to
-
__init__
(parent, passive_skill, radius, position, connections)[source]¶ Parameters: - parent (GraphGroup) – parent
GraphGroup
this node belongs to - passive_skill (int) – passive skill node id of this node
- radius (int) – radius from the parent’s x,y-position
- position (int) – position of the node in the group; together with the radius this creates a clockwise rotation from 0 to 11
- connections (list[int]) – list of passive skill nodes ids this node is connected to
- parent (GraphGroup) – parent
- parent (GraphGroup) – parent