Esempio n. 1
0
        private bool TryImportExternal(string baseName, string name, out Inferred inferred)
        {
            string path = Path.GetDirectoryName(baseName);
            string file = Path.Combine(path, name + ".py");

            Module module;

            if (!modules.TryGetValue(file, out module))
            {
                StreamReader sr = null;
                try {
                    sr = new StreamReader(file);
                } catch {
                    inferred = null;
                    return(false);
                }

                using (sr) {
                    string text = sr.ReadToEnd();
                    module = AnalyzeModule(new QuietCompilerSink(), file, text);
                }
            }

            inferred = new InferredModule(module.ModuleScope);
            return(true);
        }
        private bool TryImportExternal(string baseName, string name, out Inferred inferred)
        {
            string path = Path.GetDirectoryName(baseName);
            string file = Path.Combine(path, name + ".py");

            Module module;
            if (!modules.TryGetValue(file, out module)) {
                StreamReader sr = null;
                try {
                    sr = new StreamReader(file);
                } catch {
                    inferred = null;
                    return false;
                }

                using (sr) {
                    string text = sr.ReadToEnd();
                    module = AnalyzeModule(new QuietCompilerSink(), file, text);
                }
            }

            inferred = new InferredModule(module.ModuleScope);
            return true;
        }