def inferModule(chain, AST, lineNo): imports = getImports(AST) fullModuleParts = [] valid = False for part in chain.split('.'): if part in imports: fullModuleParts.append(imports[part]) valid = True else: fullModuleParts.append(part) if valid: return '.'.join(fullModuleParts) return None