dismantle.package package#

Module contents#

Creates a solution to handle multiple package formats.

class dismantle.package.DirectoryPackageFormat[source]#

Bases: dismantle.package._formats.PackageFormat

A package format using a directory to hold files.

static extract(src: Union[str, pathlib.Path], dest: Union[str, pathlib.Path]) None[source]#

Use the formatter to process any movement related actions.

static grasps(path: Union[str, pathlib.Path]) bool[source]#

Check if dir on the local filesystem has been provided.

class dismantle.package.HttpPackageHandler(name: str, src: Union[str, pathlib.Path], formats: Optional[List[dismantle.package._formats.PackageFormat]] = None, cache_dir: Optional[Union[str, pathlib.Path]] = None)[source]#

Bases: dismantle.package._handlers.PackageHandler

Url package structure.

static grasps(path: Union[str, pathlib.Path]) bool[source]#

Check if dir on the local filesystem has been provided.

install(path: str, version: Optional[str] = None) bool[source]#

Install the current package to the given path.

If there’s already a package in path we’ll only fetch if the version is different.

property installed: bool#

Return the current installation state.

property name: str#

Return the name of the package from the meta data.

property outdated: bool#

Execute a head request using the requests library.

To check that the ETag matches.

uninstall() bool[source]#

Uninstall the package.

verify(digest: Optional[str] = None) bool[source]#

Verify the package hasn’t been tampered with.

class dismantle.package.LocalPackageHandler(name: str, src: Union[str, pathlib.Path], formats: Optional[List[dismantle.package._formats.PackageFormat]] = None)[source]#

Bases: dismantle.package._handlers.PackageHandler

Directory package structure.

static grasps(path: Union[str, pathlib.Path]) bool[source]#

Check if the package format can process.

Check if a directory on the local filesystem has been provided.

install(path: Optional[str] = None, version: Optional[str] = None) bool[source]#

Install a package.

The local package handler does not install the package. No version control exists for the directory package type.

property installed: bool#

Return the current installation state.

property name: str#

Return the name of the package from the meta data.

property path: str#

Return the path the package is installed into.

uninstall() bool[source]#

Uninstall the package.

verify(digest: Optional[str] = None) bool[source]#

Verify the package hasn’t been tampered with.

class dismantle.package.PackageFormat[source]#

Bases: object

Base class for packet formats.

abstract static extract(src: Union[str, pathlib.Path], dest: Union[str, pathlib.Path]) bool[source]#

Verify a packages hash with the provided signature.

abstract static grasps(path: Union[str, pathlib.Path]) bool[source]#

Check if format can be processed.

abstract static verify(signature: str) bool[source]#

Verify a packages hash with the provided signature.

class dismantle.package.PackageHandler[source]#

Bases: object

Base PackageHandler interface.

The PackageHandler interface defines the structure expected for all package handlers and should be extended to provide additional custom package handler.

abstract static grasps(path: Union[str, pathlib.Path]) bool[source]#

Check if package handler understand a package format.

abstract install(path: Union[str, pathlib.Path], version: Optional[str] = None) bool[source]#

Install a specific package version.

abstract property installed: bool#

Return a boolean if the package has been installed.

abstract property name: str#

Return a string containing the name of the package.

abstract uninstall() bool[source]#

Uninstall a package.

abstract verify(signature: str) bool[source]#

Verify a packages hash with the provided signature.

class dismantle.package.TarPackageFormat[source]#

Bases: dismantle.package._formats.PackageFormat

A package format using a compressed tar file.

static extract(src: Union[str, pathlib.Path], dest: Union[str, pathlib.Path]) None[source]#

Extract the tarfile to the cache location.

static grasps(path: Union[str, pathlib.Path]) bool[source]#

Check if dir on the local filesystem has been provided.

class dismantle.package.TgzPackageFormat[source]#

Bases: dismantle.package._formats.PackageFormat

A package format using a tgz file compression.

static extract(src: Union[str, pathlib.Path], dest: Union[str, pathlib.Path]) None[source]#

Extract the tarfile to the cache location.

static grasps(path: Union[str, pathlib.Path]) bool[source]#

Check if dir on the local filesystem has been provided.

class dismantle.package.ZipPackageFormat[source]#

Bases: dismantle.package._formats.PackageFormat

A package format compressed as a zip file.

static extract(src: Union[str, pathlib.Path], dest: Union[str, pathlib.Path]) None[source]#

Extract the zipfile to the cache location.

static grasps(path: Union[str, pathlib.Path]) bool[source]#

Check if dir on the local filesystem has been provided.