private IEnumerable <IAnalysisItemView> CalculateChildren() { if (_module == null) { _module = _interpreter.ImportModule(Name); } if (File.Exists(_idbPath)) { yield return(RawView.FromFile(_idbPath)); } var cpm = _module as Interpreter.LegacyDB.CPythonModule; if (cpm != null) { cpm.EnsureLoaded(); } if (cpm != null && cpm._hiddenMembers != null) { foreach (var keyValue in cpm._hiddenMembers) { yield return(MemberView.Make(_context, keyValue.Key, keyValue.Value)); } } foreach (var memberName in _module.GetMemberNames(_context)) { yield return(MemberView.Make(_context, _module, memberName)); } }
private async Task HandleModuleImportStarAsync(IPythonModule module, CancellationToken cancellationToken = default) { foreach (var memberName in module.GetMemberNames()) { cancellationToken.ThrowIfCancellationRequested(); var member = module.GetMember(memberName); if (member == null) { Log?.Log(TraceEventType.Verbose, $"Undefined import: {module.Name}, {memberName}"); } else if (member.MemberType == PythonMemberType.Unknown) { Log?.Log(TraceEventType.Verbose, $"Unknown import: {module.Name}, {memberName}"); } member = member ?? Eval.UnknownType; if (member is IPythonModule m) { await ModuleResolution.ImportModuleAsync(m.Name, cancellationToken); } Eval.DeclareVariable(memberName, member, module.Location); } }
private static IEnumerable <IPythonType> GetTestCaseClasses(IPythonModule module, IModuleContext context) { foreach (var name in module.GetMemberNames(context)) { if (module.GetMember(context, name) is IPythonType cls) { foreach (var baseCls in cls.Mro.MaybeEnumerate()) { if (baseCls.Name == "TestCase" || baseCls.Name.StartsWithOrdinal("unittest.") && baseCls.Name.EndsWithOrdinal(".TestCase")) { yield return(cls); } } } } }