# HG changeset patch # User Jeff Hammel # Date 1379471066 25200 # Node ID c30cd64739845f4a2f923ff80bc524f8293e42b1 # Parent 68635bbb3d3efc1c3bc26b87eda7cc9317f60c27 .emacs diff -r 68635bbb3d3e -r c30cd6473984 .emacs --- a/.emacs Mon Sep 09 13:15:31 2013 -0700 +++ b/.emacs Tue Sep 17 19:24:26 2013 -0700 @@ -168,6 +168,25 @@ main()") ;; TODO: take directly from MakeItSo +(fset 'python-require "def require(url): + # http://k0s.org/hg/config/file/68635bbb3d3e/python/require.py + # import a module from the web + # url should be like scheme://host.name/path/to/module.py + + import imp + import os + import tempfile + import urllib2 + contents = urllib2.urlopen(url).read() + filename = url.rsplit('/', 1)[-1] + module = filename.rsplit('.', 1)[0] + dest = tempfile.mkstemp(suffix='.py', prefix=module) + f = file(dest, 'w') + f.write(contents) + f.close() + return imp.load_source(module, dest) +") + (fset 'mozbase-test "#!/usr/bin/env python # This Source Code Form is subject to the terms of the Mozilla Public