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.
5 from catapult_base
.refactor
import annotated_symbol
9 def __init__(self
, file_path
):
10 self
._file
_path
= file_path
12 with
open(self
._file
_path
, 'r') as f
:
13 self
._snippet
= annotated_symbol
.Annotate(f
)
17 return self
._file
_path
21 return self
._snippet
.modified
23 def FindAll(self
, snippet_type
):
24 return self
._snippet
.FindAll(snippet_type
)
26 def FindChildren(self
, snippet_type
):
27 return self
._snippet
.FindChildren(snippet_type
)
30 """Write modifications to the file."""
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
: