• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IPythonInterpreterFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IPythonInterpreterFactory的典型用法代码示例。如果您正苦于以下问题:C# IPythonInterpreterFactory类的具体用法?C# IPythonInterpreterFactory怎么用?C# IPythonInterpreterFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IPythonInterpreterFactory类属于命名空间,在下文中一共展示了IPythonInterpreterFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ContinueRun

        private static async Task<int> ContinueRun(
            IPythonInterpreterFactory factory,
            Redirector output,
            bool elevate,
            params string[] cmd
        ) {
            bool isScript;
            var easyInstallPath = GetEasyInstallPath(factory, out isScript);
            if (easyInstallPath == null) {
                throw new FileNotFoundException("Cannot find setuptools ('easy_install.exe')");
            }

            var args = cmd.ToList();
            args.Insert(0, "--always-copy");
            args.Insert(0, "--always-unzip");
            if (isScript) {
                args.Insert(0, ProcessOutput.QuoteSingleArgument(easyInstallPath));
                easyInstallPath = factory.Configuration.InterpreterPath;
            }
            using (var proc = ProcessOutput.Run(
                easyInstallPath,
                args,
                factory.Configuration.PrefixPath,
                UnbufferedEnv,
                false,
                output,
                false,
                elevate
            )) {
                return await proc;
            }
        }
开发者ID:smallwave,项目名称:PTVS,代码行数:32,代码来源:EasyInstall.cs


