# HG changeset patch # User k0s # Date 1266865147 18000 # Node ID 03fc1f76db91fd98a8380b0f051e905d9bf0e76b # Parent 9e2d6f9974a2848e4673210db73a4ba78c5554e5 adding dotpath python helper diff -r 9e2d6f9974a2 -r 03fc1f76db91 python/dotpath.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/dotpath.py Mon Feb 22 13:59:07 2010 -0500 @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +import sys + +def filename(dotpath): + path = dotpath.split('.') + while path: + try: + module = __import__('.'.join(path)) + return module.__file__.rstrip('c') + except ImportError: + path.pop() + +def main(args=sys.argv[1:]): + for arg in args: + try: + _filename = filename(arg) + except Exception, e: + print e + continue + print _filename + +if __name__ == '__main__': + main()