Mercurial > hg > config
comparison python/require.py @ 230:691b508084f1
fix module
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 10 Jul 2012 16:10:10 -0700 |
parents | 09c748a71b1b |
children |
comparison
equal
deleted
inserted
replaced
229:38ab5ff0e5cd | 230:691b508084f1 |
---|---|
7 import os | 7 import os |
8 import tempfile | 8 import tempfile |
9 import urllib2 | 9 import urllib2 |
10 contents = urllib2.urlopen(url).read() | 10 contents = urllib2.urlopen(url).read() |
11 filename = url.rsplit('/', 1)[-1] | 11 filename = url.rsplit('/', 1)[-1] |
12 module = filename.rsplit('.', 1)[-1] | 12 module = filename.rsplit('.', 1)[0] |
13 dest = tempfile.mkstemp(suffix='.py', prefix=module) | 13 dest = tempfile.mkstemp(suffix='.py', prefix=module) |
14 f = file(dest, 'w') | 14 f = file(dest, 'w') |
15 f.write(contents) | 15 f.write(contents) |
16 f.close() | 16 f.close() |
17 return imp.load_source(module, dest) | 17 return imp.load_source(module, dest) |