def pathparse(value, sep=os.pathsep, os_sep=os.sep):
escapes = []<EOL>normpath = ntpath.normpath if os_sep == '<STR_LIT:\\>' else posixpath.normpath<EOL>if '<STR_LIT:\\>' not in (os_sep, sep):<EOL><INDENT>escapes.extend((<EOL>('<STR_LIT>', '<STR_LIT>', '<STR_LIT:\\>'),<EOL>('<STR_LIT>', '<STR_LIT>', '<STR_LIT:">'),<EOL>('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>' % sep, '<STR_LIT>', sep),<EOL>))<EOL><DEDENT>for original, escape, unescape in escapes:<EOL><INDENT>value = value.replace(original, escape)<EOL><DEDENT>for part in pathsplit(value, sep=sep):<EOL><INDENT>if part[-<NUM_LIT:1>:] == os_sep and part != os_sep:<EOL><INDENT>part = part[:-<NUM_LIT:1>]<EOL><DEDENT>for original, escape, unescape in escapes:<EOL><INDENT>part = part.replace(escape, unescape)<EOL><DEDENT>yield normpath(fsdecode(part))<EOL><DEDENT>
Get enviroment PATH directories as list.

This function cares about spliting, escapes and normalization of paths
across OSes.

:param value: path string, as given by os.environ['PATH']
:type value: str
:param sep: PATH separator, defaults to os.pathsep
:type sep: str
:param os_sep: OS filesystem path separator, defaults to os.sep
:type os_sep: str
:yields: every path
:ytype: str