| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from recipe_engine import recipe_api | 5 from recipe_engine import recipe_api |
| 6 | 6 |
| 7 | 7 |
| 8 class FileApi(recipe_api.RecipeApi): | 8 class FileApi(recipe_api.RecipeApi): |
| 9 """FileApi contains helper functions for reading and writing files.""" | 9 """FileApi contains helper functions for reading and writing files.""" |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 """ | 33 """ |
| 34 import shutil | 34 import shutil |
| 35 import sys | 35 import sys |
| 36 shutil.copytree(sys.argv[1], sys.argv[2], symlinks=bool(sys.argv[3])) | 36 shutil.copytree(sys.argv[1], sys.argv[2], symlinks=bool(sys.argv[3])) |
| 37 """, | 37 """, |
| 38 args=[source, dest, int(symlinks)], | 38 args=[source, dest, int(symlinks)], |
| 39 add_python_log=False, | 39 add_python_log=False, |
| 40 **kwargs | 40 **kwargs |
| 41 ) | 41 ) |
| 42 | 42 |
| 43 def move(self, name, source, dest, **kwargs): |
| 44 """Run shutil.move in a step.""" |
| 45 return self.m.python.inline( |
| 46 name, |
| 47 """ |
| 48 import shutil |
| 49 import sys |
| 50 shutil.move(sys.argv[1], sys.argv[2]) |
| 51 """, |
| 52 args=[source, dest], |
| 53 add_python_log=False, |
| 54 **kwargs |
| 55 ) |
| 56 |
| 43 def read(self, name, path, test_data=None, **kwargs): | 57 def read(self, name, path, test_data=None, **kwargs): |
| 44 """Read a file and return its contents.""" | 58 """Read a file and return its contents.""" |
| 45 step_test_data = None | 59 step_test_data = None |
| 46 if test_data is not None: | 60 if test_data is not None: |
| 47 step_test_data = lambda: self.m.raw_io.test_api.output(test_data) | 61 step_test_data = lambda: self.m.raw_io.test_api.output(test_data) |
| 48 return self.copy(name, path, self.m.raw_io.output(), | 62 return self.copy(name, path, self.m.raw_io.output(), |
| 49 step_test_data=step_test_data, **kwargs).raw_io.output | 63 step_test_data=step_test_data, **kwargs).raw_io.output |
| 50 | 64 |
| 51 def write(self, name, path, data, **kwargs): | 65 def write(self, name, path, data, **kwargs): |
| 52 """Write the given data to a file.""" | 66 """Write the given data to a file.""" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 self.m.python.inline( | 210 self.m.python.inline( |
| 197 'rmwildcard %s in %s' % (pattern, path), | 211 'rmwildcard %s in %s' % (pattern, path), |
| 198 """ | 212 """ |
| 199 import sys | 213 import sys |
| 200 from common import chromium_utils # Error? See https://crbug.com/584783. | 214 from common import chromium_utils # Error? See https://crbug.com/584783. |
| 201 | 215 |
| 202 chromium_utils.RemoveFilesWildcards(sys.argv[1], root=sys.argv[2]) | 216 chromium_utils.RemoveFilesWildcards(sys.argv[1], root=sys.argv[2]) |
| 203 """, | 217 """, |
| 204 args=[pattern,path], | 218 args=[pattern,path], |
| 205 **kwargs) | 219 **kwargs) |
| OLD | NEW |