def importFromDir(self, dir, fqname):
dir = os.path.normpath(os.path.abspath(dir))<EOL>log.debug("<STR_LIT>", fqname, dir)<EOL>if fqname == '<STR_LIT:__main__>':<EOL><INDENT>return sys.modules[fqname]<EOL><DEDENT>if self.config.addPaths:<EOL><INDENT>add_path(dir, self.config)<EOL><DEDENT>path = [dir]<EOL>parts = fqname.split('<STR_LIT:.>')<EOL>part_fqname = '<STR_LIT>'<EOL>mod = parent = fh = None<EOL>for part in parts:<EOL><INDENT>if part_fqname == '<STR_LIT>':<EOL><INDENT>part_fqname = part<EOL><DEDENT>else:<EOL><INDENT>part_fqname = "<STR_LIT>" % (part_fqname, part)<EOL><DEDENT>try:<EOL><INDENT>acquire_lock()<EOL>log.debug("<STR_LIT>",<EOL>part, part_fqname, path)<EOL>fh, filename, desc = find_module(part, path)<EOL>old = sys.modules.get(part_fqname)<EOL>if old is not None:<EOL><INDENT>log.debug("<STR_LIT>", part_fqname, old)<EOL>if (self.sameModule(old, filename)<EOL>or (self.config.firstPackageWins and<EOL>getattr(old, '<STR_LIT>', None))):<EOL><INDENT>mod = old<EOL><DEDENT>else:<EOL><INDENT>del sys.modules[part_fqname]<EOL>mod = load_module(part_fqname, fh, filename, desc)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>mod = load_module(part_fqname, fh, filename, desc)<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>if fh:<EOL><INDENT>fh.close()<EOL><DEDENT>release_lock()<EOL><DEDENT>if parent:<EOL><INDENT>setattr(parent, part, mod)<EOL><DEDENT>if hasattr(mod, '<STR_LIT>'):<EOL><INDENT>path = mod.__path__<EOL><DEDENT>parent = mod<EOL><DEDENT>return mod<EOL>
Import a module *only* from path, ignoring sys.path and
        reloading if the version in sys.modules is not the one we want.