From bf7416a42f644ad880d4150bc624fab7c6db3a98 Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Fri, 29 Mar 2019 15:27:34 -0700 Subject: [PATCH] Add metadata_path attribute --- rbackup/hierarchy/hierarchy.py | 21 +++++++++++++-------- rbackup/hierarchy/snapshot.py | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/rbackup/hierarchy/hierarchy.py b/rbackup/hierarchy/hierarchy.py index 3d3b294..7502362 100644 --- a/rbackup/hierarchy/hierarchy.py +++ b/rbackup/hierarchy/hierarchy.py @@ -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__": diff --git a/rbackup/hierarchy/snapshot.py b/rbackup/hierarchy/snapshot.py index c3e3630..7885336 100644 --- a/rbackup/hierarchy/snapshot.py +++ b/rbackup/hierarchy/snapshot.py @@ -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