def get_canonical_uri_path(uri_path):
<EOL>if uri_path == "<STR_LIT>" or uri_path == "<STR_LIT:/>":<EOL><INDENT>return "<STR_LIT:/>"<EOL><DEDENT>if not uri_path.startswith("<STR_LIT:/>"):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>uri_path = _multislash.sub("<STR_LIT:/>", uri_path)<EOL>components = uri_path.split("<STR_LIT:/>")[<NUM_LIT:1>:]<EOL>i = <NUM_LIT:0><EOL>while i < len(components):<EOL><INDENT>component = normalize_uri_path_component(components[i])<EOL>components[i] = component<EOL>if components[i] == "<STR_LIT:.>":<EOL><INDENT>del components[i]<EOL><DEDENT>elif components[i] == "<STR_LIT:..>":<EOL><INDENT>if i == <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>del components[i-<NUM_LIT:1>:i+<NUM_LIT:1>]<EOL>i -= <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>return "<STR_LIT:/>" + "<STR_LIT:/>".join(components)<EOL>
get_canonical_uri_path(uri_path) -> str

Normalizes the specified URI path component, removing redundant slashes
and relative path components.

A ValueError exception is raised if:
* The URI path is not empty and not absolute (does not start with '/').
* A parent relative path element ('..') attempts to go beyond the top.
* An invalid percent-encoding is encountered.