batools.spinoff package

A system to wrangle projects spun off from a parent Ballistica project.

Think of this as ‘subclassing’ the project. Spinoff can arbitrarily filter/override/exclude files from the source project such that only a minimal number of additions and changes need to be included in the spinoff project itself.

Spinoff operates by copying or hard-linking source project files in from a git submodule, while also telling git to ignore those same files. At any point, the submodule/core system can be jettisoned to leave a 100% self contained standalone project. To do this, just kill the submodule and remove the ‘spinoff’ section in .gitignore.

class batools.spinoff.SpinoffContext(src_root: str, dst_root: str, mode: Mode, *, force: bool = False, verbose: bool = False, print_full_lists: bool = False, override_paths: list[str] | None = None, backport_file: str | None = None, auto_backport: bool = False, describe_path: str | None = None)[source]

Bases: object

Guts of the spinoff system.

exception BackportInProgressError[source]

Bases: Exception

Error we can raise to bow out of processing during a backport.

class Mode(*values)[source]

Bases: Enum

Mode the context can operate in.

BACKPORT = 'backport'
CHECK = 'check'
CLEAN = 'clean'
CLEAN_CHECK = 'cleancheck'
CLEAN_LIST = 'cleanlist'
DESCRIBE_PATH = 'describe_path'
DIFF = 'diff'
OVERRIDE = 'override'
STATUS = 'status'
UPDATE = 'update'
default_filter_file(src_path: str, text: str) str[source]

Run default filtering on a file.

default_filter_path(text: str) str[source]

Run default filtering on path text.

default_filter_text(text: str) str[source]

Run default filtering on a piece of text.

classmethod get_active() SpinoffContext[source]

Return the context currently running.

replace_path_components(path: str, replace_src: str, replace_dst: str) str[source]

Replace a path hierarchy with another.

Does the right thing for parents. For instance, src ‘a/b/c’ and dst ‘a2/b2/c2’ will correctly filter ‘a/foo’ to ‘a2/foo’ and ‘a/b/foo’ to ‘a2/b2/foo’.

run() None[source]

Do the thing.

strict: bool

By default, if dst files have their modtimes changed but still line up with src files, we can recover. But one may choose to error in that case to track down things mucking with dst files when they shouldn’t be.

batools.spinoff.spinoff_main() None[source]

Main script entry point.

batools.spinoff.spinoff_test(args: list[str]) None[source]

High level test run command; accepts args and raises CleanErrors.