2 from datetime import datetime
5 """Class that represents a backup
9 path -- Backup directory path
10 date -- Date when backup was created
11 _comment -- Any comment about backup
12 size -- Backup file size
13 files_number = total number of backup files
14 _time = time object was created in seconds since epoch
18 def __init__(self, name, path, size, comment=""):
19 """Initialize object attributes."""
22 self._time = time.time()
23 self.date = datetime.fromtimestamp(self._time).replace(microsecond=0)
26 self._comment = comment
27 self.fromDevice = False
30 """Return object path."""
34 """Return object name."""
38 """Return object creation date."""
42 """Return object _comment attribute."""
46 """Return object file size."""
50 """ Returns the object creation time in seconds since epoch. """
53 def getFilesNumber(self):
54 """ Return number of files this backup holds. """
55 return self.files_number
57 def setComment(self, new_comment):
58 """Set object _comment attribute to the given string"""
59 self._comment = new_comment
61 def setName(self, new_name):
62 """Set object name to a new name"""
65 def setDate(self, newDate):
68 def setFilesNumber(self, number_of_files):
69 """ Set number of files this backup holds to number_of_files ."""
70 self.files_number = number_of_files
72 def setAtDevice(self, bool=False):
73 self.fromDevice = bool