(s)
return '/'.join(output)
Remove dot segments from the string.

    See also Section 5.2.4 of :rfc:`3986`.
Remove dot segments from the string.
Remove dot segments from the string .
def remove_dot_segments(s):
    """Remove dot segments from the string.

    See also Section 5.2.4 of :rfc:`3986`.
    """
    # See http://tools.ietf.org/html/rfc3986#section-5.2.4 for pseudo-code
    segments = s.split('/')  # Turn the path into a list of segments
    output = []  # Initialize the variable to use to store output

    for segment in segments:
        # '.' is the current directory, so ignore it, it is superfluous
        if segment == '.':
            continue
        # Anything other than '..', should be appended to the output
        elif segment != '..':
            output.append(segment)
        # In this case segment == '..', if we can, we should pop the last
        # element
        elif output:
            output.pop()

    # If the path starts with '/' and the output is empty or the first string
    # is non-empty
    if s.startswith('/') and (not output or output[0]):
        output.insert(0, '')

    # If the path starts with '/.' or '/..' ensure we add one more empty
    # string to add a trailing '/'
    if s.endswith(('/.', '/..')):
        output.append('')

    return '/'.join(output)
def remove_dot_segments ( s ) : # See http://tools.ietf.org/html/rfc3986#section-5.2.4 for pseudo-code segments = s . split ( '/' ) # Turn the path into a list of segments output = [ ] # Initialize the variable to use to store output for segment in segments : # '.' is the current directory, so ignore it, it is superfluous if segment == '.' : continue # Anything other than '..', should be appended to the output elif segment != '..' : output . append ( segment ) # In this case segment == '..', if we can, we should pop the last # element elif output : output . pop ( ) # If the path starts with '/' and the output is empty or the first string # is non-empty if s . startswith ( '/' ) and ( not output or output [ 0 ] ) : output . insert ( 0 , '' ) # If the path starts with '/.' or '/..' ensure we add one more empty # string to add a trailing '/' if s . endswith ( ( '/.' , '/..' ) ) : output . append ( '' ) return '/' . join ( output )