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

Side by Side Diff: tools/retrieve_from_googlesource.py

Issue 317823003: Fix submit_try (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7
8 """Retrieve the given file from googlesource.com."""
9
10
11 from contextlib import closing
12
13 import base64
14 import sys
15 import urllib2
16
17
18 def retrieve_from_googlesource(repo_url, filepath):
epoger 2014/06/05 14:02:16 maybe rename to be something different/shorter, so
borenet 2014/06/05 14:09:49 Done.
19 """Retrieve the contents of the given file from the given googlesource repo.
20
21 Args:
22 repo_url: string; URL of the repository from which to retrieve the file.
23 filepath: string; path of the file within the repository.
24
25 Return:
26 string; the contents of the given file.
27 """
28 base64_url = '/'.join((repo_url, '+', 'master', filepath)) + '?format=TEXT'
29 with closing(urllib2.urlopen(base64_url)) as f:
30 return base64.b64decode(f.read())
31
32
33 if __name__ == '__main__':
34 if len(sys.argv) != 3:
35 print >> sys.stderr, 'Usage: %s <repo_url> <filepath>' % sys.argv[0]
36 sys.exit(1)
37 sys.stdout.write(retrieve_from_googlesource(sys.argv[1], sys.argv[2]))
OLDNEW
« no previous file with comments | « tools/buildbot_globals.py ('k') | tools/submit_try » ('j') | tools/submit_try » ('J')

Powered by Google App Engine
This is Rietveld 408576698