-
Notifications
You must be signed in to change notification settings - Fork 2
/
helpers.py
37 lines (32 loc) · 960 Bytes
/
helpers.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
36
37
"""
Database helper functions
"""
from humanize import naturalsize
from .database import get_all_latest_updates, get_devices
def export_latest():
"""
Export latest updates from the database to YAML file
:return:
"""
latest_updates = get_all_latest_updates()
return sorted(
[
{
"android": item.android,
"branch": item.branch,
"codename": item.codename,
"date": item.date,
"name": item.fullname,
"md5": item.md5,
"method": item.method,
"link": item.link,
"size": naturalsize(item.size),
"version": item.version,
}
for item in latest_updates
],
key=lambda x: x["codename"],
)
def export_devices():
devices = get_devices()
return {device.codename: [device.name, device.miui_name] for device in devices}