-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinventory.py
35 lines (31 loc) · 1.18 KB
/
inventory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import dateutil.parser
class File():
def __init__(self, json):
self.size = json["Size"]
self.date = json["CreationDate"]
self.desc = json["ArchiveDescription"]
self.aid = json["ArchiveId"]
self.sha256 = json["SHA256TreeHash"]
self.deleted = False
self.isNew = False
def __str__(self):
return "File: " + self.desc + " - Size: " + str(self.size) + "bytes - Created: " + self.date
def __repr__(self):
return "File: " + self.desc + " - Size: " + str(self.size) + "bytes - Created: " + self.date
#def __cmd__(self,obj)
class Inventory():
def __init__(self, json):
self.arn = json["VaultARN"]
self.date = dateutil.parser.parse(json["InventoryDate"])
self.files = []
for f in json["ArchiveList"]:
self.files.append(File(f))
def __str__(self):
s = "Inventory Date: " + self.date + "\n"
s += str(self.files)
return s
def getFile(self, size, date, description):
ffile = None
for f in self.files:
if (str(f.size) == size and f.date == date and f.desc == description): ffile = f
return ffile