Mercurial > hg
comparison hgdemandimport/demandimportpy2.py @ 32447:252d2260c74e
demandimport: look for 'mod' suffix as alternative name for module reference
It's widely used in our codebase.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 28 Apr 2017 23:46:16 +0900 |
parents | 63365e9621d6 |
children | 91a2ec8e7fa0 |
comparison
equal
deleted
inserted
replaced
32446:63365e9621d6 | 32447:252d2260c74e |
---|---|
130 | 130 |
131 for x in after: | 131 for x in after: |
132 subload(mod, x) | 132 subload(mod, x) |
133 | 133 |
134 # Replace references to this proxy instance with the actual module. | 134 # Replace references to this proxy instance with the actual module. |
135 if locals and locals.get(head) is self: | 135 if locals: |
136 locals[head] = mod | 136 if locals.get(head) is self: |
137 locals[head] = mod | |
138 elif locals.get(head + r'mod') is self: | |
139 locals[head + r'mod'] = mod | |
137 | 140 |
138 for modname in modrefs: | 141 for modname in modrefs: |
139 modref = sys.modules.get(modname, None) | 142 modref = sys.modules.get(modname, None) |
140 if modref and getattr(modref, head, None) is self: | 143 if modref and getattr(modref, head, None) is self: |
141 setattr(modref, head, mod) | 144 setattr(modref, head, mod) |