def test_source_reference(tmpdir): import pydevd_file_utils pydevd_file_utils.set_ide_os('WINDOWS') if IS_WINDOWS: # Client and server are on windows. pydevd_file_utils.setup_client_server_paths([('c:\\foo', 'c:\\bar')]) assert pydevd_file_utils.norm_file_to_client('c:\\bar\\my') == 'c:\\foo\\my' assert pydevd_file_utils.get_client_filename_source_reference('c:\\foo\\my') == 0 assert pydevd_file_utils.norm_file_to_client('c:\\another\\my') == 'c:\\another\\my' source_reference = pydevd_file_utils.get_client_filename_source_reference('c:\\another\\my') assert source_reference != 0 assert pydevd_file_utils.get_server_filename_from_source_reference(source_reference) == 'c:\\another\\my' else: # Client on windows and server on unix pydevd_file_utils.set_ide_os('WINDOWS') pydevd_file_utils.setup_client_server_paths([('c:\\foo', '/bar')]) assert pydevd_file_utils.norm_file_to_client('/bar/my') == 'c:\\foo\\my' assert pydevd_file_utils.get_client_filename_source_reference('c:\\foo\\my') == 0 assert pydevd_file_utils.norm_file_to_client('/another/my') == '\\another\\my' source_reference = pydevd_file_utils.get_client_filename_source_reference('\\another\\my') assert source_reference != 0 assert pydevd_file_utils.get_server_filename_from_source_reference(source_reference) == '/another/my'
def _iter_visible_frames_info(self, py_db, frames_list): assert frames_list.__class__ == FramesList for frame in frames_list: if frame.f_code is None: pydev_log.info('Frame without f_code: %s', frame) continue # IronPython sometimes does not have it! method_name = frame.f_code.co_name # method name (if in method) or ? if global if method_name is None: pydev_log.info('Frame without co_name: %s', frame) continue # IronPython sometimes does not have it! abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) if py_db.get_file_type(frame, abs_path_real_path_and_base) == py_db.PYDEV_FILE: # Skip pydevd files. frame = frame.f_back continue frame_id = id(frame) lineno = frames_list.frame_id_to_lineno.get(frame_id, frame.f_lineno) filename_in_utf8, lineno, changed = py_db.source_mapping.map_to_client(abs_path_real_path_and_base[0], lineno) new_filename_in_utf8, applied_mapping = pydevd_file_utils.norm_file_to_client(filename_in_utf8) applied_mapping = applied_mapping or changed yield frame_id, frame, method_name, abs_path_real_path_and_base[0], new_filename_in_utf8, lineno, applied_mapping
def _iter_visible_frames_info(self, py_db, frame, frame_id_to_lineno): while frame is not None: if frame.f_code is None: continue # IronPython sometimes does not have it! method_name = frame.f_code.co_name # method name (if in method) or ? if global if method_name is None: continue # IronPython sometimes does not have it! abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame( frame) if py_db.get_file_type( abs_path_real_path_and_base) == py_db.PYDEV_FILE: # Skip pydevd files. frame = frame.f_back continue filename_in_utf8 = pydevd_file_utils.norm_file_to_client( abs_path_real_path_and_base[0]) frame_id = id(frame) lineno = frame_id_to_lineno.get(frame_id, frame.f_lineno) yield frame_id, frame, method_name, abs_path_real_path_and_base[ 0], filename_in_utf8, lineno frame = frame.f_back
def make_thread_stack_str(self, frame, frame_id_to_lineno=None): ''' :param frame_id_to_lineno: If available, the line number for the frame will be gotten from this dict, otherwise frame.f_lineno will be used (needed for unhandled exceptions as the place where we report may be different from the place where it's raised). ''' if frame_id_to_lineno is None: frame_id_to_lineno = {} make_valid_xml_value = pydevd_xml.make_valid_xml_value cmd_text_list = [] append = cmd_text_list.append curr_frame = frame frame = None # Clear frame reference try: py_db = get_global_debugger() while curr_frame: frame_id = id(curr_frame) if curr_frame.f_code is None: break # Iron Python sometimes does not have it! method_name = curr_frame.f_code.co_name # method name (if in method) or ? if global if method_name is None: break # Iron Python sometimes does not have it! abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(curr_frame) if py_db.get_file_type(abs_path_real_path_and_base) == py_db.PYDEV_FILE: # Skip pydevd files. curr_frame = curr_frame.f_back continue filename_in_utf8 = pydevd_file_utils.norm_file_to_client(abs_path_real_path_and_base[0]) if not filesystem_encoding_is_utf8 and hasattr(filename_in_utf8, "decode"): # filename_in_utf8 is a byte string encoded using the file system encoding # convert it to utf8 filename_in_utf8 = filename_in_utf8.decode(file_system_encoding).encode("utf-8") # print("file is ", filename_in_utf8) lineno = frame_id_to_lineno.get(frame_id, curr_frame.f_lineno) # print("line is ", lineno) # Note: variables are all gotten 'on-demand'. append('<frame id="%s" name="%s" ' % (frame_id , make_valid_xml_value(method_name))) append('file="%s" line="%s">' % (quote(make_valid_xml_value(filename_in_utf8), '/>_= \t'), lineno)) append("</frame>") curr_frame = curr_frame.f_back except: traceback.print_exc() curr_frame = None # Clear frame reference return ''.join(cmd_text_list)
def make_thread_stack_str(self, frame, frame_to_lineno=None): ''' :param frame_to_lineno: If available, the line number for the frame will be gotten from this dict, otherwise frame.f_lineno will be used (needed for unhandled exceptions as the place where we report may be different from the place where it's raised). ''' if frame_to_lineno is None: frame_to_lineno = {} make_valid_xml_value = pydevd_xml.make_valid_xml_value cmd_text_list = [] append = cmd_text_list.append curr_frame = frame frame = None # Clear frame reference try: py_db = get_global_debugger() while curr_frame: my_id = id(curr_frame) if curr_frame.f_code is None: break # Iron Python sometimes does not have it! method_name = curr_frame.f_code.co_name # method name (if in method) or ? if global if method_name is None: break # Iron Python sometimes does not have it! abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(curr_frame) if py_db.get_file_type(abs_path_real_path_and_base) == py_db.PYDEV_FILE: # Skip pydevd files. curr_frame = curr_frame.f_back continue filename_in_utf8 = pydevd_file_utils.norm_file_to_client(abs_path_real_path_and_base[0]) if not filesystem_encoding_is_utf8 and hasattr(filename_in_utf8, "decode"): # filename_in_utf8 is a byte string encoded using the file system encoding # convert it to utf8 filename_in_utf8 = filename_in_utf8.decode(file_system_encoding).encode("utf-8") # print("file is ", filename_in_utf8) lineno = frame_to_lineno.get(curr_frame, curr_frame.f_lineno) # print("line is ", lineno) # Note: variables are all gotten 'on-demand'. append('<frame id="%s" name="%s" ' % (my_id , make_valid_xml_value(method_name))) append('file="%s" line="%s">' % (quote(make_valid_xml_value(filename_in_utf8), '/>_= \t'), lineno)) append("</frame>") curr_frame = curr_frame.f_back except: traceback.print_exc() curr_frame = None # Clear frame reference return ''.join(cmd_text_list)
def get_text_list_for_frame(frame): # partial copy-paste from make_thread_suspend_str curFrame = frame cmdTextList = [] try: while curFrame: #print cmdText myId = str(id(curFrame)) #print "id is ", myId if curFrame.f_code is None: break #Iron Python sometimes does not have it! myName = curFrame.f_code.co_name #method name (if in method) or ? if global if myName is None: break #Iron Python sometimes does not have it! #print "name is ", myName filename = pydevd_file_utils.get_abs_path_real_path_and_base_from_frame( curFrame)[1] myFile = pydevd_file_utils.norm_file_to_client(filename) if file_system_encoding.lower() != "utf-8" and hasattr( myFile, "decode"): # myFile is a byte string encoded using the file system encoding # convert it to utf8 myFile = myFile.decode(file_system_encoding).encode("utf-8") #print "file is ", myFile #myFile = inspect.getsourcefile(curFrame) or inspect.getfile(frame) myLine = str(curFrame.f_lineno) #print "line is ", myLine #the variables are all gotten 'on-demand' #variables = pydevd_vars.frame_vars_to_xml(curFrame.f_locals) variables = '' cmdTextList.append( '<frame id="%s" name="%s" ' % (myId, pydevd_vars.make_valid_xml_value(myName))) cmdTextList.append('file="%s" line="%s">' % (quote(myFile, '/>_= \t'), myLine)) cmdTextList.append(variables) cmdTextList.append("</frame>") curFrame = curFrame.f_back except: traceback.print_exc() return cmdTextList
def get_text_list_for_frame(frame): # partial copy-paste from make_thread_suspend_str curFrame = frame cmdTextList = [] try: while curFrame: #print cmdText myId = str(id(curFrame)) #print "id is ", myId if curFrame.f_code is None: break #Iron Python sometimes does not have it! myName = curFrame.f_code.co_name #method name (if in method) or ? if global if myName is None: break #Iron Python sometimes does not have it! #print "name is ", myName filename = pydevd_file_utils.get_abs_path_real_path_and_base_from_frame(curFrame)[1] myFile = pydevd_file_utils.norm_file_to_client(filename) if file_system_encoding.lower() != "utf-8" and hasattr(myFile, "decode"): # myFile is a byte string encoded using the file system encoding # convert it to utf8 myFile = myFile.decode(file_system_encoding).encode("utf-8") #print "file is ", myFile #myFile = inspect.getsourcefile(curFrame) or inspect.getfile(frame) myLine = str(curFrame.f_lineno) #print "line is ", myLine #the variables are all gotten 'on-demand' #variables = pydevd_xml.frame_vars_to_xml(curFrame.f_locals) variables = '' cmdTextList.append('<frame id="%s" name="%s" ' % (myId , pydevd_xml.make_valid_xml_value(myName))) cmdTextList.append('file="%s" line="%s">' % (quote(myFile, '/>_= \t'), myLine)) cmdTextList.append(variables) cmdTextList.append("</frame>") curFrame = curFrame.f_back except : traceback.print_exc() return cmdTextList
def get_text_list_for_frame(frame): # partial copy-paste from make_thread_suspend_str curFrame = frame cmdTextList = [] try: while curFrame: # print cmdText myId = str(id(curFrame)) # print "id is ", myId if curFrame.f_code is None: break # Iron Python sometimes does not have it! myName = curFrame.f_code.co_name # method name (if in method) or ? if global if myName is None: break # Iron Python sometimes does not have it! # print "name is ", myName filename = pydevd_file_utils.get_abs_path_real_path_and_base_from_frame( curFrame)[1] myFile = pydevd_file_utils.norm_file_to_client(filename) # print "file is ", myFile # myFile = inspect.getsourcefile(curFrame) or inspect.getfile(frame) myLine = str(curFrame.f_lineno) # print "line is ", myLine # the variables are all gotten 'on-demand' # variables = pydevd_xml.frame_vars_to_xml(curFrame.f_locals) variables = '' cmdTextList.append('<frame id="%s" name="%s" ' % (myId, pydevd_xml.make_valid_xml_value(myName))) cmdTextList.append('file="%s" line="%s">' % (quote(myFile, '/>_= \t'), myLine)) cmdTextList.append(variables) cmdTextList.append("</frame>") curFrame = curFrame.f_back except: pydev_log.exception() return cmdTextList
def get_text_list_for_frame(frame): # partial copy-paste from make_thread_suspend_str curFrame = frame cmdTextList = [] try: while curFrame: # print cmdText myId = str(id(curFrame)) # print "id is ", myId if curFrame.f_code is None: break # Iron Python sometimes does not have it! myName = curFrame.f_code.co_name # method name (if in method) or ? if global if myName is None: break # Iron Python sometimes does not have it! # print "name is ", myName filename = pydevd_file_utils.get_abs_path_real_path_and_base_from_frame(curFrame)[1] myFile = pydevd_file_utils.norm_file_to_client(filename) # print "file is ", myFile # myFile = inspect.getsourcefile(curFrame) or inspect.getfile(frame) myLine = str(curFrame.f_lineno) # print "line is ", myLine # the variables are all gotten 'on-demand' # variables = pydevd_xml.frame_vars_to_xml(curFrame.f_locals) variables = '' cmdTextList.append('<frame id="%s" name="%s" ' % (myId , pydevd_xml.make_valid_xml_value(myName))) cmdTextList.append('file="%s" line="%s">' % (quote(myFile, '/>_= \t'), myLine)) cmdTextList.append(variables) cmdTextList.append("</frame>") curFrame = curFrame.f_back except : pydev_log.exception() return cmdTextList
def _iter_visible_frames_info(self, py_db, frame, frame_id_to_lineno): while frame is not None: if frame.f_code is None: continue # IronPython sometimes does not have it! method_name = frame.f_code.co_name # method name (if in method) or ? if global if method_name is None: continue # IronPython sometimes does not have it! abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) if py_db.get_file_type(abs_path_real_path_and_base) == py_db.PYDEV_FILE: # Skip pydevd files. frame = frame.f_back continue filename_in_utf8 = pydevd_file_utils.norm_file_to_client(abs_path_real_path_and_base[0]) frame_id = id(frame) lineno = frame_id_to_lineno.get(frame_id, frame.f_lineno) yield frame_id, frame, method_name, filename_in_utf8, lineno frame = frame.f_back
def test_to_server_and_to_client(tmpdir): try: def check(obtained, expected): assert obtained == expected assert isinstance(obtained, str) # bytes on py2, unicode on py3 assert isinstance(expected, str) # bytes on py2, unicode on py3 import pydevd_file_utils import sys if sys.platform == 'win32': # Check with made-up files # Client and server are on windows. pydevd_file_utils.set_ide_os('WINDOWS') in_eclipse = 'c:\\foo' in_python = 'c:\\bar' PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) check(pydevd_file_utils.norm_file_to_server('c:\\foo\\my'), 'c:\\bar\\my') check( pydevd_file_utils.norm_file_to_server( 'c:\\foo\\áéíóú'.upper()), 'c:\\bar\\áéíóú') check(pydevd_file_utils.norm_file_to_client('c:\\bar\\my'), 'c:\\foo\\my') # Client on unix and server on windows pydevd_file_utils.set_ide_os('UNIX') in_eclipse = '/foo' in_python = 'c:\\bar' PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) check(pydevd_file_utils.norm_file_to_server('/foo/my'), 'c:\\bar\\my') check(pydevd_file_utils.norm_file_to_client('c:\\bar\\my'), '/foo/my') # Test with 'real' files # Client and server are on windows. pydevd_file_utils.set_ide_os('WINDOWS') test_dir = str(tmpdir.mkdir("Foo")) os.makedirs(os.path.join(test_dir, "Another")) in_eclipse = os.path.join(os.path.dirname(test_dir), 'Bar') in_python = test_dir PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) assert pydevd_file_utils.norm_file_to_server( in_eclipse) == in_python.lower() found_in_eclipse = pydevd_file_utils.norm_file_to_client(in_python) assert found_in_eclipse.endswith('Bar') assert pydevd_file_utils.norm_file_to_server( os.path.join(in_eclipse, 'another')) == os.path.join(in_python, 'another').lower() found_in_eclipse = pydevd_file_utils.norm_file_to_client( os.path.join(in_python, 'another')) assert found_in_eclipse.endswith('Bar\\Another') # Client on unix and server on windows pydevd_file_utils.set_ide_os('UNIX') in_eclipse = '/foo' in_python = test_dir PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) assert pydevd_file_utils.norm_file_to_server( '/foo').lower() == in_python.lower() assert pydevd_file_utils.norm_file_to_client( in_python) == in_eclipse # Test without translation in place (still needs to fix case and separators) pydevd_file_utils.set_ide_os('WINDOWS') PATHS_FROM_ECLIPSE_TO_PYTHON = [] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) assert pydevd_file_utils.norm_file_to_server( test_dir) == test_dir.lower() assert pydevd_file_utils.norm_file_to_client(test_dir).endswith( '\\Foo') else: # Client on windows and server on unix pydevd_file_utils.set_ide_os('WINDOWS') in_eclipse = 'c:\\foo' in_python = '/bar' PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) assert pydevd_file_utils.norm_file_to_server( 'c:\\foo\\my') == '/bar/my' assert pydevd_file_utils.norm_file_to_client( '/bar/my') == 'c:\\foo\\my' # Files for which there's no translation have only their separators updated. assert pydevd_file_utils.norm_file_to_client( '/usr/bin') == '\\usr\\bin' assert pydevd_file_utils.norm_file_to_server( '\\usr\\bin') == '/usr/bin' # Client and server on unix pydevd_file_utils.set_ide_os('UNIX') in_eclipse = '/foo' in_python = '/bar' PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) assert pydevd_file_utils.norm_file_to_server( '/foo/my') == '/bar/my' assert pydevd_file_utils.norm_file_to_client( '/bar/my') == '/foo/my' finally: pydevd_file_utils.setup_client_server_paths([])
def test_to_server_and_to_client(tmpdir): try: def check(obtained, expected): assert obtained == expected, '%s (%s) != %s (%s)' % ( obtained, type(obtained), expected, type(expected)) assert isinstance(obtained, str) # bytes on py2, unicode on py3 assert isinstance(expected, str) # bytes on py2, unicode on py3 import pydevd_file_utils if IS_WINDOWS: # Check with made-up files # Client and server are on windows. pydevd_file_utils.set_ide_os('WINDOWS') for in_eclipse, in_python in ([ ('c:\\foo', 'c:\\bar'), ('c:/foo', 'c:\\bar'), ('c:\\foo', 'c:/bar'), ('c:\\foo', 'c:\\bar\\'), ('c:/foo', 'c:\\bar\\'), ('c:\\foo', 'c:/bar/'), ('c:\\foo\\', 'c:\\bar'), ('c:/foo/', 'c:\\bar'), ('c:\\foo\\', 'c:/bar'), ]): PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) check(pydevd_file_utils.norm_file_to_server('c:\\foo\\my'), 'c:\\bar\\my') check(pydevd_file_utils.norm_file_to_server('c:/foo/my'), 'c:\\bar\\my') check(pydevd_file_utils.norm_file_to_server('c:/foo/my/'), 'c:\\bar\\my') check( pydevd_file_utils.norm_file_to_server( 'c:\\foo\\áéíóú'.upper()), 'c:\\bar\\áéíóú') check(pydevd_file_utils.norm_file_to_client('c:\\bar\\my'), 'c:\\foo\\my') # Client on unix and server on windows pydevd_file_utils.set_ide_os('UNIX') for in_eclipse, in_python in ([ ('/foo', 'c:\\bar'), ('/foo', 'c:/bar'), ('/foo', 'c:\\bar\\'), ('/foo', 'c:/bar/'), ('/foo/', 'c:\\bar'), ('/foo/', 'c:\\bar\\'), ]): PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) check(pydevd_file_utils.norm_file_to_server('/foo/my'), 'c:\\bar\\my') check(pydevd_file_utils.norm_file_to_client('c:\\bar\\my'), '/foo/my') check(pydevd_file_utils.norm_file_to_client('c:\\bar\\my\\'), '/foo/my') check(pydevd_file_utils.norm_file_to_client('c:/bar/my'), '/foo/my') check(pydevd_file_utils.norm_file_to_client('c:/bar/my/'), '/foo/my') # Test with 'real' files # Client and server are on windows. pydevd_file_utils.set_ide_os('WINDOWS') test_dir = str(tmpdir.mkdir("Foo")) os.makedirs(os.path.join(test_dir, "Another")) in_eclipse = os.path.join(os.path.dirname(test_dir), 'Bar') in_python = test_dir PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) assert pydevd_file_utils.norm_file_to_server( in_eclipse) == in_python.lower() found_in_eclipse = pydevd_file_utils.norm_file_to_client(in_python) assert found_in_eclipse.endswith('Bar') assert pydevd_file_utils.norm_file_to_server( os.path.join(in_eclipse, 'another')) == os.path.join(in_python, 'another').lower() found_in_eclipse = pydevd_file_utils.norm_file_to_client( os.path.join(in_python, 'another')) assert found_in_eclipse.endswith('Bar\\Another') # Client on unix and server on windows pydevd_file_utils.set_ide_os('UNIX') in_eclipse = '/foo' in_python = test_dir PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) assert pydevd_file_utils.norm_file_to_server( '/foo').lower() == in_python.lower() assert pydevd_file_utils.norm_file_to_client( in_python) == in_eclipse # Test without translation in place (still needs to fix case and separators) pydevd_file_utils.set_ide_os('WINDOWS') PATHS_FROM_ECLIPSE_TO_PYTHON = [] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) assert pydevd_file_utils.norm_file_to_server( test_dir) == test_dir.lower() assert pydevd_file_utils.norm_file_to_client(test_dir).endswith( '\\Foo') else: # Client on windows and server on unix pydevd_file_utils.set_ide_os('WINDOWS') for in_eclipse, in_python in ([ ('c:\\foo', '/báéíóúr'), ('c:/foo', '/báéíóúr'), ('c:/foo/', '/báéíóúr'), ('c:/foo/', '/báéíóúr/'), ('c:\\foo\\', '/báéíóúr/'), ]): PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) assert pydevd_file_utils.norm_file_to_server( 'c:\\foo\\my') == '/báéíóúr/my' assert pydevd_file_utils.norm_file_to_server( 'C:\\foo\\my') == '/báéíóúr/my' assert pydevd_file_utils.norm_file_to_server( 'C:\\foo\\MY') == '/báéíóúr/MY' assert pydevd_file_utils.norm_file_to_server( 'C:\\foo\\MY\\') == '/báéíóúr/MY' assert pydevd_file_utils.norm_file_to_server( 'c:\\foo\\my\\file.py') == '/báéíóúr/my/file.py' assert pydevd_file_utils.norm_file_to_server( 'c:\\foo\\my\\other\\file.py' ) == '/báéíóúr/my/other/file.py' assert pydevd_file_utils.norm_file_to_server( 'c:/foo/my') == '/báéíóúr/my' assert pydevd_file_utils.norm_file_to_server( 'c:\\foo\\my\\') == '/báéíóúr/my' assert pydevd_file_utils.norm_file_to_server( 'c:/foo/my/') == '/báéíóúr/my' assert pydevd_file_utils.norm_file_to_client( '/báéíóúr/my') == 'c:\\foo\\my' assert pydevd_file_utils.norm_file_to_client( '/báéíóúr/my/') == 'c:\\foo\\my' # Files for which there's no translation have only their separators updated. assert pydevd_file_utils.norm_file_to_client( '/usr/bin/x.py') == '\\usr\\bin\\x.py' assert pydevd_file_utils.norm_file_to_client( '/usr/bin') == '\\usr\\bin' assert pydevd_file_utils.norm_file_to_client( '/usr/bin/') == '\\usr\\bin' assert pydevd_file_utils.norm_file_to_server( '\\usr\\bin') == '/usr/bin' assert pydevd_file_utils.norm_file_to_server( '\\usr\\bin\\') == '/usr/bin' # When we have a client file and there'd be no translation, and making it absolute would # do something as '$cwd/$file_received' (i.e.: $cwd/c:/another in the case below), # warn the user that it's not correct and the path that should be translated instead # and don't make it absolute. assert pydevd_file_utils.norm_file_to_server( 'c:\\another') == 'c:/another' # Client and server on unix pydevd_file_utils.set_ide_os('UNIX') in_eclipse = '/foo' in_python = '/báéíóúr' PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)] pydevd_file_utils.setup_client_server_paths( PATHS_FROM_ECLIPSE_TO_PYTHON) assert pydevd_file_utils.norm_file_to_server( '/foo/my') == '/báéíóúr/my' assert pydevd_file_utils.norm_file_to_client( '/báéíóúr/my') == '/foo/my' finally: pydevd_file_utils.setup_client_server_paths([])