General cleanup

This commit is contained in:
Eric Torres 2019-04-12 10:10:47 -07:00
parent 95289cbc68
commit 14204b1c58

View File

@ -1,7 +1,7 @@
""" """
.. author:: Eric Torres .. author:: Eric Torres
.. module:: rbackup.struct.hierarchy .. module:: rbackup.struct.hierarchy
:synopsis: Classes for creating the backup hierarchy. :synopsis: Classes for creating the backup hierarchy.
""" """
import json import json
import logging import logging
@ -27,9 +27,9 @@ class Hierarchy(PathLike):
Attributes Attributes
---------- ----------
* path * Hierarchy.path
* name * Hierarchy.name
* metadata_path * Hierarchy.metadata_path
Methods Methods
------- -------
@ -42,8 +42,7 @@ class Hierarchy(PathLike):
def __init__(self, dest): def __init__(self, dest):
"""Default constructor for the Hierarchy class. """Default constructor for the Hierarchy class.
>>> hier = Hierarchy('backup_dir') >>> Hierarchy('backup_dir').path
>>> hier.path
PosixPath('backup_dir') PosixPath('backup_dir')
:param dest: the root directory of the backup hierarchy :param dest: the root directory of the backup hierarchy
@ -54,19 +53,18 @@ class Hierarchy(PathLike):
except TypeError as e: except TypeError as e:
raise e raise e
def __fspath__(self):
return str(self._path)
def __repr__(self): def __repr__(self):
"""Return a string representation of this Hierarchy.""" """Return a string representation of this Hierarchy."""
return f"{self.__class__.__name__}('{self._path}')" return f"{self.__class__.__name__}('{self._path}')"
def __fspath__(self):
return str(self._path)
@property @property
def path(self): def path(self):
"""Return the base directory of this hierarchy. """Return the base directory of this hierarchy.
>>> hier = Hierarchy('backup') >>> Hierarchy('backup').path
>>> hier.path
PosixPath('backup') PosixPath('backup')
:rtype: path-like object :rtype: path-like object
@ -77,8 +75,7 @@ class Hierarchy(PathLike):
def name(self): def name(self):
"""Return the name of this hierarchy. """Return the name of this hierarchy.
>>> hier = Hierarchy('backup/data/snapshot-one') >>> Hierarchy('backup/data/snapshot-one').name
>>> hier.name
'snapshot-one' 'snapshot-one'
:rtype: str :rtype: str
@ -89,8 +86,7 @@ class Hierarchy(PathLike):
def metadata_path(self): def metadata_path(self):
"""Return the path of this hierarchy's metadata file. """Return the path of this hierarchy's metadata file.
>>> hier = Hierarchy('backup') >>> Hierarchy('backup').metadata_path
>>> hier.metadata_path
PosixPath('backup/.metadata') PosixPath('backup/.metadata')
:rtype: path-like object :rtype: path-like object
@ -98,8 +94,8 @@ class Hierarchy(PathLike):
return self._path / ".metadata" return self._path / ".metadata"
def gen_metadata(self): def gen_metadata(self):
"""Generate metadata for this repository. After this method is called, """Generate metadata for this repository.
the data necessary for this repository has been created. After this method is called, the data necessary for this repository has been created.
""" """
raise NotImplementedError("This method must be called in a child class.") raise NotImplementedError("This method must be called in a child class.")