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

Unified Diff: tools/telemetry/catapult_base/refactor/module.py

Issue 1620023002: Revert of Remove catapult_base from telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@perf_cb_move
Patch Set: Created 4 years, 11 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/telemetry/catapult_base/refactor/module.py
diff --git a/tools/telemetry/catapult_base/refactor/module.py b/tools/telemetry/catapult_base/refactor/module.py
new file mode 100644
index 0000000000000000000000000000000000000000..d8b6fb86ae51652b56580efca0353a3cbe9f6605
--- /dev/null
+++ b/tools/telemetry/catapult_base/refactor/module.py
@@ -0,0 +1,38 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from catapult_base.refactor import annotated_symbol
+
+
+class Module(object):
+ def __init__(self, file_path):
+ self._file_path = file_path
+
+ with open(self._file_path, 'r') as f:
+ self._snippet = annotated_symbol.Annotate(f)
+
+ @property
+ def file_path(self):
+ return self._file_path
+
+ @property
+ def modified(self):
+ return self._snippet.modified
+
+ def FindAll(self, snippet_type):
+ return self._snippet.FindAll(snippet_type)
+
+ def FindChildren(self, snippet_type):
+ return self._snippet.FindChildren(snippet_type)
+
+ def Write(self):
+ """Write modifications to the file."""
+ if not self.modified:
+ return
+
+ # Stringify before opening the file for writing.
+ # If we fail, we won't truncate the file.
+ string = str(self._snippet)
+ with open(self._file_path, 'w') as f:
+ f.write(string)

Powered by Google App Engine
This is Rietveld 408576698