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

Side by Side Diff: tools/telemetry/catapult_base/refactor/module.py

Issue 1599413006: 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from catapult_base.refactor import annotated_symbol
6
7
8 class Module(object):
9 def __init__(self, file_path):
10 self._file_path = file_path
11
12 with open(self._file_path, 'r') as f:
13 self._snippet = annotated_symbol.Annotate(f)
14
15 @property
16 def file_path(self):
17 return self._file_path
18
19 @property
20 def modified(self):
21 return self._snippet.modified
22
23 def FindAll(self, snippet_type):
24 return self._snippet.FindAll(snippet_type)
25
26 def FindChildren(self, snippet_type):
27 return self._snippet.FindChildren(snippet_type)
28
29 def Write(self):
30 """Write modifications to the file."""
31 if not self.modified:
32 return
33
34 # Stringify before opening the file for writing.
35 # If we fail, we won't truncate the file.
36 string = str(self._snippet)
37 with open(self._file_path, 'w') as f:
38 f.write(string)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698