def path_shift(script_name, path_info, shift=<NUM_LIT:1>):
if shift == <NUM_LIT:0>: return script_name, path_info<EOL>pathlist = path_info.strip('<STR_LIT:/>').split('<STR_LIT:/>')<EOL>scriptlist = script_name.strip('<STR_LIT:/>').split('<STR_LIT:/>')<EOL>if pathlist and pathlist[<NUM_LIT:0>] == '<STR_LIT>': pathlist = []<EOL>if scriptlist and scriptlist[<NUM_LIT:0>] == '<STR_LIT>': scriptlist = []<EOL>if shift > <NUM_LIT:0> and shift <= len(pathlist):<EOL><INDENT>moved = pathlist[:shift]<EOL>scriptlist = scriptlist + moved<EOL>pathlist = pathlist[shift:]<EOL><DEDENT>elif shift < <NUM_LIT:0> and shift >= -len(scriptlist):<EOL><INDENT>moved = scriptlist[shift:]<EOL>pathlist = moved + pathlist<EOL>scriptlist = scriptlist[:shift]<EOL><DEDENT>else:<EOL><INDENT>empty = '<STR_LIT>' if shift < <NUM_LIT:0> else '<STR_LIT>'<EOL>raise AssertionError("<STR_LIT>" % empty)<EOL><DEDENT>new_script_name = '<STR_LIT:/>' + '<STR_LIT:/>'.join(scriptlist)<EOL>new_path_info = '<STR_LIT:/>' + '<STR_LIT:/>'.join(pathlist)<EOL>if path_info.endswith('<STR_LIT:/>') and pathlist: new_path_info += '<STR_LIT:/>'<EOL>return new_script_name, new_path_info<EOL>
Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa.

        :return: The modified paths.
        :param script_name: The SCRIPT_NAME path.
        :param script_name: The PATH_INFO path.
        :param shift: The number of path fragments to shift. May be negative to
          change the shift direction. (default: 1)