From aa7271c15915a3c818f658b2756a8d1cb47ed3df Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Tue, 26 Nov 2019 14:06:01 +0100 Subject: [PATCH] containers: Missing properties + string represenation --- restic_volume_backup/containers.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/restic_volume_backup/containers.py b/restic_volume_backup/containers.py index b792ad8..16c3e65 100644 --- a/restic_volume_backup/containers.py +++ b/restic_volume_backup/containers.py @@ -13,7 +13,6 @@ class Container: def __init__(self, data: dict): self._data = data self.id = data['Id'] - self.name = data['Name'].replace('/', '') self._state = data.get('State') self._config = data.get('Config') @@ -87,6 +86,11 @@ class Container: """Is the container running?""" return self._state.get('Running', False) + @property + def name(self) -> str: + """Container name""" + return self._data['Name'].replace('/', '') + @property def service_name(self) -> str: """Name of the container/service""" @@ -169,6 +173,12 @@ class Container: return self.id == other.id + def __repr__(self): + return str(self) + + def __str__(self): + return "".format(self.name) + class Mount: """Represents a volume mount (volume or bind)"""