def normalize_path(path):
    """Resolve given path from relative into absolute form."""
    if './' not in path:
        return path

    # Normalize the URL by removing ./ and ../
    atoms = []
    for atom in path.split('/'):
        if atom == '.':
            pass
        elif atom == '..':
            # Don't pop from empty list
            # (i.e. ignore redundant '..')
            if atoms:
                atoms.pop()
        elif atom:
            atoms.append(atom)

    newpath = '/'.join(atoms)
    # Preserve leading '/'
    if path.startswith('/'):
        newpath = '/' + newpath

    return newpath
Resolve given path from relative into absolute form.
cherrypy/_helper.py