private IEnumerable <PythonEvaluationResult> GetDebugChildrenFromDict(PyDictObject dict) { foreach (var pair in dict.ReadElements()) { IPyBaseStringObject name = pair.Key as IPyBaseStringObject; if (name != null && !pair.Value.IsNull) { yield return(new PythonEvaluationResult(pair.Value, name.ToString())); } } }
private void LoadInitialPythonModules() { foreach (var interp in PyInterpreterState.GetInterpreterStates(_process)) { var modules = interp.modules.TryRead(); if (modules == null) { continue; } foreach (var moduleEntry in modules.ReadElements()) { PyModuleObject module = moduleEntry.Value.TryRead() as PyModuleObject; if (module == null) { continue; } PyDictObject md_dict = module.md_dict.TryRead(); if (md_dict == null) { continue; } foreach (var entry in md_dict.ReadElements()) { var name = (entry.Key as IPyBaseStringObject).ToStringOrNull(); if (name == "__file__") { var fileName = (entry.Value.TryRead() as IPyBaseStringObject).ToStringOrNull(); if (fileName != null && !fileName.EndsWithOrdinal(".pyd", ignoreCase: true)) { // Unlike co_filename, __file__ usually reflects the actual name of the file from which the module // was created, which will be .pyc rather than .py if it was available, so fix that up. if (fileName.EndsWithOrdinal(".pyc", ignoreCase: true)) { fileName = fileName.Substring(0, fileName.Length - 1); } new RemoteComponent.CreateModuleRequest { ModuleId = Guid.NewGuid(), FileName = fileName }.SendLower(_process); } } } } } }