#NEWLINE# def path_info_pop( self , pattern = None ) : #NEWLINE# #INDENT# "\n        'Pops' off the next segment of PATH_INFO, pushing it onto\n        SCRIPT_NAME, and returning the popped segment.  Returns None if\n        there is nothing left on PATH_INFO.\n\n        Does not return ``''`` when there's an empty segment (like\n        ``/path//path``); these segments are just ignored.\n\n        Optional ``pattern`` argument is a regexp to match the return value\n        before returning. If there is no match, no changes are made to the\n        request and None is returned.\n        " #NEWLINE# path = self . path_info #NEWLINE# if ( not path ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# slashes = '' #NEWLINE# while path . startswith ( '/' ) : #NEWLINE# #INDENT# slashes += '/' #NEWLINE# path = path [ 1 : ] #NEWLINE# #UNINDENT# idx = path . find ( '/' ) #NEWLINE# if ( idx == ( - 1 ) ) : #NEWLINE# #INDENT# idx = len ( path ) #NEWLINE# #UNINDENT# r = path [ : idx ] #NEWLINE# if ( ( pattern is None ) or re . match ( pattern , r ) ) : #NEWLINE# #INDENT# self . script_name += ( slashes + r ) #NEWLINE# self . path_info = path [ idx : ] #NEWLINE# return pattern