MCPcopy Index your code
hub / github.com/fabioz/PyDev.Debugger / _map_file_to_client

Function _map_file_to_client

pydevd_file_utils.py:837–895  ·  view source on GitHub ↗
(filename, cache=norm_filename_to_client_container)

Source from the content-addressed store, hash-verified

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
839 # So, this would be 'NormFileFromPythonToEclipse'
840 try:
841 return cache[filename]
842 except KeyError:
843 abs_path = absolute_path(filename)
844 translated_proper_case = get_path_with_real_case(abs_path)
845 translated_normalized = normcase(abs_path)
846
847 path_mapping_applied = False
848
849 if translated_normalized.lower() != translated_proper_case.lower():
850 if DEBUG_CLIENT_SERVER_TRANSLATION:
851 pydev_log.critical(
852 "pydev debugger: translated_normalized changed path (from: %s to %s)", translated_proper_case, translated_normalized
853 )
854
855 for i, (eclipse_prefix, python_prefix) in enumerate(paths_from_eclipse_to_python):
856 if translated_normalized.startswith(python_prefix):
857 if DEBUG_CLIENT_SERVER_TRANSLATION:
858 pydev_log.critical("pydev debugger: replacing to client: %s", translated_normalized)
859
860 # Note: use the non-normalized version.
861 eclipse_prefix = initial_paths[i][0]
862 translated = eclipse_prefix + translated_proper_case[len(python_prefix) :]
863 if DEBUG_CLIENT_SERVER_TRANSLATION:
864 pydev_log.critical("pydev debugger: sent to client: %s - matched prefix: %s", translated, python_prefix)
865 path_mapping_applied = True
866 break
867 else:
868 if DEBUG_CLIENT_SERVER_TRANSLATION:
869 pydev_log.critical(
870 "pydev debugger: to client: unable to find matching prefix for: %s in %s",
871 translated_normalized,
872 [x[1] for x in paths_from_eclipse_to_python],
873 )
874 translated = translated_proper_case
875
876 if eclipse_sep != python_sep:
877 translated = translated.replace(python_sep, eclipse_sep)
878
879 translated = _path_to_expected_str(translated)
880
881 # The resulting path is not in the python process, so, we cannot do a normalize the path here,
882 # only at the beginning of this method.
883 cache[filename] = (translated, path_mapping_applied)
884
885 if translated not in _client_filename_in_utf8_to_source_reference:
886 if path_mapping_applied:
887 source_reference = 0
888 else:
889 source_reference = _next_source_reference()
890 pydev_log.debug("Created source reference: %s for untranslated path: %s", source_reference, filename)
891
892 _client_filename_in_utf8_to_source_reference[translated] = source_reference
893 _source_reference_to_server_filename[source_reference] = filename
894

Callers

nothing calls this directly

Calls 4

absolute_pathFunction · 0.85
get_path_with_real_caseFunction · 0.85
normcaseFunction · 0.85
_path_to_expected_strFunction · 0.85

Tested by

no test coverage detected