Overview¶
Path | PyPoE/poe/file/idt.py |
Version | 1.0.0a0 |
Revision | $Id: f6432f6155b2d277be48be55bd8a89f893a14485 $ |
Author | Omega_K2 |
Description¶
File Format handler for Grinding Gear Games’ .idt format.
.idt files are generally used to link the inventory texture to an object.
Agreement¶
See PyPoE/LICENSE
Documentation¶
Public API¶
-
class
PyPoE.poe.file.idt.
IDTFile
(data=None)[source]¶ Bases:
PyPoE.poe.file.shared.AbstractFile
Encapsulated in-memory representation of .idt files.
-
__init__
(data=None)[source]¶ Creates a new IDTFile instance.
Optionally data can be specified to initialize the object in memory with the given data. The same can be achieved by simply setting the relevant attributes. Note that
IDTFile.read()
will override any initial data.Parameters: data (dict or None) – Take a dict containing the data to create this object and it’s attributes with. The dict should match the structure of the classes attributes and the respective sub attributes. Raises: TypeError
– if dict contains data of invalid types
-
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
-
get_write_buffer
(file_path_or_raw, function, *args, **kwargs)¶ Will attempt to open the given file_path_or_raw in write 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 write to
- 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
-
records
¶ Get records
Returns: List of stored TextureRecord
instancesReturn type: TextureList[TextureRecord]
-
write
(file_path_or_raw, *args, **kwargs)¶ Write the contents of file to the specified path or buffer.
If a buffer or bytes was given, a buffer object with the new data should be returned.
If a file path was given, the resulting data should be written to the specified file.
Parameters: - file_path_or_raw (BytesIO | bytes | str) – file path, bytes or buffer to write to
- args – Additional positional arguments
- kwargs – Additional keyword arguments
Returns: result of the write operation, if any
Return type: Raises: TypeError
– if file_path_or_raw has an invalid type
-
-
class
PyPoE.poe.file.idt.
TextureRecord
(name, records=None)[source]¶ Bases:
PyPoE.shared.containers.Record
Object that represents a single texture with the relevant attributes
Variables: - 'name' (str) – name (internal path) of the texture
- 'records' (CoordinateList[CoordinateRecord]) –
CoordinateList
ofCoordinateRecord
instances for this texture.
-
__init__
(name, records=None)[source]¶ Parameters: - name (str) – name (internal path) of the texture
- records (None or CoordinateList[CoordinateRecord]) –
CoordinateList
ofCoordinateRecord
instances for this texture. If None, an emptyCoordinateList
will be created.
Raises:
Internal API¶
-
class
PyPoE.poe.file.idt.
TextureList
[source]¶ Bases:
PyPoE.shared.containers.TypedList
A list that only accepts TextureRecord instances.
-
__init__
¶ Initialize self. See help(type(self)) for accurate signature.
-
append
(object) → None -- append object to end¶
-
clear
() → None -- remove all items from L¶
-
copy
() → list -- a shallow copy of L¶
-
count
(value) → integer -- return number of occurrences of value¶
-
extend
(iterable) → None -- extend list by appending elements from the iterable¶
-
index
(value[, start[, stop]]) → integer -- return first index of value.¶ Raises ValueError if the value is not present.
-
insert
(index, p_object)¶ L.insert(index, object) – insert object before index
-
pop
([index]) → item -- remove and return item at index (default last).¶ Raises IndexError if list is empty or index is out of range.
-
remove
(value) → None -- remove first occurrence of value.¶ Raises ValueError if the value is not present.
-
reverse
()¶ L.reverse() – reverse IN PLACE
-
sort
(key=None, reverse=False) → None -- stable sort *IN PLACE*¶
-
-
class
PyPoE.poe.file.idt.
CoordinateList
[source]¶ Bases:
PyPoE.shared.containers.TypedList
A list that only accepts
CoordinateRecord
instances.-
__init__
¶ Initialize self. See help(type(self)) for accurate signature.
-
append
(object) → None -- append object to end¶
-
clear
() → None -- remove all items from L¶
-
copy
() → list -- a shallow copy of L¶
-
count
(value) → integer -- return number of occurrences of value¶
-
extend
(iterable) → None -- extend list by appending elements from the iterable¶
-
index
(value[, start[, stop]]) → integer -- return first index of value.¶ Raises ValueError if the value is not present.
-
insert
(index, p_object)¶ L.insert(index, object) – insert object before index
-
pop
([index]) → item -- remove and return item at index (default last).¶ Raises IndexError if list is empty or index is out of range.
-
remove
(value) → None -- remove first occurrence of value.¶ Raises ValueError if the value is not present.
-
reverse
()¶ L.reverse() – reverse IN PLACE
-
sort
(key=None, reverse=False) → None -- stable sort *IN PLACE*¶
-