API Reference
The APIs documented in this section are the public interface of the
dayz-dev-tools package. All other functions and classes are considered
private and may change without notice.
Extracting PBO Content
- dayz_dev_tools.extract_pbo.extract_pbo(reader: PBOReader, files_to_extract: list[str], *, verbose: bool, deobfuscate: bool, cfgconvert: str | None, pattern: str | None = None) None[source]
Extract one or more files contained in a PBO archive.
- Parameters:
reader: A
PBOReaderinstance representing the PBO archive containing the file(s) to be extracted.files_to_extract: A list of fully-qualified paths of the files to be extracted.
verbose: When True, print the paths of the files being extracted to stdout.
deobfuscate: When True, attempt to deobfuscate obfuscated script files.
cfgconvert: Location of the DayZ Tools CfgConvert.exe binary, or None if binarized configs should not be converted.
pattern: Only extract filenames matching this glob pattern, or None if all files should be extracted.
Note
Deobfuscation may not always work, as obfuscation techniques may evolve over time.
DayZ GUIDs
Public Key Management
- dayz_dev_tools.keys.copy_keys(source: str, destination: str) None[source]
Recursively search for *.bikey (public key) files in one directory and copy them to another directory.
- Parameters:
source: The source directory to be searched for
*.bikeyfiles.destination: The destination directory where found
*.bikeyfiles are to be copied to. This directory will be created if it does not already exist.
Launch Settings
- class dayz_dev_tools.launch_settings.LaunchSettings[source]
Settings that determine what command line parameters to pass when running DayZ Server.
- __init__(config: ServerConfig) None[source]
Create a
LaunchSettingsfrom aServerConfig.- Parameters:
config: A
ServerConfiginstance returned bydayz_dev_tools.server_config.load().
- add_mod(name: str) None[source]
Add a mod to be loaded.
- Parameters:
name: The name of the mod to load. If the name starts with
@, it will be loaded from the DayZ workshop directory (seeLaunchSettings.workshop_directory()), else the name is expected to be the name of the directory containing the mod.
- add_parameter(param: str) None[source]
Add extra parameter to pass on the DayZ Server command line.
- Parameters:
param: The parameter to pass on the DayZ Server command line.
- add_server_mod(name: str) None[source]
Add a server mod to be loaded.
- Parameters:
name: The name of the server mod to load. If the name starts with
@, it will be loaded from the DayZ workshop directory (seeLaunchSettings.workshop_directory()), else the name is expected to be the name of the directory containing the server mod.
- config() str[source]
Get the DayZ Server config filename, usually
serverDZ.cfg.- Returns:
The DayZ Server config filename.
- directory() str | None[source]
Get the directory to switch to before running DayZ Server.
- Returns:
The directory to switch to or
Noneif it hasn’t been set.
- executable() str[source]
Get the DayZ Server executable filename, usually
.\DayZServer_x64.exe.- Returns:
The DayZ Server executable filename.
- load_bundle(name: str) None[source]
Load a bundle to configure DayZ Server launch settings.
- Parameters:
name: The name of the bundle to load.
This method will first try to find the bundle in the settings TOML file (e.g.
server.toml). If the bundle name does not exist there, then it will then try to find the bundle in the bundles Python module (e.g.bundles.py).
- mission_directory() str | None[source]
Get the DayZ Server mission directory.
- Returns:
The DayZ Server mission directory, or
Noneif the mission directory hasn’t been set.
Note
The mission directory is often configured in the DayZ Server config file (e.g.
serverDZ.cfg). See alsoLaunchSettings.config().
- parameters() list[str][source]
Get extra command line parameters to pass to DayZ Server.
- Returns:
The list of extra command line parameters to pass to DayZ Server.
- profile_directory() str | None[source]
Get the DayZ Server profile directory name.
- Returns:
The DayZ Server profile directory name, or
Noneif it hasn’t been set.
Note
When the profile directory is unspecified, DayZ Server will usually use
%LOCALAPPDATA%\DayZas the profile directory.
- server_mods() list[str][source]
Get the list of server mods to load.
- Returns:
The list of server mods to load.
- set_config(path: str) None[source]
Set the DayZ Server config filename.
- Parameters:
path: The DayZ Server config filename.
- set_directory(path: str) None[source]
Set the directory to switch to before running DayZ Server.
- Parameters:
path: The directory to switch to before running DayZ Server.
- set_executable(path: str) None[source]
Set the DayZ Server executable filename.
- Parameters:
path: The DayZ Server executable filename.
- set_mission_directory(name: str) None[source]
Set the DayZ Server mission directory.
- Parameters:
name: The DayZ Server mission directory name.
- set_profile_directory(path: str) None[source]
Set the DayZ Server profile directory name.
- Parameters:
path: The DayZ Server profile directory name.
Listing PBO Content
PBO File
- class dayz_dev_tools.pbo_file.PBOFile[source]
Interface for accessing a file contained within a PBO archive. Instances should be obtained using
dayz_dev_tools.pbo_reader.PBOReader.file().- __init__(prefix: bytes | None, filename: bytes, mime_type: bytes, original_size: int, reserved: int, time_stamp: int, data_size: int, content_reader: PBOFileReader | None = None) None
- data_size: int
The size of the file in the PBO archive
- deobfuscated_filename(index: int) str[source]
Get the deobfuscated version of the file’s name.
- Parameters:
index: A number to uniquely identify the deobfuscated file.
- Returns:
A deobfuscated version of the file’s name.
- deobfuscated_split(index: int) list[bytes][source]
Get the file’s deobfuscated name as a
list, where each element in the list represents a component of the file’s path.- Parameters:
index: A number to uniquely identify the deobfuscated file.
- Returns:
A list of deobfuscated path components.
- filename: bytes
The raw name of the file
- invalid() bool[source]
Returns True if filename is not a valid Windows filename.
- Returns:
True if filename is not a valid Windows filename, or False otherwise.
- normalized_filename() str[source]
Get the normalized version of the file’s name.
The resulting filename will contain the local OS’s native directory separator character and any bytes representing illegal UTF-8 will be replaced.
- Returns:
A normalized version of the file’s name.
- obfuscated() bool[source]
Returns True if filename appears to be an obfuscated script file.
- Returns:
True if filename appears to be an obfuscated script, or False otherwise.
- split_filename() list[bytes][source]
Get the file’s name as a
list, where each element in the list represents a component of the file’s path.- Returns:
A list of path components.
- time_stamp: int
The file’s creation or modification time as a Unix timestamp
- type() str[source]
Get the type of the file.
- Returns:
A 4-character string representing the file type.
- unpack(output_file: BinaryIO) None[source]
Write the contents of the file.
- Parameters:
output_file: A binary file-like object where the contents are to be written.
- unpacked_size() int[source]
Get the original size of the file. If the file is compressed, this will be different from the
PBOFile.data_size.- Returns:
The original size of the file.
PBO Reader
- class dayz_dev_tools.pbo_reader.PBOReader[source]
Interface for reading a PBO archive.
- __init__(file: BinaryIO)[source]
Create a new
PBOReaderinstance.- Parameters:
file: A binary file-like object providing PBO archive contents.
- file(filename: AnyStr) PBOFile | None[source]
Get a file contained in the PBO archive, by name.
- Parameters:
filename: A
strorbytescontaining the filename of the file to be retrieved. If astr, the filename is matched case-insensitively by the normalized filename in the PBO (seedayz_dev_tools.pbo_file.PBOFile.normalized_filename()). If abytes, the filename is matched case-insensitively by the raw filename (seedayz_dev_tools.pbo_file.PBOFile.filename).
- Returns:
An instance of
dayz_dev_tools.pbo_file.PBOFilerepresenting the retrieved file.
- files() list[PBOFile][source]
Get the list of files contained in the PBO archive.
- Returns:
A list of
PBOFileinstances representing the files contained in the PBO archive.
PBO Writer
- class dayz_dev_tools.pbo_writer.PBOWriter[source]
Interface for writing a PBO archive.
- __init__(*, cfgconvert: str | None) None[source]
Create a new
PBOWriterinstance.- Parameters:
cfgconvert: The location of the DayZ Tools
CfgConvert.exeprogram, orNoneifconfig.cppfiles should not be binarized.
- add_file(path: Path) None[source]
Add a file to the PBO archive.
- Parameters:
path: A
pathlib.Pathinstance containing the location of the file to be added.
Script Logs
- dayz_dev_tools.script_logs.newest(directory: str) str | None[source]
Find the newest
script_*.logfile in a directory.- Parameters:
directory: The directory to search for
script_*.logfiles.
- Returns:
The filename of the newest
script_*.logfile, orNoneif no script logs could be found.
- dayz_dev_tools.script_logs.stream(outfile: TextIO, infile: TextIO, keep_streaming: Callable[[], bool]) None[source]
Stream the contents of a log file to another file.
- Parameters:
outfile: A file-like object to stream the log file contents to.
infile: A file-like object containing the log to stream.
keep_streaming: A callback function taking no arguments that returns True if streaming should continue or False if streaming should stop and the function should return.
- dayz_dev_tools.script_logs.wait_for_new(directory: str, previous_log_name: str | None, *, timeout: int = 10) str | None[source]
Wait for a script log that is newer than another script log to be created in a directory.
- Parameters:
directory: The directory to search for a newer
script_*.logfile.previous_log_name: The current newest
script_*.logfile.timeout: Give up and return
Noneif no new script log is created after this many seconds.
- Returns:
The filename of the newer
script_*.logfile, orNoneif no newer script logs are created.
Server Configuration
- class dayz_dev_tools.server_config.BundleConfig[source]
Configuration file bundle settings.
- __init__(executable: str | None = None, config: str | None = None, directory: str | None = None, profile_directory: str | None = None, workshop_directory: str | None = None, mods: list[str] = <factory>, server_mods: list[str] = <factory>, mission_directory: str | None = None, parameters: list[str] = <factory>) None
- config: str | None = None
DayZ Server config filename override (optional)
- directory: str | None = None
Directory to switch to before running DayZ Server (optional)
- executable: str | None = None
DayZ Server executable filename override (optional)
- mission_directory: str | None = None
DayZ Server mission directory name override (optional)
- mods: list[str]
DayZ mod list to add
- parameters: list[str]
Extra server command line parameters to add
- profile_directory: str | None = None
DayZ Server profile directory name override (optional)
- server_mods: list[str]
DayZ server mod list to add
- workshop_directory: str | None = None
DayZ workshop directory name override (optional)
- class dayz_dev_tools.server_config.ServerConfig[source]
Configuration file settings.
- __init__(executable: str, config: str, bundle_path: str, workshop_directory: str, bundles: dict[str, ~dayz_dev_tools.server_config.BundleConfig], directory: str | None = None, profile_directory: str | None = None, mission_directory: str | None = None, parameters: list[str] = <factory>) None
- bundle_path: str
Filename of the bundles Python module
- bundles: dict[str, BundleConfig]
Configuration file bundles, by name (see
dayz_dev_tools.server_config.BundleConfig)
- config: str
DayZ Server config filename
- directory: str | None = None
Directory to switch to before running DayZ Server (optional)
- executable: str
DayZ Server executable filename
- mission_directory: str | None = None
DayZ Server mission directory name (optional)
- parameters: list[str]
Extra server command line parameters to add
- profile_directory: str | None = None
DayZ Server profile directory name (optional)
- workshop_directory: str
DayZ workshop directory name
- dayz_dev_tools.server_config.load(filename: str) ServerConfig[source]
Read a TOML-syntax DayZ Server configuration file.
- Parameters:
filename: The name of the configuration file to read (e.g.
server.toml)
- Returns:
A
ServerConfig.