def parse_path_info(path_info, av=False):
 if av:
  vars = None
  if ('?' in path_info):
   (path_info, query) = path_info.split('?', 2)
   vars = Storage()
   for var in query.split('&'):
    (var, val) = (var.split('=', 2) if ('=' in var) else (var, None))
    vars[var] = val
  items = List(path_info.split('/'))
  args = (List(items[3:]) if (len(items) > 3) else None)
  return (items(0), items(1), items(2), args, vars)
 mo = re.match('^/?(?P<a>\\w+)(/(?P<c>\\w+)(/(?P<f>\\w+))?)?$', path_info)
 if mo:
  return (mo.group('a'), mo.group('c'), mo.group('f'))
 else:
  return (None, None, None)

def parse_path_info ( path_info , av = False ) : if av : vars = None if ( '?' in path_info ) : ( path_info , query ) = path_info . split ( '?' , 2 ) vars = Storage ( ) for var in query . split ( '&' ) : ( var , val ) = ( var . split ( '=' , 2 ) if ( '=' in var ) else ( var , None ) ) vars [ var ] = val items = List ( path_info . split ( '/' ) ) args = ( List ( items [ 3 : ] ) if ( len ( items ) > 3 ) else None ) return ( items ( 0 ) , items ( 1 ) , items ( 2 ) , args , vars ) mo = re . match ( '^/?(?P<a>\\w+)(/(?P<c>\\w+)(/(?P<f>\\w+))?)?$' , path_info ) if mo : return ( mo . group ( 'a' ) , mo . group ( 'c' ) , mo . group ( 'f' ) ) else : return ( None , None , None )
parses path info formatted like a/c/f where c and f are optional and a leading / is accepted .