forked from Customrombay/database
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_list_file.dart
More file actions
27 lines (26 loc) · 873 Bytes
/
build_list_file.dart
File metadata and controls
27 lines (26 loc) · 873 Bytes
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
import 'dart:io';
import 'package:yaml/yaml.dart';
import 'package:yaml_writer/yaml_writer.dart';
void main() {
List mainList = [];
File mainFile = File("database/main.yaml");
if (mainFile.existsSync()) {
}
else {
mainFile.createSync();
}
for (FileSystemEntity entity in Directory("database/phone_data").listSync()) {
if (entity is File) {
String content = entity.readAsStringSync();
YamlMap ydoc = loadYaml(content);
mainList += [{
"device-name": ydoc["device-name"],
"device-vendor": ydoc["device-vendor"],
"device-model-name": ydoc["device-model-name"]
}];
stdout.write("${ydoc["device-vendor"].toString().toLowerCase()}-${ydoc["device-name"]}\n");
}
}
mainList.sort((a, b) => a["device-name"].compareTo(b["device-name"]));
mainFile.writeAsStringSync(YAMLWriter().write(mainList));
}