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

Unified Diff: gclient_utils.py

Issue 1602020: Adding weekly tool to help with weekly snippets (Closed)
Patch Set: . Created 10 years, 8 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 | « no previous file | weekly » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_utils.py
diff --git a/gclient_utils.py b/gclient_utils.py
index e08bf8ebc251915079443e2c08ebb36991c281ae..a052d42cab7caf8d70259793b8bf8fb260efa4c1 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -323,3 +323,33 @@ def PathDifference(root, subpath):
# provided.
root = os.path.join(root, '')
return subpath[len(root):]
+
+
+def FindFileUpwards(filename, path=None):
+ """Search upwards from the a directory (default: current) to find a file."""
+ if not path:
+ path = os.getcwd()
+ path = os.path.realpath(path)
+ while True:
+ file_path = os.path.join(path, filename)
+ if os.path.isfile(file_path):
+ return file_path
+ (new_path, _) = os.path.split(path)
+ if new_path == path:
+ return None
+ path = new_path
+
+
+def GetGClientRootAndEntries(path=None):
+ """Returns the gclient root and the dict of entries."""
+ config_file = '.gclient_entries'
+ config_path = FindFileUpwards(config_file, path)
+
+ if not config_path:
+ print "Can't find", config_file
+ return None
+
+ env = {}
+ execfile(config_path, env)
+ config_dir = os.path.dirname(config_path)
+ return config_dir, env['entries']
« no previous file with comments | « no previous file | weekly » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698