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

Side by Side Diff: recipes/recipe_util.py

Issue 1494793002: Rename recipes/ to fetch_configs/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Renamed recipes to configs Created 5 years 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 | Annotate | Revision Log
« no previous file with comments | « recipes/pdfium.py ('k') | recipes/skia.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2013 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 """This module holds utilities which make writing recipes easier."""
6
7 import json
8
9
10 class Recipe(object):
11 """Base class for all recipes.
12
13 Provides methods that are expected to be overridden by child classes. Also
14 provides an command-line parsing method that converts the unified command-line
15 interface used in depot_tools to the unified python interface defined here."""
16
17 @staticmethod
18 def fetch_spec(_props):
19 """Returns instructions to check out the project, conditioned on |props|."""
20 raise NotImplementedError
21
22 @staticmethod
23 def expected_root(_props):
24 """Returns the directory into which the checkout will be performed."""
25 raise NotImplementedError
26
27 def handle_args(self, argv):
28 """Passes the command-line arguments through to the appropriate method."""
29 methods = {'fetch': self.fetch_spec,
30 'root': self.expected_root}
31 if len(argv) <= 1 or argv[1] not in methods:
32 print 'Must specify a a fetch/root action'
33 return 1
34
35 def looks_like_arg(arg):
36 return arg.startswith('--') and arg.count('=') == 1
37
38 bad_parms = [x for x in argv[2:] if not looks_like_arg(x)]
39 if bad_parms:
40 print 'Got bad arguments %s' % bad_parms
41 return 1
42
43 method = methods[argv[1]]
44 props = dict(x.split('=', 1) for x in (y.lstrip('-') for y in argv[2:]))
45
46 self.output(method(props))
47
48 @staticmethod
49 def output(data):
50 print(json.dumps(data))
OLDNEW
« no previous file with comments | « recipes/pdfium.py ('k') | recipes/skia.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698