Mercurial > hg > config
comparison python/require.py @ 168:09c748a71b1b
handle overlapping files
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 26 Sep 2011 16:33:02 -0700 |
parents | f145d7b1fbf7 |
children | 691b508084f1 |
comparison
equal
deleted
inserted
replaced
167:842e1fca024a | 168:09c748a71b1b |
---|---|
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)[-1] |
13 dest = os.path.join(tempfile.gettempdir(), filename) | 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) |
18 | 18 |