本文整理汇总了C#中PythonLanguageVersion.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# PythonLanguageVersion.ToString方法的具体用法?C# PythonLanguageVersion.ToString怎么用?C# PythonLanguageVersion.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonLanguageVersion
的用法示例。
在下文中一共展示了PythonLanguageVersion.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCPythonVersion
private static PythonVersion GetCPythonVersion(PythonLanguageVersion version, bool x64 = false) {
if (!x64) {
foreach (var baseKey in new[] { Registry.LocalMachine, Registry.CurrentUser }) {
using (var python = baseKey.OpenSubKey(PythonCorePath)) {
var res = TryGetCPythonPath(version, python, x64);
if (res != null) {
return res;
}
}
}
}
if (Environment.Is64BitOperatingSystem && x64) {
foreach (var baseHive in new[] { RegistryHive.LocalMachine, RegistryHive.CurrentUser }) {
var python64 = RegistryKey.OpenBaseKey(baseHive, RegistryView.Registry64).OpenSubKey(PythonCorePath);
var res = TryGetCPythonPath(version, python64, x64);
if (res != null) {
return res;
}
}
}
var path = "C:\\Python" + version.ToString().Substring(1) + "\\python.exe";
var arch = NativeMethods.GetBinaryType(path);
if (arch == ProcessorArchitecture.X86 && !x64) {
return new PythonVersion(path, version, CPythonGuid);
} else if (arch == ProcessorArchitecture.Amd64 && x64) {
return new PythonVersion(path, version, CPython64Guid);
}
if (x64) {
path = "C:\\Python" + version.ToString().Substring(1) + "_x64\\python.exe";
arch = NativeMethods.GetBinaryType(path);
if (arch == ProcessorArchitecture.Amd64) {
return new PythonVersion(path, version, CPython64Guid);
}
}
return null;
}
示例2: Create
/// <summary>
/// Creates a database containing the default modules and any overrides
/// specified in modules. The overrides will be copied from
/// TestData\Databases\Vxx, where Vxx is taken from the provided
/// version number.
///
/// Each tuple in modules specifies the source filename and destination
/// filename, respectively.
/// </summary>
public static MockCompletionDB Create(PythonLanguageVersion version, params Tuple<string, string>[] modules) {
var source1 = PythonTypeDatabase.BaselineDatabasePath;
var source2 = TestData.GetPath(Path.Combine("TestData", "Databases", version.ToString()));
Assert.IsTrue(Directory.Exists(source1), "Cannot find " + source1);
Assert.IsTrue(Directory.Exists(source2), "Cannot find " + source2);
var db = new MockCompletionDB(TestData.GetTempPath(randomSubPath: true), version);
Assert.IsNotNull(db, "Unable to create DB path");
Console.WriteLine("Creating temporary database at {0}", db.DBPath);
foreach (var src in Directory.EnumerateFiles(source1, "*.idb")) {
File.Copy(src, Path.Combine(db.DBPath, Path.GetFileName(src)));
}
foreach (var mod in modules) {
var src = Path.Combine(source2, mod.Item1 + ".idb");
Assert.IsTrue(File.Exists(src), "No IDB file for " + mod.Item1);
Console.WriteLine("Copying {0} from {1} as {2}", mod.Item1, src, mod.Item2);
File.Copy(src, Path.Combine(db.DBPath, mod.Item2 + ".idb"), true);
Assert.IsTrue(db.Contains(mod.Item2), "Failed to copy module " + mod.Item1);
}
File.WriteAllText(Path.Combine(db.DBPath, "database.ver"),
PythonTypeDatabase.CurrentVersion.ToString());
return db;
}
示例3: TryGetCPythonPath
private static PythonVersion TryGetCPythonPath(PythonLanguageVersion version, RegistryKey python, bool x64) {
if (python != null) {
string versionStr = version.ToString().Substring(1);
versionStr = versionStr[0] + "." + versionStr[1];
if (!x64 && version >= PythonLanguageVersion.V35) {
versionStr += "-32";
}
using (var versionKey = python.OpenSubKey(versionStr + "\\InstallPath")) {
if (versionKey != null) {
var installPath = versionKey.GetValue("");
if (installPath != null) {
var path = Path.Combine(installPath.ToString(), "python.exe");
var arch = NativeMethods.GetBinaryType(path);
if (arch == ProcessorArchitecture.X86) {
return x64 ? null : new PythonVersion(path, version, CPythonGuid);
} else if (arch == ProcessorArchitecture.Amd64) {
return x64 ? new PythonVersion(path, version, CPython64Guid) : null;
} else {
return null;
}
}
}
}
}
return null;
}