Add metadata_path attribute
This commit is contained in:
parent
da1accf609
commit
bf7416a42f
@ -23,13 +23,12 @@ class Hierarchy:
|
||||
----------
|
||||
* path
|
||||
* name
|
||||
* metadata_path
|
||||
"""
|
||||
|
||||
def __init__(self, dest):
|
||||
"""Default constructor for the Hierarchy class.
|
||||
|
||||
Example
|
||||
-------
|
||||
>>> hier = Hierarchy('backup')
|
||||
>>> hier.path
|
||||
PosixPath('backup')
|
||||
@ -42,14 +41,10 @@ class Hierarchy:
|
||||
except TypeError as e:
|
||||
raise e
|
||||
|
||||
self._metadata_path = self.path / ".metadata"
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
"""Return the base directory of this hierarchy.
|
||||
|
||||
Example
|
||||
-------
|
||||
>>> hier = Hierarchy('backup')
|
||||
>>> hier.path
|
||||
PosixPath('backup')
|
||||
@ -62,8 +57,6 @@ class Hierarchy:
|
||||
def name(self):
|
||||
"""Return the name of this hierarchy.
|
||||
|
||||
Example
|
||||
-------
|
||||
>>> hier = Hierarchy('backup/data/snapshot-one')
|
||||
>>> hier.name
|
||||
'snapshot-one'
|
||||
@ -72,6 +65,18 @@ class Hierarchy:
|
||||
"""
|
||||
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 ==========
|
||||
if __name__ == "__main__":
|
||||
|
@ -19,6 +19,7 @@ class Snapshot(Hierarchy):
|
||||
----------
|
||||
* path (inherited from Hierarchy)
|
||||
* name (inherited from Hierarchy)
|
||||
* metadata_path (inherited from Hierarchy)
|
||||
* boot_dir
|
||||
* etc_dir
|
||||
* home_dir
|
||||
|
Loading…
x
Reference in New Issue
Block a user