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

Unified Diff: scripts/common/chromium_utils.py

Issue 12351003: Backporting ilevy@'s ParsePythonCfg so it can be used in Annotator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Remove __builtins__ from returned dict. Created 7 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/common/chromium_utils.py
diff --git a/scripts/common/chromium_utils.py b/scripts/common/chromium_utils.py
index 7ecc5392065abe0929d525fb4b78bff1a2f63bed..9320eb87bf3e3946f7531c3e93fe4716f8bd3323 100644
--- a/scripts/common/chromium_utils.py
+++ b/scripts/common/chromium_utils.py
@@ -991,6 +991,25 @@ def ListMasters(cue='master.cfg', include_public=True, include_internal=True):
return [os.path.abspath(os.path.dirname(f)) for f in filenames]
+def ParsePythonCfg(cfg_filepath):
+ """Retrieves data from a python config file."""
+ if not os.path.exists(cfg_filepath):
+ return None
+ base_path = os.path.dirname(os.path.abspath(cfg_filepath))
+ old_sys_path = sys.path
+ sys.path = sys.path + [base_path]
+ old_path = os.getcwd()
+ try:
+ os.chdir(base_path)
+ local_vars = {}
+ execfile(os.path.join(cfg_filepath), local_vars)
+ del local_vars['__builtins__']
+ return local_vars
+ finally:
+ os.chdir(old_path)
+ sys.path = old_sys_path
+
+
def RunSlavesCfg(slaves_cfg):
"""Runs slaves.cfg in a consistent way."""
if not os.path.exists(slaves_cfg):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698