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

Unified Diff: tools/retrieve_from_googlesource.py

Issue 317823003: Fix submit_try (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/buildbot_globals.py ('k') | tools/submit_try » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/retrieve_from_googlesource.py
diff --git a/tools/retrieve_from_googlesource.py b/tools/retrieve_from_googlesource.py
new file mode 100644
index 0000000000000000000000000000000000000000..2f78ce0392834928806b0846db46245eb558a5d9
--- /dev/null
+++ b/tools/retrieve_from_googlesource.py
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+
+# Copyright (c) 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Retrieve the given file from googlesource.com."""
+
+
+from contextlib import closing
+
+import base64
+import sys
+import urllib2
+
+
+def get(repo_url, filepath):
+ """Retrieve the contents of the given file from the given googlesource repo.
+
+ Args:
+ repo_url: string; URL of the repository from which to retrieve the file.
+ filepath: string; path of the file within the repository.
+
+ Return:
+ string; the contents of the given file.
+ """
+ base64_url = '/'.join((repo_url, '+', 'master', filepath)) + '?format=TEXT'
+ with closing(urllib2.urlopen(base64_url)) as f:
+ return base64.b64decode(f.read())
+
+
+if __name__ == '__main__':
+ if len(sys.argv) != 3:
+ print >> sys.stderr, 'Usage: %s <repo_url> <filepath>' % sys.argv[0]
+ sys.exit(1)
+ sys.stdout.write(get(sys.argv[1], sys.argv[2]))
« no previous file with comments | « tools/buildbot_globals.py ('k') | tools/submit_try » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698