示例2: EnsureReplWindow

        internal static IVsInteractiveWindow/*!*/ EnsureReplWindow(IServiceProvider serviceProvider, IPythonInterpreterFactory factory, PythonProjectNode project) {
            var compModel = serviceProvider.GetComponentModel();
            var provider = compModel.GetService<InteractiveWindowProvider>();

            string replId = PythonReplEvaluatorProvider.GetReplId(factory, project);
            var window = provider.FindReplWindow(replId);
            if (window == null) {
                window = provider.CreateInteractiveWindow(
                    serviceProvider.GetPythonContentType(),
                    factory.Description + " Interactive",
                    typeof(PythonLanguageInfo).GUID,
                    replId
                );

                var toolWindow = window as ToolWindowPane;
                if (toolWindow != null) {
                    toolWindow.BitmapImageMoniker = KnownMonikers.PYInteractiveWindow;
                }

                var pyService = serviceProvider.GetPythonToolsService();
                window.InteractiveWindow.SetSmartUpDown(pyService.GetInteractiveOptions(factory).ReplSmartHistory);
            }

            if (project != null && project.Interpreters.IsProjectSpecific(factory)) {
                project.AddActionOnClose(window, BasePythonReplEvaluator.CloseReplWindow);
            }

            return window;
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:29,代码来源:ExecuteInReplCommand.cs


示例3: AddFactory

 public void AddFactory(IPythonInterpreterFactory factory) {
     _factories.Add(factory);
     var evt = InterpreterFactoriesChanged;
     if (evt != null) {
         evt(this, EventArgs.Empty);
     }
 }
开发者ID:wenh123,项目名称:PTVS,代码行数:7,代码来源:MockPythonInterpreterFactoryProvider.cs


示例4: AddVirtualEnvironmentView

        public AddVirtualEnvironmentView(
            PythonProjectNode project,
            IInterpreterRegistryService interpreterService,
            IPythonInterpreterFactory selectInterpreter
        ) {
            _interpreterService = interpreterService;
            _project = project;
            VirtualEnvBasePath = _projectHome = project.ProjectHome;
            Interpreters = new ObservableCollection<InterpreterView>(InterpreterView.GetInterpreters(project.Site, project));
            var selection = Interpreters.FirstOrDefault(v => v.Interpreter == selectInterpreter);
            if (selection == null) {
                selection = Interpreters.FirstOrDefault(v => v.Interpreter == project.GetInterpreterFactory())
                    ?? Interpreters.LastOrDefault();
            }
            BaseInterpreter = selection;

            _project.InterpreterFactoriesChanged += OnInterpretersChanged;

            var venvName = "env";
            for (int i = 1; Directory.Exists(Path.Combine(_projectHome, venvName)); ++i) {
                venvName = "env" + i.ToString();
            }
            VirtualEnvName = venvName;

            CanInstallRequirementsTxt = File.Exists(PathUtils.GetAbsoluteFilePath(_projectHome, "requirements.txt"));
            WillInstallRequirementsTxt = CanInstallRequirementsTxt;
        }
开发者ID:RussBaz,项目名称:PTVS,代码行数:27,代码来源:AddVirtualEnvironmentView.cs


示例5: IronPythonAnalysis

 public IronPythonAnalysis(
     IPythonInterpreterFactory factory,
     IPythonInterpreter interpreter = null,
     string builtinName = null
 ) : base(factory, interpreter, builtinName) {
     ((IronPythonInterpreter)Analyzer.Interpreter).Remote.AddAssembly(new ObjectHandle(typeof(IronPythonAnalysisTest).Assembly));
 }
开发者ID:jsschultz,项目名称:PTVS,代码行数:7,代码来源:IronPythonAnalysis.cs


示例6: IsRealInterpreter

 private bool IsRealInterpreter(IPythonInterpreterFactory factory) {
     if (factory == null) {
         return false;
     }
     var interpreterService = _serviceProvider.GetComponentModel().GetService<IInterpreterOptionsService>();
     return interpreterService != null && interpreterService.NoInterpretersValue != factory;
 }
开发者ID:wenh123,项目名称:PTVS,代码行数:7,代码来源:SendToReplCommand.cs


示例7: Save

        public void Save(IPythonInterpreterFactory interpreter) {
            base.Save();
            _pyService.SaveString(_id + InterpreterOptionsSetting, _category, InterpreterOptions ?? "");
            _pyService.SaveBool(_id + EnableAttachSetting, _category, EnableAttach);
            _pyService.SaveString(_id + ExecutionModeSetting, _category, ExecutionMode ?? "");
            _pyService.SaveString(_id + StartupScriptSetting, _category, StartupScript ?? "");
            var replProvider = _serviceProvider.GetComponentModel().GetService<IReplWindowProvider>();
            if (replProvider != null) {
                // propagate changed settings to existing REPL windows
                foreach (var replWindow in replProvider.GetReplWindows()) {
                    PythonReplEvaluator pyEval = replWindow.Evaluator as PythonReplEvaluator;
                    if (EvaluatorUsesThisInterpreter(pyEval, interpreter)) {
                        if (UseInterpreterPrompts) {
                            replWindow.UseInterpreterPrompts();
                        } else {
                            replWindow.SetPrompts(PrimaryPrompt, SecondaryPrompt);
                        }
#if !DEV14_OR_LATER
                        replWindow.SetOptionValue(ReplOptions.DisplayPromptInMargin, !InlinePrompts);
#endif
                        replWindow.SetSmartUpDown(ReplSmartHistory);
                    }
                }
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:25,代码来源:PythonInteractiveOptions.cs


示例8: List

        public static async Task<HashSet<string>> List(IPythonInterpreterFactory factory) {
            using (var proc = Run(factory, null, false, "list")) {
                if (await proc == 0) {
                    return new HashSet<string>(proc.StandardOutputLines
                        .Select(line => Regex.Match(line, "(?<name>.+?) \\((?<version>.+?)\\)"))
                        .Where(match => match.Success)
                        .Select(match => string.Format("{0}=={1}",
                            match.Groups["name"].Value,
                            match.Groups["version"].Value
                        ))
                    );
                }
            }

            // Pip failed, so return a directory listing
            var packagesPath = Path.Combine(factory.Configuration.LibraryPath, "site-packages");
            HashSet<string> result = null;
            if (Directory.Exists(packagesPath)) {
                result = await Task.Run(() => new HashSet<string>(Directory.EnumerateDirectories(packagesPath)
                    .Select(path => Path.GetFileName(path))
                    .Select(name => PackageNameRegex.Match(name))
                    .Where(match => match.Success)
                    .Select(match => match.Groups["name"].Value)
                ))
                    .SilenceException<IOException, HashSet<string>>()
                    .SilenceException<UnauthorizedAccessException, HashSet<string>>()
                    .HandleAllExceptions(SR.ProductName, typeof(Pip));
            }

            return result ?? new HashSet<string>();
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:31,代码来源:Pip.cs


示例9: Run

        private static ProcessOutput Run(
            IPythonInterpreterFactory factory,
            Redirector output,
            bool elevate,
            params string[] cmd
        ) {
            factory.ThrowIfNotRunnable("factory");

            IEnumerable<string> args;
            if (factory.Configuration.Version >= SupportsDashMPip) {
                args = new[] { "-m", "pip" }.Concat(cmd);
            } else {
                // Manually quote the code, since we are passing false to
                // quoteArgs below.
                args = new[] { "-c", "\"import pip; pip.main()\"" }.Concat(cmd);
            }

            return ProcessOutput.Run(
                factory.Configuration.InterpreterPath,
                args,
                factory.Configuration.PrefixPath,
                UnbufferedEnv,
                false,
                output,
                quoteArgs: false,
                elevate: elevate
            );
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:28,代码来源:Pip.cs


示例10: SetDefault

        public void SetDefault(IPythonInterpreterFactory factory) {
            Assert.IsNotNull(factory, "Cannot set default to null");
            var interpreterService = _model.GetService<IInterpreterOptionsService>();
            Assert.IsNotNull(interpreterService);

            CurrentDefault = factory;
            interpreterService.DefaultInterpreter = factory;
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:8,代码来源:DefaultInterpreterSetter.cs


示例11: PythonReplEvaluator

 public PythonReplEvaluator(IPythonInterpreterFactory interpreter, IServiceProvider serviceProvider, PythonReplEvaluatorOptions options, IInterpreterOptionsService interpreterService = null)
     : base(serviceProvider, serviceProvider.GetPythonToolsService(), options) {
     _interpreter = interpreter;
     _interpreterService = interpreterService;
     if (_interpreterService != null) {
         _interpreterService.InterpretersChanged += InterpretersChanged;
     }
 }
开发者ID:smallwave,项目名称:PTVS,代码行数:8,代码来源:PythonReplEvaluator.cs


示例12: TryGetCondaFactoryAsync

        private static async Task<IPythonInterpreterFactory> TryGetCondaFactoryAsync(
            IPythonInterpreterFactory target,
            IInterpreterOptionsService service
        ) {
            var condaMetaPath = CommonUtils.GetAbsoluteDirectoryPath(
                target.Configuration.PrefixPath,
                "conda-meta"
            );

            if (!Directory.Exists(condaMetaPath)) {
                return null;
            }

            string metaFile;
            try {
                metaFile = Directory.EnumerateFiles(condaMetaPath, "*.json").FirstOrDefault();
            } catch (Exception ex) {
                if (ex.IsCriticalException()) {
                    throw;
                }
                return null;
            }

            if (!string.IsNullOrEmpty(metaFile)) {
                string text = string.Empty;
                try {
                    text = File.ReadAllText(metaFile);
                } catch (Exception ex) {
                    if (ex.IsCriticalException()) {
                        throw;
                    }
                }

                var m = Regex.Match(text, @"\{[^{]+link.+?\{.+?""source""\s*:\s*""(.+?)""", RegexOptions.Singleline);
                if (m.Success) {
                    var pkg = m.Groups[1].Value;
                    if (!Directory.Exists(pkg)) {
                        return null;
                    }

                    var prefix = Path.GetDirectoryName(Path.GetDirectoryName(pkg));
                    var factory = service.Interpreters.FirstOrDefault(
                        f => CommonUtils.IsSameDirectory(f.Configuration.PrefixPath, prefix)
                    );

                    if (factory != null && !(await factory.FindModulesAsync("conda")).Any()) {
                        factory = null;
                    }

                    return factory;
                }
            }

            if ((await target.FindModulesAsync("conda")).Any()) {
                return target;
            }
            return null;
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:58,代码来源:Conda.cs


示例13: RemoveFactory

 public bool RemoveFactory(IPythonInterpreterFactory factory) {
     if (_factories.Remove(factory)) {
         var evt = InterpreterFactoriesChanged;
         if (evt != null) {
             evt(this, EventArgs.Empty);
         }
         return true;
     }
     return false;
 }
开发者ID:wenh123,项目名称:PTVS,代码行数:10,代码来源:MockPythonInterpreterFactoryProvider.cs


示例14: DefaultInterpreterSetter

        public DefaultInterpreterSetter(IPythonInterpreterFactory factory) {
            var props = VsIdeTestHostContext.Dte.get_Properties("Python Tools", "Interpreters");
            Assert.IsNotNull(props);

            OriginalInterpreter = props.Item("DefaultInterpreter").Value;
            OriginalVersion = props.Item("DefaultInterpreterVersion").Value;

            props.Item("DefaultInterpreter").Value = factory.Id;
            props.Item("DefaultInterpreterVersion").Value = string.Format("{0}.{1}", factory.Configuration.Version.Major, factory.Configuration.Version.Minor);
        }
开发者ID:sramos30,项目名称:ntvsiot,代码行数:10,代码来源:DefaultInterpreterSetter.cs


示例15: IsEqual

        /// <summary>
        /// Determines whether two interpreter factories are equivalent.
        /// </summary>
        public static bool IsEqual(this IPythonInterpreterFactory x, IPythonInterpreterFactory y) {
            if (x == null || y == null) {
                return x == null && y == null;
            }
            if (x.GetType() != y.GetType()) {
                return false;
            }

            return x.Configuration.Equals(y.Configuration);
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:13,代码来源:PythonInterpreterFactoryExtensions.cs


示例16: DefaultInterpreterSetter

        public DefaultInterpreterSetter(IPythonInterpreterFactory factory, IServiceProvider site = null) {
            Assert.IsNotNull(factory, "Cannot set default to null");
            _model = (IComponentModel)(site ?? VSTestContext.ServiceProvider).GetService(typeof(SComponentModel));
            var interpreterService = _model.GetService<IInterpreterOptionsService>();
            Assert.IsNotNull(interpreterService);

            OriginalInterpreter = interpreterService.DefaultInterpreter;
            CurrentDefault = factory;
            interpreterService.DefaultInterpreter = factory;
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:10,代码来源:DefaultInterpreterSetter.cs


示例17: EnvironmentView

        internal EnvironmentView(
            IInterpreterOptionsService service,
            IInterpreterRegistryService registry,
            IPythonInterpreterFactory factory,
            Redirector redirector
        ) {
            if (service == null) {
                throw new ArgumentNullException(nameof(service));
            }
            if (registry == null) {
                throw new ArgumentNullException(nameof(registry));
            }
            if (factory == null) {
                throw new ArgumentNullException(nameof(factory));
            }
            if (factory.Configuration == null) {
                throw new ArgumentException("factory must include a configuration");
            }

            _service = service;
            _registry = registry;
            Factory = factory;
            Configuration = Factory.Configuration;

            _withDb = factory as IPythonInterpreterFactoryWithDatabase;
            if (_withDb != null) {
                _withDb.IsCurrentChanged += Factory_IsCurrentChanged;
                IsCheckingDatabase = _withDb.IsCheckingDatabase;
                IsCurrent = _withDb.IsCurrent;
            }
            

            if (_service.IsConfigurable(Factory.Configuration.Id)) {
                IsConfigurable = true;
            }

            Description = Factory.Configuration.Description;
            IsDefault = (_service != null && _service.DefaultInterpreterId == Configuration.Id);

            PrefixPath = Factory.Configuration.PrefixPath;
            InterpreterPath = Factory.Configuration.InterpreterPath;
            WindowsInterpreterPath = Factory.Configuration.WindowsInterpreterPath;

            Extensions = new ObservableCollection<object>();
            Extensions.Add(new EnvironmentPathsExtensionProvider());
            if (IsConfigurable) {
                Extensions.Add(new ConfigurationExtensionProvider(_service, alwaysCreateNew: false));
            }

            CanBeDefault = Factory.CanBeDefault();

            Company = _registry.GetProperty(Factory.Configuration.Id, CompanyKey) as string ?? "";
            SupportUrl = _registry.GetProperty(Factory.Configuration.Id, SupportUrlKey) as string ?? "";
        }
开发者ID:zooba,项目名称:PTVS,代码行数:54,代码来源:EnvironmentView.cs


示例18: ShowDialog

 public static InstallPythonPackageView ShowDialog(
     IServiceProvider serviceProvider,
     IPythonInterpreterFactory factory,
     IInterpreterOptionsService service
 ) {
     var wnd = new InstallPythonPackage(serviceProvider, factory, service);
     if (wnd.ShowModal() ?? false) {
         return wnd._view;
     } else {
         return null;
     }
 }
开发者ID:omnimark,项目名称:PTVS,代码行数:12,代码来源:InstallPythonPackage.xaml.cs


示例19: Install

 /// <summary>
 /// Installs virtualenv. If pip is not installed, the returned task will
 /// succeed but error text will be passed to the redirector.
 /// </summary>
 public static Task<bool> Install(IServiceProvider provider, IPythonInterpreterFactory factory, Redirector output = null) {
     bool elevate = provider.GetPythonToolsService().GeneralOptions.ElevatePip;
     if (factory.Configuration.Version < new Version(2, 5)) {
         if (output != null) {
             output.WriteErrorLine("Python versions earlier than 2.5 are not supported by PTVS.");
         }
         throw new OperationCanceledException();
     } else if (factory.Configuration.Version == new Version(2, 5)) {
         return Pip.Install(provider, factory, "https://go.microsoft.com/fwlink/?LinkID=317970", elevate, output);
     } else {
         return Pip.Install(provider, factory, "https://go.microsoft.com/fwlink/?LinkID=317969", elevate, output);
     }
 }
开发者ID:wenh123,项目名称:PTVS,代码行数:17,代码来源:VirtualEnv.cs


示例20: CreateAnalyzer

        public PythonAnalysis CreateAnalyzer(IPythonInterpreterFactory factory = null, bool allowParseErrors = false) {
            var analysis = CreateAnalyzerInternal(factory ?? DefaultFactoryV2);
            analysis.AssertOnParseErrors = !allowParseErrors;
            analysis.ModuleContext = DefaultContext;
            analysis.SetLimits(GetLimits());

            if (_toDispose == null) {
                _toDispose = new List<IDisposable>();
            }
            _toDispose.Add(analysis);

            return analysis;
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:13,代码来源:BaseAnalysisTest.cs



注:本文中的IPythonInterpreterFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IQ类代码示例发布时间:2022-05-24
下一篇:
C# IPublisher类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap