forked from Customrombay/database
-
Notifications
You must be signed in to change notification settings - Fork 0
/
syncWithCorvusOS.dart
113 lines (106 loc) · 3.72 KB
/
syncWithCorvusOS.dart
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import 'dart:io';
import 'package:yaml/yaml.dart';
import 'package:yaml_writer/yaml_writer.dart';
import 'tools/codename_correction.dart';
import 'tools/android_version_from_crdroid_version.dart';
void main() async {
File devicesFile = File("filesFromCorvusOS/devices.json");
String fileContent = devicesFile.readAsStringSync();
print("OK");
var yamlWriter = YAMLWriter();
int numberOfCovered = 0;
int numberOfNotCovered = 0;
List<String> listOfNotCovered = [];
List<String> listOfCovered = [];
YamlMap ydoc = loadYaml(fileContent);
print(ydoc.runtimeType);
print(ydoc.entries.length);
for (var entry in ydoc.entries) {
print(entry.key);
String readVendor = entry.key;
String vendor = "";
if (readVendor == "Poco") {
vendor = "Xiaomi";
}
else if (readVendor == "Redmi") {
vendor = "Xiaomi";
}
else {
vendor = readVendor;
}
YamlMap devices = entry.value;
for (var readCodename in devices.keys) {
if (readCodename == "tulip") {
continue;
}
String codename = codenameCorrection(readCodename, vendor);
print(codename);
print(devices[readCodename]["device"]);
String phoneWebsite = devices[readCodename]["download"] ?? "";
String state = "Official";
File thisFile = File("database/phone_data/${vendor.toString().toLowerCase()}-${codename.toString()}.yaml");
if (await thisFile.exists()) {
numberOfCovered += 1;
if (listOfCovered.contains("${vendor.toString().toLowerCase()}-${codename.toString()}")) {
throw Exception();
}
listOfCovered += ["${vendor.toString().toLowerCase()}-${codename.toString()}"];
String thisFileContent = await thisFile.readAsString();
var thisFileyaml = loadYaml(thisFileContent);
// // stdout.write(yamlWriter.write(thisFileyaml));
List newList = [];
bool alreadySupported = false;
for (var thisRom in thisFileyaml["roms"]) {
String thisRomName = thisRom["rom-name"];
if (thisRomName == "CorvusOS") {
alreadySupported = true;
newList += [
{
"rom-name": "CorvusOS",
"rom-support": true,
"rom-state": state,
"android-version": thisRom["android-version"],
"rom-webpage": "https://www.corvusrom.com/",
"phone-webpage": phoneWebsite
}
];
}
else {
newList += [thisRom];
}
}
if (!alreadySupported) {
newList += <dynamic>[
{
"rom-name": "CorvusOS",
"rom-support": true,
"rom-state": state,
"android-version": null,
"rom-webpage": "https://www.corvusrom.com/",
"phone-webpage": phoneWebsite
}
];
}
Map newMap = {
"device-name" : thisFileyaml["device-name"],
"device-vendor": thisFileyaml["device-vendor"],
"device-model-name": thisFileyaml["device-model-name"],
"device-description": thisFileyaml["device-description"],
"roms": newList,
"recoveries": thisFileyaml["recoveries"]
};
// File newFile = File("newfiles/${vendor.toString().toLowerCase()}-$codename.yaml");
await thisFile.writeAsString(yamlWriter.write(newMap));
}
else {
numberOfNotCovered += 1;
listOfNotCovered += ["${vendor.toString().toLowerCase()}-${codename.toString()}"];
}
}
}
stdout.write("Covered: $numberOfCovered\n");
stdout.write("Not covered: $numberOfNotCovered\n");
for (var deviceNotCovered in listOfNotCovered) {
stdout.write("$deviceNotCovered\n");
}
}