public IEnumerable <PythonPackage> FindInstalledPackages(string name, string required_version, Request request) { /* FIXME: optimize if name and required_version are specified. */ string path = global_site_folder; string name_wc = string.IsNullOrWhiteSpace(name) ? "*" : name; string version_wc = string.IsNullOrWhiteSpace(required_version) ? "*" : required_version; request.Debug("Python::FindInstalledPackages searching {0}", path); foreach (string dir in Directory.EnumerateDirectories(path, string.Format("{0}-{1}.dist-info", name_wc, version_wc))) { request.Debug("Python::FindInstalledPackages trying {0}", dir); PythonPackage result = PythonPackage.FromDistInfo(dir, this, request); if (result != null) { if (!string.IsNullOrWhiteSpace(name) && !result.MatchesName(name)) { continue; } yield return(result); } } foreach (string dir in Directory.EnumerateDirectories(path, string.Format("{0}-{1}-*.egg-info", name_wc, version_wc))) { request.Debug("Python::FindInstalledPackages trying {0}", dir); PythonPackage result = PythonPackage.FromEggInfo(dir, this, request); if (result != null) { if (!string.IsNullOrWhiteSpace(name) && !result.MatchesName(name)) { continue; } yield return(result); } } }