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

Unified Diff: third_party/mozrunner/mozrunner/utils.py

Issue 108313011: Adding mozilla libraries required by Firefox interop test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: Created 7 years 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 | « third_party/mozrunner/mozrunner/runner.py ('k') | third_party/mozrunner/setup.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/mozrunner/mozrunner/utils.py
===================================================================
--- third_party/mozrunner/mozrunner/utils.py (revision 0)
+++ third_party/mozrunner/mozrunner/utils.py (revision 0)
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
+"""
+utility functions for mozrunner
+"""
+
+__all__ = ['findInPath', 'get_metadata_from_egg']
+
+import mozinfo
+import os
+import sys
+
+
+### python package method metadata by introspection
+try:
+ import pkg_resources
+ def get_metadata_from_egg(module):
+ ret = {}
+ try:
+ dist = pkg_resources.get_distribution(module)
+ except pkg_resources.DistributionNotFound:
+ return {}
+ if dist.has_metadata("PKG-INFO"):
+ key = None
+ for line in dist.get_metadata("PKG-INFO").splitlines():
+ # see http://www.python.org/dev/peps/pep-0314/
+ if key == 'Description':
+ # descriptions can be long
+ if not line or line[0].isspace():
+ value += '\n' + line
+ continue
+ else:
+ key = key.strip()
+ value = value.strip()
+ ret[key] = value
+
+ key, value = line.split(':', 1)
+ key = key.strip()
+ value = value.strip()
+ ret[key] = value
+ if dist.has_metadata("requires.txt"):
+ ret["Dependencies"] = "\n" + dist.get_metadata("requires.txt")
+ return ret
+except ImportError:
+ # package resources not avaialable
+ def get_metadata_from_egg(module):
+ return {}
+
+
+def findInPath(fileName, path=os.environ['PATH']):
+ """python equivalent of which; should really be in the stdlib"""
+ dirs = path.split(os.pathsep)
+ for dir in dirs:
+ if os.path.isfile(os.path.join(dir, fileName)):
+ return os.path.join(dir, fileName)
+ if mozinfo.isWin:
+ if os.path.isfile(os.path.join(dir, fileName + ".exe")):
+ return os.path.join(dir, fileName + ".exe")
+
+if __name__ == '__main__':
+ for i in sys.argv[1:]:
+ print findInPath(i)
Property changes on: third_party/mozrunner/mozrunner/utils.py
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « third_party/mozrunner/mozrunner/runner.py ('k') | third_party/mozrunner/setup.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698