#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

77 lines
1.6 KiB

// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using System.Security;
using Microsoft.Win32;
namespace ICSharpCode.PythonBinding
{
public class PythonStandardLibraryPath
{
List<string> directories = new List<string>();
string path = String.Empty;
public PythonStandardLibraryPath(string path)
{
Path = path;
}
public PythonStandardLibraryPath()
{
ReadPathFromRegistry();
}
void ReadPathFromRegistry()
{
try {
using (RegistryKey registryKey = GetPythonLibraryRegistryKey()) {
if (registryKey != null) {
Path = (string)registryKey.GetValue(String.Empty, String.Empty);
}
}
} catch (SecurityException) {
} catch (UnauthorizedAccessException) {
} catch (IOException) {
}
}
RegistryKey GetPythonLibraryRegistryKey()
{
return Registry.LocalMachine.OpenSubKey(@"Software\Python\PythonCore\2.6\PythonPath");
}
public string[] Directories {
get { return directories.ToArray(); }
}
public string Path {
get { return path; }
set {
path = value;
ReadDirectories();
}
}
void ReadDirectories()
{
directories.Clear();
foreach (string item in path.Split(';')) {
string directory = item.Trim();
if (!String.IsNullOrEmpty(directory)) {
directories.Add(directory);
}
}
}
public bool HasPath {
get { return directories.Count > 0; }
}
}
}