Overview

Path PyPoE/poe/file/ot.py
Version 1.0.0a0
Revision $Id: 12159b88f87b69718fce413a4f2835dea306be2d $
Author Omega_K2

Description

Support for .ot file format.

.ot file seem to be generally used for server-side settings related to abstract objects.

Generally make sure to consider the context of the file when interpreting the contents; there is a chance they’re extended or embedded though .dat files and the key/value pairs found are in relevance to the context.

Usually they’re accompanied by .otc files which handle client-side settings.

See also:

Agreement

See PyPoE/LICENSE

Documentation

class PyPoE.poe.file.ot.OTFile(*args, **kwargs)[source]

Bases: PyPoE.poe.file.shared.keyvalues.AbstractKeyValueFile

Representation of a .ot file.

Variables:
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:

object

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:

object

Raises:

TypeError – if file_path_or_raw has an invalid type

merge(other)

Merge with other file.

Parameters:other (AbstractKeyValueFile) – Instance of the other file to merge with
Raises:ValueError – if other has a different type then this instance
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:

object

Raises:

TypeError – if file_path_or_raw has an invalid type

write(*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:

object

Raises:

TypeError – if file_path_or_raw has an invalid type

Warning

The current values held by the file instance will be written. This means values inherited from parent files will also be written.

class PyPoE.poe.file.ot.OTFileCache(path_or_ggpk=None, files=None, files_shortcut=True, instance_options=None, read_options=None)[source]

Bases: PyPoE.poe.file.shared.keyvalues.AbstractKeyValueFileCache

Cache for OTFile instances.

FILE_TYPE

alias of OTFile

__init__(path_or_ggpk=None, files=None, files_shortcut=True, instance_options=None, read_options=None)
Parameters:
  • path_or_ggpk (str | GGPKFile) – The root path (i.e. relative to content.ggpk) where the files are stored or a PyPoE.poe.file.ggpk.GGPKFile instance
  • files (Iterable) – Iterable of files that will be loaded right away
  • files_shortcut (bool) – Whether to use the shortcut function, i.e. self.__getitem__
  • instance_options (dict[str, object]) – options to pass to the file’s __init__ method
  • read_options (dict[str, object]) – options to pass to the file instance’s read method
Raises:
get_file(file_name, *args, **kwargs)

Returns the the specified file from the cache.

If the file does not exist, read it from the path specified on cache creation, add it to the cache and then return it.

Parameters:file_name (str) – File to retrieve
Returns:read file instance
Return type:AbstractFileReadOnly
path_or_ggpk

The path or PyPoE.poe.file.ggpk.GGPKFile instance the cache was created with