Show More
@@ -0,0 +1,47 b'' | |||
|
1 | #!/usr/bin/env python | |
|
2 | ||
|
3 | from mercurial import demandimport | |
|
4 | demandimport.enable() | |
|
5 | ||
|
6 | import re | |
|
7 | ||
|
8 | rsub = re.sub | |
|
9 | def f(obj): | |
|
10 | l = repr(obj) | |
|
11 | l = rsub("0x[0-9a-f]+", "0x?", l) | |
|
12 | l = rsub("from '.*'", "from '?'", l) | |
|
13 | return l | |
|
14 | ||
|
15 | import os | |
|
16 | ||
|
17 | print "os =", f(os) | |
|
18 | print "os.system =", f(os.system) | |
|
19 | print "os =", f(os) | |
|
20 | ||
|
21 | import mercurial.version | |
|
22 | ||
|
23 | print "mercurial.version =", f(mercurial.version) | |
|
24 | print "mercurial.version.get_version =", f(mercurial.version.get_version) | |
|
25 | print "mercurial.version =", f(mercurial.version) | |
|
26 | print "mercurial =", f(mercurial) | |
|
27 | ||
|
28 | from mercurial import util | |
|
29 | ||
|
30 | print "util =", f(util) | |
|
31 | print "util.system =", f(util.system) | |
|
32 | print "util =", f(util) | |
|
33 | print "util.system =", f(util.system) | |
|
34 | ||
|
35 | import re as fred | |
|
36 | print "fred =", f(fred) | |
|
37 | ||
|
38 | import sys as re | |
|
39 | print "re =", f(re) | |
|
40 | ||
|
41 | print "fred =", f(fred) | |
|
42 | print "fred.sub =", f(fred.sub) | |
|
43 | print "fred =", f(fred) | |
|
44 | ||
|
45 | print "re =", f(re) | |
|
46 | print "re.stdout =", f(re.stdout) | |
|
47 | print "re =", f(re) |
@@ -0,0 +1,19 b'' | |||
|
1 | os = <unloaded module 'os'> | |
|
2 | os.system = <built-in function system> | |
|
3 | os = <module 'os' from '?'> | |
|
4 | mercurial.version = <unloaded module 'version'> | |
|
5 | mercurial.version.get_version = <function get_version at 0x?> | |
|
6 | mercurial.version = <module 'mercurial.version' from '?'> | |
|
7 | mercurial = <module 'mercurial' from '?'> | |
|
8 | util = <unloaded module 'util'> | |
|
9 | util.system = <function system at 0x?> | |
|
10 | util = <module 'mercurial.util' from '?'> | |
|
11 | util.system = <function system at 0x?> | |
|
12 | fred = <unloaded module 're'> | |
|
13 | re = <unloaded module 'sys'> | |
|
14 | fred = <unloaded module 're'> | |
|
15 | fred.sub = <function sub at 0x?> | |
|
16 | fred = <proxied module 're'> | |
|
17 | re = <unloaded module 'sys'> | |
|
18 | re.stdout = <open file '<stdout>', mode 'w' at 0x?> | |
|
19 | re = <proxied module 'sys'> |
@@ -61,7 +61,10 b' class _demandmod(object):' | |||
|
61 | 61 | if locals and locals.get(head) == self: |
|
62 | 62 | locals[head] = mod |
|
63 | 63 | object.__setattr__(self, "_module", mod) |
|
64 | ||
|
64 | 65 | def __repr__(self): |
|
66 | if self._module: | |
|
67 | return "<proxied module '%s'>" % self._data[0] | |
|
65 | 68 | return "<unloaded module '%s'>" % self._data[0] |
|
66 | 69 | def __call__(self, *args, **kwargs): |
|
67 | 70 | raise TypeError("'unloaded module' object is not callable") |
@@ -102,7 +105,7 b' def _demandimport(name, globals=None, lo' | |||
|
102 | 105 | for x in fromlist: |
|
103 | 106 | # set requested submodules for demand load |
|
104 | 107 | if not(hasattr(mod, x)): |
|
105 |
setattr(mod, x, _demandmod(x, mod.__dict__, |
|
|
108 | setattr(mod, x, _demandmod(x, mod.__dict__, locals)) | |
|
106 | 109 | return mod |
|
107 | 110 | |
|
108 | 111 | ignore = ['_hashlib', '_xmlplus', 'fcntl', 'win32com.gen_py'] |
General Comments 0
You need to be logged in to leave comments.
Login now