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

Unified Diff: tools/gardening/lib/src/util.dart

Issue 2753513005: Add status_summary and current_summary to tools/gardening (Closed)
Patch Set: dartfmt Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
Index: tools/gardening/lib/src/util.dart
diff --git a/tools/gardening/lib/src/util.dart b/tools/gardening/lib/src/util.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b27614e8a96e9b9b2e4cf526deebb32e02b2f35d
--- /dev/null
+++ b/tools/gardening/lib/src/util.dart
@@ -0,0 +1,30 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// Split [text] using [infixes] as infix markers.
+List<String> split(String text, List<String> infixes) {
+ List<String> result = <String>[];
+ int start = 0;
+ for (String infix in infixes) {
+ int index = text.indexOf(infix, start);
+ if (index == -1)
+ throw "'$infix' not found in '$text' from offset ${start}.";
+ result.add(text.substring(start, index));
+ start = index + infix.length;
+ }
+ result.add(text.substring(start));
+ return result;
+}
+
+/// Pad [text] with spaces to the right to fit [length].
+String padRight(String text, int length) {
+ if (text.length < length) return '${text}${' ' * (length - text.length)}';
+ return text;
+}
+
+const bool LOG = const bool.fromEnvironment('LOG', defaultValue: false);
+
+void log(String text) {
+ if (LOG) print(text);
+}

Powered by Google App Engine
This is Rietveld 408576698