-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
38 lines (32 loc) · 1.15 KB
/
Copy pathmodels.py
File metadata and controls
38 lines (32 loc) · 1.15 KB
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
36
37
38
import datetime
import json
def get_formatted_date(timestamp):
date_time = datetime.datetime.fromtimestamp(timestamp)
return date_time.strftime('%Y-%m-%dT%H:%M:%SZ')
class Build:
def __init__(self, id, name, tag_name, timestamp, size, md5_hash, sha256_hash, download_url, gitlab_url):
self.id = id
self.name = name
self.tag_name = tag_name
self.timestamp = int(timestamp * 1000)
self.datetime = get_formatted_date(timestamp)
self.size = size
self.md5_hash = md5_hash
self.sha256_hash = sha256_hash
self.download_url = download_url
self.gitlab_url = gitlab_url
def __repr__(self):
return json.dumps({"name": self.name, "timestamp": self.timestamp})
def serialize(self):
return {
"id": self.id,
"name": self.name,
"tag_name": self.tag_name,
"timestamp": self.timestamp,
"datetime": self.datetime,
"size": self.size,
"md5": self.md5_hash,
"sha256": self.sha256_hash,
"download_url": self.download_url,
"gitlab_url": self.gitlab_url,
}