Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1097 Cannot add existing virtualenv when home has no trailing backslash #1127

Merged
merged 2 commits into from
Mar 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Python/Product/VSInterpreters/DerivedInterpreterFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ public static IPythonInterpreterFactory FindBaseInterpreterFromVirtualEnv(
string libPath,
IInterpreterOptionsService service
) {
string basePath = GetOrigPrefixPath(prefixPath, libPath);
string basePath = CommonUtils.TrimEndSeparator(GetOrigPrefixPath(prefixPath, libPath));

if (Directory.Exists(basePath)) {
return service.Interpreters.FirstOrDefault(interp =>
CommonUtils.IsSamePath(interp.Configuration.PrefixPath, basePath)
CommonUtils.IsSamePath(CommonUtils.TrimEndSeparator(interp.Configuration.PrefixPath), basePath)
);
}
return null;
Expand All @@ -298,7 +298,7 @@ public static string GetOrigPrefixPath(string prefixPath, string libPath = null)
.Where(m => m != null && m.Success)
.Select(m => m.Groups["path"])
.Where(g => g != null && g.Success)
.Select(g => g.Value)
.Select(g => g.Value.Trim())
.FirstOrDefault(CommonUtils.IsValidPath);
} catch (IOException) {
} catch (UnauthorizedAccessException) {
Expand All @@ -318,7 +318,7 @@ public static string GetOrigPrefixPath(string prefixPath, string libPath = null)
if (basePath == null && File.Exists(prefixFile)) {
try {
var lines = File.ReadAllLines(prefixFile);
basePath = lines.FirstOrDefault(CommonUtils.IsValidPath);
basePath = (lines.FirstOrDefault(CommonUtils.IsValidPath) ?? string.Empty).Trim();
} catch (IOException) {
} catch (UnauthorizedAccessException) {
} catch (System.Security.SecurityException) {
Expand Down