Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: test/perf/update_json.dart

Issue 55143003: webui fixes for 0.8.9 (Closed) Base URL: git@github.com:dart-lang/web-ui.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env dart 1 #!/usr/bin/env dart
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 /** 6 /**
7 * A simple script that updates a target json file with the new values from 7 * A simple script that updates a target json file with the new values from
8 * another json file. 8 * another json file.
9 */ 9 */
10 library test.perf.update_json; 10 library test.perf.update_json;
11 11
12 import 'dart:async'; 12 import 'dart:async';
13 import 'dart:io'; 13 import 'dart:io';
14 import 'dart:json' as json; 14 import 'dart:convert';
15 import 'dart:math' as math; 15 import 'dart:math' as math;
16 16
17 main() { 17 main() {
18 var args = new Options().arguments;
19 if (args.length < 2) { 18 if (args.length < 2) {
20 print('update_json.dart: A simple script that updates a target json file ' 19 print('update_json.dart: A simple script that updates a target json file '
21 'with the new values from another json file. '); 20 'with the new values from another json file. ');
22 print('usage: update.dart from.json to.json'); 21 print('usage: update.dart from.json to.json');
23 exit(1); 22 exit(1);
24 } 23 }
25 24
26 var path1 = args[0]; 25 var path1 = args[0];
27 var path2 = args[1]; 26 var path2 = args[1];
28 var file1 = new File(path1).readAsStringSync(); 27 var file1 = new File(path1).readAsStringSync();
29 var file2 = new File(path2).readAsStringSync(); 28 var file2 = new File(path2).readAsStringSync();
30 29
31 var results = []; 30 var results = [];
32 var map1 = json.parse(file1); 31 var map1 = JSON.decode(file1);
33 var map2 = json.parse(file2); 32 var map2 = JSON.decode(file2);
34 33
35 for (var key in map1.keys) { 34 for (var key in map1.keys) {
36 if (map1[key] != null) { 35 if (map1[key] != null) {
37 map2[key] = map1[key]; 36 map2[key] = map1[key];
38 } 37 }
39 } 38 }
40 39
41 print('updating $path2...'); 40 print('updating $path2...');
42 _writeFile(path2, json.stringify(map2)); 41 _writeFile(path2, JSON.encode(map2));
43 } 42 }
44 43
45 Future _writeFile(String path, String text) { 44 Future _writeFile(String path, String text) {
46 return new File(path).open(FileMode.WRITE) 45 return new File(path).open(FileMode.WRITE)
47 .then((file) => file.writeString(text)) 46 .then((file) => file.writeString(text))
48 .then((file) => file.close()); 47 .then((file) => file.close());
49 } 48 }
OLDNEW
« pubspec.yaml ('K') | « test/perf/perf.dart ('k') | test/run_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698