def PrefixFromPattern(pattern):
 if pattern.endswith('*'):
  return pattern[:(-1)]
 elif pattern.endswith('/'):
  return ('' if (pattern == '/') else pattern)
 elif (pattern == ''):
  return pattern
 else:
  return (pattern + '/')

def PrefixFromPattern ( pattern ) : if pattern . endswith ( '*' ) : return pattern [ : ( - 1 ) ] elif pattern . endswith ( '/' ) : return ( '' if ( pattern == '/' ) else pattern ) elif ( pattern == '' ) : return pattern else : return ( pattern + '/' )
given a path pattern .