def minrelpath(path):
if not is_string(path):<EOL><INDENT>return path<EOL><DEDENT>if '<STR_LIT:.>' not in path:<EOL><INDENT>return path<EOL><DEDENT>l = path.split(os.sep)<EOL>while l:<EOL><INDENT>try:<EOL><INDENT>i = l.index('<STR_LIT:.>', <NUM_LIT:1>)<EOL><DEDENT>except ValueError:<EOL><INDENT>break<EOL><DEDENT>del l[i]<EOL><DEDENT>j = <NUM_LIT:1><EOL>while l:<EOL><INDENT>try:<EOL><INDENT>i = l.index('<STR_LIT:..>', j)<EOL><DEDENT>except ValueError:<EOL><INDENT>break<EOL><DEDENT>if l[i-<NUM_LIT:1>]=='<STR_LIT:..>':<EOL><INDENT>j += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>del l[i], l[i-<NUM_LIT:1>]<EOL>j = <NUM_LIT:1><EOL><DEDENT><DEDENT>if not l:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>return os.sep.join(l)<EOL>
Resolve `..` and '.' from path.