def id_mods(obj,modlist,intrinsic_mods={},submodlist=[]):
for i in range(len(obj.uses)):<EOL><INDENT>for candidate in modlist:<EOL><INDENT>if obj.uses[i][<NUM_LIT:0>].lower() == candidate.name.lower():<EOL><INDENT>obj.uses[i] = [candidate, obj.uses[i][<NUM_LIT:1>]]<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if obj.uses[i][<NUM_LIT:0>].lower() in intrinsic_mods:<EOL><INDENT>obj.uses[i] = [intrinsic_mods[obj.uses[i][<NUM_LIT:0>].lower()], obj.uses[i][<NUM_LIT:1>]]<EOL>continue<EOL><DEDENT><DEDENT><DEDENT>if getattr(obj,'<STR_LIT>',None):<EOL><INDENT>for submod in submodlist:<EOL><INDENT>if obj.ancestor.lower() == submod.name.lower():<EOL><INDENT>obj.ancestor = submod<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if hasattr(obj,'<STR_LIT>'):<EOL><INDENT>for mod in modlist:<EOL><INDENT>if obj.ancestor_mod.lower() == mod.name.lower():<EOL><INDENT>obj.ancestor_mod = mod<EOL>break<EOL><DEDENT><DEDENT><DEDENT>for modproc in getattr(obj,'<STR_LIT>',[]):<EOL><INDENT>id_mods(modproc,modlist,intrinsic_mods)<EOL><DEDENT>for func in getattr(obj,'<STR_LIT>',[]):<EOL><INDENT>id_mods(func,modlist,intrinsic_mods)<EOL><DEDENT>for subroutine in getattr(obj,'<STR_LIT>',[]):<EOL><INDENT>id_mods(subroutine,modlist,intrinsic_mods)<EOL><DEDENT>
Match USE statements up with the right modules