Add metadata_path attribute

This commit is contained in:
Eric Torres 2019-03-29 15:27:34 -07:00
parent da1accf609
commit bf7416a42f
2 changed files with 14 additions and 8 deletions

View File

@ -23,13 +23,12 @@ class Hierarchy:
---------- ----------
* path * path
* name * name
* metadata_path
""" """
def __init__(self, dest): def __init__(self, dest):
"""Default constructor for the Hierarchy class. """Default constructor for the Hierarchy class.
Example
-------
>>> hier = Hierarchy('backup') >>> hier = Hierarchy('backup')
>>> hier.path >>> hier.path
PosixPath('backup') PosixPath('backup')
@ -42,14 +41,10 @@ class Hierarchy:
except TypeError as e: except TypeError as e:
raise e raise e
self._metadata_path = self.path / ".metadata"
@property @property
def path(self): def path(self):
"""Return the base directory of this hierarchy. """Return the base directory of this hierarchy.
Example
-------
>>> hier = Hierarchy('backup') >>> hier = Hierarchy('backup')
>>> hier.path >>> hier.path
PosixPath('backup') PosixPath('backup')
@ -62,8 +57,6 @@ class Hierarchy:
def name(self): def name(self):
"""Return the name of this hierarchy. """Return the name of this hierarchy.
Example
-------
>>> hier = Hierarchy('backup/data/snapshot-one') >>> hier = Hierarchy('backup/data/snapshot-one')
>>> hier.name >>> hier.name
'snapshot-one' 'snapshot-one'
@ -72,6 +65,18 @@ class Hierarchy:
""" """
return self.path.name return self.path.name
@property
def metadata_path(self):
"""Return the path of this hierarchy's metadata file.
>>> hier = Hierarchy('backup')
>>> hier.metadata_path
PosixPath('backup/.metadata')
:rtype: path-like object
"""
return self.path / ".metadata"
# ========== Functions ========== # ========== Functions ==========
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -19,6 +19,7 @@ class Snapshot(Hierarchy):
---------- ----------
* path (inherited from Hierarchy) * path (inherited from Hierarchy)
* name (inherited from Hierarchy) * name (inherited from Hierarchy)
* metadata_path (inherited from Hierarchy)
* boot_dir * boot_dir
* etc_dir * etc_dir
* home_dir * home_dir