srctools.cmdseq
CmdSeq.wc is Hammer’s configuration format for “expert” compiles, storing the various sequences of executables to compile maps with.
This module allows for reading and writing this file format. Valve’s is a binary format,
while both Strata Source and Hammer++ have alternate keyvalue formats which are human-readable.
Classes
- class srctools.cmdseq.SpecialCommand
Bases:
EnumSpecial commands to run instead of an executable.
Depending on the command, these either take a single
filenameor asource destinationpair.- CHANGE_DIR = 256
Change the working directory to the specified folder.
- COPY_FILE = 257
Copies the
sourcefile to thedestinationfilename.
- DELETE_FILE = 258
Deletes the specified
filename.
- RENAME_FILE = 259
Renames the
sourcefile to thedestinationfilename.
- STRATA_COPY_FILE_IF_EXISTS = 261
Strata Source addition. If
sourceexists, copies it to thedestinationfilename.
- class srctools.cmdseq.Command(
- exe: str | SpecialCommand,
- args: str,
- *,
- enabled: bool = True,
- ensure_file: str | None = None,
- use_proc_win: bool = True,
- no_wait: bool = False,
A command to run.
- exe: str | SpecialCommand
Either the path to the executable, or one of several special commands. A few presets are also available like
$vis_exe.
- ensure_file: str | None
If non-
None, the command should fail if this file doesn’t exist after it runs.
Binary Format
Valve uses a binary file format, which can be read and written by these two functions.
Keyvalues Format
Strata Source and Hammer++ both independently switched over to using a keyvalues-based format
instead, which is human-editable. The parse function detects and reads this automatically,
but these functions are available to directly parse from keyvalues, and produce the tree to resave:
- srctools.cmdseq.parse_keyvalues(
- kv: Keyvalues,
Parse Strata Source’s or Hammer++’s alternate Keyvalues file format.
This is automatically called by the standard
parsefunction if the signature is detected.
- srctools.cmdseq.build_keyvalues( ) Keyvalues
Build Strata Source’s or Hammer++’s keyvalues file format, for export.
- Parameters:
file_format – The file format to produce,
"strata"or"hammer++". Hammer++ does not support theensure_file,use_proc_winorno_waitattributes.sequences – The sequences to build. The keys are the name of the commands.