MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / _map_file_to_server

Function _map_file_to_server

pydevd_file_utils.py:783–835  ·  view source on GitHub ↗
(filename, cache=norm_filename_to_server_container)

Source from the content-addressed store, hash-verified

781
782 # only setup translation functions if absolutely needed!
783 def _map_file_to_server(filename, cache=norm_filename_to_server_container):
784 # Eclipse will send the passed filename to be translated to the python process
785 # So, this would be 'NormFileFromEclipseToPython'
786 try:
787 return cache[filename]
788 except KeyError:
789 if eclipse_sep != python_sep:
790 # Make sure that the separators are what we expect from the IDE.
791 filename = filename.replace(python_sep, eclipse_sep)
792
793 # used to translate a path from the client to the debug server
794 translated = filename
795 translated_normalized = _normcase_from_client(filename)
796 for eclipse_prefix, server_prefix in paths_from_eclipse_to_python:
797 if translated_normalized.startswith(eclipse_prefix):
798 found_translation = True
799 if DEBUG_CLIENT_SERVER_TRANSLATION:
800 pydev_log.critical("pydev debugger: replacing to server: %s", filename)
801 translated = server_prefix + filename[len(eclipse_prefix) :]
802 if DEBUG_CLIENT_SERVER_TRANSLATION:
803 pydev_log.critical("pydev debugger: sent to server: %s - matched prefix: %s", translated, eclipse_prefix)
804 break
805 else:
806 found_translation = False
807
808 # Note that when going to the server, we do the replace first and only later do the norm file.
809 if eclipse_sep != python_sep:
810 translated = translated.replace(eclipse_sep, python_sep)
811
812 if found_translation:
813 # Note: we don't normalize it here, this must be done as a separate
814 # step by the caller.
815 translated = absolute_path(translated)
816 else:
817 if not os_path_exists(translated):
818 if not translated.startswith("<"):
819 # This is a configuration error, so, write it always so
820 # that the user can fix it.
821 error_once(
822 'pydev debugger: unable to find translation for: "%s" in [%s] (please revise your path mappings).\n',
823 filename,
824 ", ".join(['"%s"' % (x[0],) for x in paths_from_eclipse_to_python]),
825 )
826 else:
827 # It's possible that we had some round trip (say, we sent /usr/lib and received
828 # it back, so, having no translation is ok too).
829
830 # Note: we don't normalize it here, this must be done as a separate
831 # step by the caller.
832 translated = absolute_path(translated)
833
834 cache[filename] = translated
835 return translated
836
837 def _map_file_to_client(filename, cache=norm_filename_to_client_container):
838 # The result of this method will be passed to eclipse

Callers

nothing calls this directly

Calls 3

error_onceFunction · 0.90
absolute_pathFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected