Added documentation
Some checks failed
continuous-integration/drone the build failed

This commit is contained in:
Jef Roosens 2021-04-25 19:26:12 +02:00
parent d513a03c4a
commit ecfa6fe7b7
Signed by: Jef Roosens
GPG key ID: B580B976584B5F30
4 changed files with 83 additions and 44 deletions

View file

@ -1,4 +1,7 @@
"""Parent module for the various spec types."""
from .spec import Spec
from .directory import DirectorySpec
from .volume import VolumeSpec
from .container import ContainerSpec
__all__ = ["Spec", "DirectorySpec", "VolumeSpec", "ContainerSpec"]

View file

@ -1,3 +1,4 @@
"""Module defining a Container-based spec."""
from .spec import Spec
from typing import Union
from pathlib import Path
@ -6,11 +7,10 @@ import subprocess
class ContainerSpec(Spec):
"""
A spec for backing up via a container.
"""
"""Spec for backing up via a container."""
_SKEL = {"container": None, "command": None, "mountpoint": "/from"}
"""The skeleton for the ContainerSpec config."""
def __init__(
self,
@ -23,6 +23,22 @@ class ContainerSpec(Spec):
mountpoint: str,
notify=None,
):
"""
Create a new ContainerSpec object.
Args:
name: name of the spec (used as an identifier)
container: the Docker container to back up
destination: where to store the backups (gets created if
non-existent)
limit: max amount of backups to keep
command: command to run inside the container. This command should
perform a specified backup and output this data to stdout. This
output then gets piped to a backup file.
extension: the extension of the backup files.
mountpoint:
notify: notifier object (may be None)
"""
super().__init__(name, destination, limit, extension, notify)
self.container = container

View file

@ -60,7 +60,19 @@ class Spec:
self.extension = extension
@classmethod
def skeleton(cls):
def skeleton(cls: "Spec") -> Dict:
"""
Return the skeleton for the given class.
It works by inspecting the inheritance tree and merging the skeleton
for each of the parents.
Args:
cls: the class to get the skeleton for
Returns:
a dictionary containing the skeleton
"""
return skeleton.merge(
*[val._SKEL for val in reversed(inspect.getmro(cls)[:-1])]
)