Initialize all properties of Snapshot object in __init__

This commit is contained in:
Eric Torres 2019-03-17 09:34:01 -07:00
parent 6daab95f5f
commit f70a4c96a1

View File

@ -1,13 +1,19 @@
""" """
.. author:: Eric Torres .. author:: Eric Torres
.. module:: r/tmp.hierarchy.snapshot .. module:: rbackup.hierarchy.snapshot
:synopsis: Classes for creating the /tmp hierarchy. :synopsis: Classes for creating the /tmp hierarchy.
""" """
import logging
import os.path import os.path
from rbackup.hierarchy.hierarchy import Hierarchy from rbackup.hierarchy.hierarchy import Hierarchy
# ========== Logging Setup ===========
syslog = logging.getLogger(__name__)
# ========== Classes ==========
class Snapshot(Hierarchy): class Snapshot(Hierarchy):
"""Hierarchy for a single snapshot. """Hierarchy for a single snapshot.
Attributes Attributes
@ -24,6 +30,11 @@ class Snapshot(Hierarchy):
"""Default constructor for the Snapshot class.""" """Default constructor for the Snapshot class."""
super().__init__(path) super().__init__(path)
self._boot_dir = os.path.join(self.path, "boot")
self._etc_dir = os.path.join(self.path, "etc")
self._home_dir = os.path.join(self.path, "home")
self._root_home_dir = os.path.join(self.path, "root")
@property @property
def name(self): def name(self):
"""Return the name of this snapshot. """Return the name of this snapshot.
@ -50,7 +61,7 @@ class Snapshot(Hierarchy):
:rtype: str :rtype: str
""" """
return os.path.join(self.path, "boot") return self._boot_dir
@property @property
def etc_dir(self): def etc_dir(self):
@ -64,7 +75,7 @@ class Snapshot(Hierarchy):
:rtype: str :rtype: str
""" """
return os.path.join(self.path, "etc") return self._etc_dir
@property @property
def home_dir(self): def home_dir(self):
@ -78,7 +89,7 @@ class Snapshot(Hierarchy):
:rtype: str :rtype: str
""" """
return os.path.join(self.path, "home") return self._home_dir
@property @property
def root_home_dir(self): def root_home_dir(self):
@ -92,7 +103,7 @@ class Snapshot(Hierarchy):
:rtype: str :rtype: str
""" """
return os.path.join(self.path, "root") return self._root_home_dir
# ========== Functions ========== # ========== Functions ==========