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

Side by Side Diff: recipe_modules/shutil/api.py

Issue 2146523003: shutil recipe_module: port chromium_utils rmtree implementation. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/recipes-py@master
Patch Set: nit Created 4 years, 5 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
« no previous file with comments | « no previous file | recipe_modules/shutil/example.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The LUCI Authors. All rights reserved. 1 # Copyright 2016 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 from recipe_engine import recipe_api 5 from recipe_engine import recipe_api
6 6
7 class ShutilApi(recipe_api.RecipeApi): 7 class ShutilApi(recipe_api.RecipeApi):
8 def rmtree(self, path, **kwargs): 8 def rmtree(self, path, **kwargs):
9 name = kwargs.pop('name', 'rmtree %s' % path) 9 name = kwargs.pop('name', 'rmtree %s' % path)
10 if kwargs.pop('flag_smart_rmtree', False):
11 # TODO(tandrii): remove this flag and makes this the only implementation.
12 self.m.python(
13 name,
14 self.resource('rmtree.py'),
15 args=[path],
16 **kwargs)
17 return
10 self.m.python.inline( 18 self.m.python.inline(
11 name, 19 name,
12 """ 20 """
13 import shutil, sys 21 import shutil, sys
14 shutil.rmtree(sys.argv[1]) 22 shutil.rmtree(sys.argv[1])
15 """, 23 """,
16 args=[path], 24 args=[path],
17 **kwargs) 25 **kwargs)
18 26
19 def copy(self, name, source, dest, step_test_data=None, **kwargs): 27 def copy(self, name, source, dest, step_test_data=None, **kwargs):
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if not os.path.isdir(path): 142 if not os.path.isdir(path):
135 if os.path.exists(path): 143 if os.path.exists(path):
136 print "%s exists but is not a dir" % path 144 print "%s exists but is not a dir" % path
137 sys.exit(1) 145 sys.exit(1)
138 os.makedirs(path, mode) 146 os.makedirs(path, mode)
139 """, 147 """,
140 args=[path, str(mode)], 148 args=[path, str(mode)],
141 **kwargs 149 **kwargs
142 ) 150 )
143 self.m.path.mock_add_paths(path) 151 self.m.path.mock_add_paths(path)
OLDNEW
« no previous file with comments | « no previous file | recipe_modules/shutil/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698