comparison mercurial/demandimport.py @ 26456:86fc4a2863ff

demandimport: refactor processfromitem This will match the next patch smaller and easier to read.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 04 Oct 2015 10:36:54 -0700
parents f2bf76d3d567
children 7e81305092a0
comparison
equal deleted inserted replaced
26455:f2bf76d3d567 26456:86fc4a2863ff
147 """Process an imported symbol in the import statement. 147 """Process an imported symbol in the import statement.
148 148
149 If the symbol doesn't exist in the parent module, it must be a 149 If the symbol doesn't exist in the parent module, it must be a
150 module. We set missing modules up as _demandmod instances. 150 module. We set missing modules up as _demandmod instances.
151 """ 151 """
152 if getattr(mod, attr, nothing) is nothing: 152 symbol = getattr(mod, attr, nothing)
153 setattr(mod, attr, 153 if symbol is nothing:
154 _demandmod(attr, mod.__dict__, locals, **kwargs)) 154 symbol = _demandmod(attr, mod.__dict__, locals, **kwargs)
155 setattr(mod, attr, symbol)
155 156
156 if level >= 0: 157 if level >= 0:
157 # Mercurial's enforced import style does not use 158 # Mercurial's enforced import style does not use
158 # "from a import b,c,d" or "from .a import b,c,d" syntax. In 159 # "from a import b,c,d" or "from .a import b,c,d" syntax. In
159 # addition, this appears to be giving errors with some modules 160 # addition, this appears to be giving errors with some modules