Пример #1
0
        public void Search(RegistryKey root, InterpreterArchitecture assumedArch)
        {
            if (root == null)
            {
                return;
            }

            var companies = GetSubkeys(root);

            foreach (var company in companies)
            {
                if ("PyLauncher".Equals(company, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }
                bool pythonCore = "PythonCore".Equals(company, StringComparison.OrdinalIgnoreCase);

                using (var companyKey = root.OpenSubKey(company)) {
                    if (companyKey == null)
                    {
                        continue;
                    }

                    var companyDisplay    = companyKey.GetValue("DisplayName") as string;
                    var companySupportUrl = companyKey.GetValue("SupportUrl") as string;

                    if (pythonCore)
                    {
                        companyDisplay    = companyDisplay ?? PythonCoreCompanyDisplayName;
                        companySupportUrl = companySupportUrl ?? PythonCoreSupportUrl;
                    }
                    else
                    {
                        companyDisplay = companyDisplay ?? company;
                    }

                    var tags = GetSubkeys(companyKey);
                    foreach (var tag in tags)
                    {
                        using (var tagKey = companyKey.OpenSubKey(tag))
                            using (var installKey = tagKey?.OpenSubKey("InstallPath")) {
                                var config = TryReadConfiguration(company, tag, tagKey, installKey, pythonCore, assumedArch);
                                if (config == null)
                                {
                                    continue;
                                }

                                if (_seenIds.Add(config.Id))
                                {
                                    var supportUrl = tagKey.GetValue("SupportUrl") as string ?? companySupportUrl;

                                    var info = new PythonInterpreterInformation(config, companyDisplay, companySupportUrl, supportUrl);
                                    _info.Add(info);
                                }
                            }
                    }
                }
            }
        }
Пример #2
0
        public void Search(RegistryKey root, InterpreterArchitecture assumedArch)
        {
            if (root == null)
            {
                return;
            }

            var companies = GetSubkeys(root);

            if (companies == null)
            {
                return;
            }

            foreach (var company in companies)
            {
                if ("PyLauncher".Equals(company, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }
                bool pythonCore = PythonCoreCompany.Equals(company, StringComparison.OrdinalIgnoreCase);

                using (var companyKey = root.OpenSubKey(company)) {
                    if (companyKey == null)
                    {
                        continue;
                    }

                    var companyDisplay    = companyKey.GetValue("DisplayName") as string;
                    var companySupportUrl = companyKey.GetValue("SupportUrl") as string;

                    if (pythonCore)
                    {
                        companyDisplay    = companyDisplay ?? PythonCoreCompanyDisplayName;
                        companySupportUrl = companySupportUrl ?? PythonCoreSupportUrl;
                    }
                    else
                    {
                        companyDisplay = companyDisplay ?? company;
                    }

                    var tags = GetSubkeys(companyKey);
                    if (tags == null)
                    {
                        continue;
                    }
                    foreach (var tag in tags)
                    {
                        using (var tagKey = companyKey.OpenSubKey(tag))
                            using (var installKey = tagKey?.OpenSubKey("InstallPath")) {
                                var config = TryReadConfiguration(company, tag, tagKey, installKey, pythonCore, assumedArch);
                                if (config == null)
                                {
                                    continue;
                                }

                                if (_seenIds.Add(config.Id))
                                {
                                    var supportUrl = tagKey.GetValue("SupportUrl") as string ?? companySupportUrl;

                                    // We don't want to send people to http://python.org, even
                                    // if that's what is in the registry, so catch and fix it.
                                    if (!string.IsNullOrEmpty(supportUrl))
                                    {
                                        var url = supportUrl.TrimEnd('/');
                                        if (url.Equals("http://www.python.org", StringComparison.OrdinalIgnoreCase) ||
                                            url.Equals("http://python.org", StringComparison.OrdinalIgnoreCase))
                                        {
                                            supportUrl = PythonCoreSupportUrl;
                                        }
                                    }

                                    var info = new PythonInterpreterInformation(config, companyDisplay, companySupportUrl, supportUrl);
                                    _info.Add(info);
                                }
                            }
                    }
                }
            }
        }
Пример #3
0
        public void Search(RegistryKey root, InterpreterArchitecture assumedArch) {
            if (root == null) {
                return;
            }

            var companies = GetSubkeys(root);
            foreach (var company in companies) {
                if ("PyLauncher".Equals(company, StringComparison.OrdinalIgnoreCase)) {
                    continue;
                }
                bool pythonCore = "PythonCore".Equals(company, StringComparison.OrdinalIgnoreCase);

                using (var companyKey = root.OpenSubKey(company)) {
                    if (companyKey == null) {
                        continue;
                    }

                    var companyDisplay = companyKey.GetValue("DisplayName") as string;
                    var companySupportUrl = companyKey.GetValue("SupportUrl") as string;

                    if (pythonCore) {
                        companyDisplay = companyDisplay ?? PythonCoreCompanyDisplayName;
                        companySupportUrl = companySupportUrl ?? PythonCoreSupportUrl;
                    } else {
                        companyDisplay = companyDisplay ?? company;
                    }

                    var tags = GetSubkeys(companyKey);
                    foreach (var tag in tags) {
                        using (var tagKey = companyKey.OpenSubKey(tag))
                        using (var installKey = tagKey?.OpenSubKey("InstallPath")) {
                            var config = TryReadConfiguration(company, tag, tagKey, installKey, pythonCore, assumedArch);
                            if (config == null) {
                                continue;
                            }

                            if (_seenIds.Add(config.Id)) {
                                var supportUrl = tagKey.GetValue("SupportUrl") as string ?? companySupportUrl;

                                var info = new PythonInterpreterInformation(config, companyDisplay, companySupportUrl, supportUrl);
                                _info.Add(info);
                            }
                        }
                    }
                }
            }
        }