Mercurial > mozilla > hg > talosnames
comparison talosnames/require.py @ 14:1b18b2746e69
minor fixes
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 10 Jul 2012 18:09:19 -0700 |
parents | 1029ddf7b806 |
children | cc0edf61ab21 |
comparison
equal
deleted
inserted
replaced
13:323a01abd180 | 14:1b18b2746e69 |
---|---|
1 import imp | |
2 import os | |
3 import tempfile | |
4 import urllib2 | |
5 | |
1 def require(url): | 6 def require(url): |
2 """ | 7 """ |
3 import a module from the web | 8 import a module from the web |
4 url should be like scheme://host.name/path/to/module.py | 9 url should be like scheme://host.name/path/to/module.py |
5 """ | 10 """ |
6 import imp | |
7 import os | |
8 import tempfile | |
9 import urllib2 | |
10 contents = urllib2.urlopen(url).read() | 11 contents = urllib2.urlopen(url).read() |
11 filename = url.rsplit('/', 1)[-1] | 12 filename = url.rsplit('/', 1)[-1] |
12 module = filename.rsplit('.', 1)[-1] | 13 module = filename.rsplit('.', 1)[-1] |
13 dest = tempfile.mktemp(suffix='.py', prefix=module) | 14 dest = tempfile.mktemp(suffix='.py', prefix=module) |
14 f = file(dest, 'w') | 15 f = file(dest, 'w') |