def insert_on(self, path, loc = None):
loc = loc or self.location<EOL>if not loc:<EOL><INDENT>return<EOL><DEDENT>if path is sys.path:<EOL><INDENT>self.check_version_conflict()<EOL><DEDENT>nloc = _normalize_cached(loc)<EOL>bdir = os.path.dirname(nloc)<EOL>npath= list(map(_normalize_cached, path))<EOL>bp = None<EOL>for p, item in enumerate(npath):<EOL><INDENT>if item==nloc:<EOL><INDENT>break<EOL><DEDENT>elif item==bdir and self.precedence==EGG_DIST:<EOL><INDENT>path.insert(p, loc)<EOL>npath.insert(p, nloc)<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>path.append(loc)<EOL>return<EOL><DEDENT>while <NUM_LIT:1>:<EOL><INDENT>try:<EOL><INDENT>np = npath.index(nloc, p+<NUM_LIT:1>)<EOL><DEDENT>except ValueError:<EOL><INDENT>break<EOL><DEDENT>else:<EOL><INDENT>del npath[np], path[np]<EOL>p = np  <EOL><DEDENT><DEDENT>return<EOL>
Insert self.location in path before its nearest parent directory