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: dayz_dev_tools.pbo_reader.PBOReader, files_to_extract: List[str], *, verbose: bool, deobfuscate: bool, cfgconvert: Optional[str]) 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.
Note
Deobfuscation may not always work, as obfuscation techniques may evolve over time.
Public Key Management
- dayz_dev_tools.keys.copy_keys(source: str, destination: str) None[source]
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: dayz_dev_tools.server_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() Optional[str][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() Optional[str][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() Optional[str][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
- dayz_dev_tools.list_pbo.list_pbo(reader: dayz_dev_tools.pbo_reader.PBOReader, *, verbose: bool) None[source]
Print the contents of a PBO archive to stdout in tabular format.
- Parameters
reader: A
PBOReaderinstance representing the PBO archive to list.verbose: When True, additional detail will be printed.
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__(filename: bytes, mime_type: bytes, original_size: int, reserved: int, time_stamp: int, data_size: int, content_reader: Optional[dayz_dev_tools.pbo_file_reader.PBOFileReader] = None) None
- data_size: int
The size of the file in the PBO archive
- filename: bytes
The raw name of the file
- 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.
- 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) Optional[dayz_dev_tools.pbo_file.PBOFile][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[dayz_dev_tools.pbo_file.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.
Script Logs
- dayz_dev_tools.script_logs.newest(directory: str) Optional[str][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: Optional[str], *, timeout: int = 10) Optional[str][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: typing.Optional[str] = None, config: typing.Optional[str] = None, directory: typing.Optional[str] = None, profile_directory: typing.Optional[str] = None, workshop_directory: typing.Optional[str] = None, mods: typing.List[str] = <factory>, server_mods: typing.List[str] = <factory>, mission_directory: typing.Optional[str] = None, parameters: typing.List[str] = <factory>) None
- config: Optional[str] = None
DayZ Server config filename override (optional)
- directory: Optional[str] = None
Directory to switch to before running DayZ Server (optional)
- executable: Optional[str] = None
DayZ Server executable filename override (optional)
- mission_directory: Optional[str] = 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: Optional[str] = None
DayZ Server profile directory name override (optional)
- server_mods: List[str]
DayZ server mod list to add
- workshop_directory: Optional[str] = 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: typing.Dict[str, dayz_dev_tools.server_config.BundleConfig], directory: typing.Optional[str] = None, profile_directory: typing.Optional[str] = None, mission_directory: typing.Optional[str] = None, parameters: typing.List[str] = <factory>) None
- bundle_path: str
Filename of the bundles Python module
- bundles: Dict[str, dayz_dev_tools.server_config.BundleConfig]
Configuration file bundles, by name (see
dayz_dev_tools.server_config.BundleConfig)
- config: str
DayZ Server config filename
- directory: Optional[str] = None
Directory to switch to before running DayZ Server (optional)
- executable: str
DayZ Server executable filename
- mission_directory: Optional[str] = None
DayZ Server mission directory name (optional)
- parameters: List[str]
Extra server command line parameters to add
- profile_directory: Optional[str] = None
DayZ Server profile directory name (optional)
- workshop_directory: str
DayZ workshop directory name
- dayz_dev_tools.server_config.load(filename: str) dayz_dev_tools.server_config.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.