コード例 #1
0
ファイル: Importer.cs プロジェクト: wtf3505-git/ironpython2
        internal static PythonModule TryImportSourceFile(PythonContext /*!*/ context, string /*!*/ name)
        {
            var sourceUnit = TryFindSourceFile(context, name);
            PlatformAdaptationLayer pal = context.DomainManager.Platform;

            if (sourceUnit == null ||
                GetFullPathAndValidateCase(context, pal.CombinePaths(pal.GetDirectoryName(sourceUnit.Path), name + pal.GetExtension(sourceUnit.Path)), false) == null)
            {
                return(null);
            }

            var scope = ExecuteSourceUnit(context, sourceUnit);

            if (sourceUnit.LanguageContext != context)
            {
                // foreign language, we should publish in sys.modules too
                context.SystemStateModules[name] = scope;
            }
            PythonOps.ScopeSetMember(context.SharedContext, sourceUnit.LanguageContext.DomainManager.Globals, name, scope);
            return(scope);
        }