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

Side by Side Diff: gce/uploader_helper.py

Issue 1351373003: [chrome-devtools-frontend] Use full Chromium checkout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chrome-devtools-frontend
Patch Set: Created 5 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gce/uploader_iteration.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import optparse 6 import optparse
7 import re 7 import re
8 import sys 8 import sys
9 9
10 class VarImpl(object): 10 class VarImpl(object):
11 """Implement the Var function used within the DEPS file.""" 11 """Implement the Var function used within the DEPS file."""
12 12
13 def __init__(self, local_scope): 13 def __init__(self, local_scope):
14 self._local_scope = local_scope 14 self._local_scope = local_scope
15 15
16 def Lookup(self, var_name): 16 def Lookup(self, var_name):
17 """Implements the Var syntax.""" 17 """Implements the Var syntax."""
18 if var_name in self._local_scope.get('vars', {}): 18 if var_name in self._local_scope.get('vars', {}):
19 return self._local_scope['vars'][var_name] 19 return self._local_scope['vars'][var_name]
20 raise Exception('Var is not defined: %s' % var_name) 20 raise Exception('Var is not defined: %s' % var_name)
21 21
22 def FindProjectRevision(project_name): 22 def FindProjectRevision(project_name):
23 # Parse Chromium DEPS file to find out the revision of the project in use. 23 # Parse Chromium DEPS file to find out the revision of the project in use.
24 deps_content = sys.stdin.read() 24 deps_content = sys.stdin.read()
25 local_scope = {} 25 local_scope = {}
26 var = VarImpl(local_scope) 26 var = VarImpl(local_scope)
27 global_scope = { 'Var': var.Lookup, 'deps': {} } 27 global_scope = { 'Var': var.Lookup, 'deps': {} }
28 exec(deps_content, global_scope, local_scope) 28 exec(deps_content, global_scope, local_scope)
29 project_path = local_scope['deps'][project_name] 29 project_path = local_scope['deps'][project_name]
30 match = re.search('r[^@]*@(\d+)', project_path) 30 match = re.search('r[^@]*@([0-9a-f]+)', project_path)
31 if match: 31 if match:
32 return match.group(1) 32 return match.group(1)
33 return project_path 33 return project_path
34 34
35 def main(): 35 def main():
36 parser = optparse.OptionParser(usage='%prog [options]') 36 parser = optparse.OptionParser(usage='%prog [options]')
37 parser.add_option( 37 parser.add_option(
38 '', '--find_project_revision', 38 '', '--find_project_revision',
39 default=False, 39 default=False,
40 help=('FindProjectRevision')) 40 help=('FindProjectRevision'))
41 (options, args) = parser.parse_args() 41 (options, args) = parser.parse_args()
42 if args: 42 if args:
43 parser.print_help() 43 parser.print_help()
44 return 1 44 return 1
45 if options.find_project_revision: 45 if options.find_project_revision:
46 print FindProjectRevision(options.find_project_revision) 46 print FindProjectRevision(options.find_project_revision)
47 47
48 return 0 48 return 0
49 49
50 if __name__ == '__main__': 50 if __name__ == '__main__':
51 sys.exit(main()) 51 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | gce/uploader_iteration.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698