Skip to content

uninstall

Functionality for copying all files into their instances

break_ender_chest(minecraft_root)

Replace all instance symlinks with their actual targets, effectively "uninstalling" EnderChest

Parameters:

Name Type Description Default
minecraft_root Path

The root directory that your minecraft stuff (or, at least, the one that's the parent of your EnderChest folder)

required
Source code in enderchest/uninstall.py
def break_ender_chest(minecraft_root: Path) -> None:
    """Replace all instance symlinks with their actual targets, effectively
    "uninstalling" EnderChest

    Parameters
    ----------
    minecraft_root : Path
        The root directory that your minecraft stuff (or, at least, the one
        that's the parent of your EnderChest folder)
    """
    instances = load_ender_chest_instances(minecraft_root, log_level=IMPORTANT)
    if not instances:
        BREAK_LOGGER.error("Aborting.")
        return

    BREAK_LOGGER.warning(
        "Are you sure you want to uninstall this EnderChest?"
        "\nDoing so will replace ALL the symlinks in each of the above instances"
        "\nwith copies of their EnderChest-linked targets."
        "\n\nTHIS CANNOT EASILY BE UNDONE!!"
    )
    if not confirm(default=False):
        BREAK_LOGGER.error("Aborting.")
        return

    chest_folder = fs.ender_chest_folder(minecraft_root)
    _break(chest_folder, instances)

    BREAK_LOGGER.log(
        IMPORTANT,
        "EnderChest has been uninstalled."
        "\nYou may now delete %s"
        "\nand uninstall the EnderChest package",
        chest_folder,
    )

break_instances(minecraft_root, instance_names)

Deregister the specified instances from EnderChest, replacing all instance symlinks with their actual targets, and then removing those instances from the enderchest.cfg

Parameters:

Name Type Description Default
minecraft_root Path

The root directory that your minecraft stuff (or, at least, the one that's the parent of your EnderChest folder)

required
instance_names list of str

The names of the instances to break

required
Source code in enderchest/uninstall.py
def break_instances(minecraft_root: Path, instance_names: Iterable[str]) -> None:
    """Deregister the specified instances from EnderChest, replacing all
    instance symlinks with their actual targets, and then removing those
    instances from the enderchest.cfg

    Parameters
    ----------
    minecraft_root : Path
        The root directory that your minecraft stuff (or, at least, the one
        that's the parent of your EnderChest folder)
    instance_names : list of str
        The names of the instances to break
    """
    ender_chest = load_ender_chest(minecraft_root)

    instance_lookup = {instance.name: instance for instance in ender_chest.instances}
    instances: list[InstanceSpec] = []
    for name in instance_names:
        try:
            instances.append(instance_lookup[name])
        except KeyError:
            BREAK_LOGGER.warning(
                f'No instance named "%s" is registered to this EnderChest.'
                "\nSkipping.",
                name,
            )
    if len(instances) == 0:
        BREAK_LOGGER.error("No valid instances specified.\nAborting.")
        return

    BREAK_LOGGER.warning(
        "Are you sure you want to remove the following instances from your EnderChest?"
        "\n%s\nDoing so will replace ALL the symlinks in each of the above instances"
        "\nwith copies of their EnderChest-linked targets."
        "\n\nTHIS CANNOT EASILY BE UNDONE!!",
        "\n".join((f"  - {instance.name}" for instance in instances)),
    )
    if not confirm(default=False):
        BREAK_LOGGER.error("Aborting.")
        return

    _break(fs.ender_chest_folder(minecraft_root), instances)
    for instance in instances:
        ender_chest._instances.remove(instance)
    create_ender_chest(minecraft_root, ender_chest)