本文整理汇总了C#中PythonProjectNode类的典型用法代码示例。如果您正苦于以下问题:C# PythonProjectNode类的具体用法?C# PythonProjectNode怎么用?C# PythonProjectNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PythonProjectNode类属于命名空间,在下文中一共展示了PythonProjectNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddInterpreter
private AddInterpreter(PythonProjectNode project, IInterpreterOptionsService service) {
_view = new AddInterpreterView(project, project.Site, project.InterpreterFactories);
_view.PropertyChanged += View_PropertyChanged;
DataContext = _view;
InitializeComponent();
}
示例2: AddVirtualEnvironmentView
public AddVirtualEnvironmentView(
PythonProjectNode project,
IInterpreterRegistryService interpreterService,
IPythonInterpreterFactory selectInterpreter
) {
_interpreterService = interpreterService;
_project = project;
VirtualEnvBasePath = _projectHome = project.ProjectHome;
Interpreters = new ObservableCollection<InterpreterView>(InterpreterView.GetInterpreters(project.Site, project));
var selection = Interpreters.FirstOrDefault(v => v.Interpreter == selectInterpreter);
if (selection == null) {
selection = Interpreters.FirstOrDefault(v => v.Interpreter == project.GetInterpreterFactory())
?? Interpreters.LastOrDefault();
}
BaseInterpreter = selection;
_project.InterpreterFactoriesChanged += OnInterpretersChanged;
var venvName = "env";
for (int i = 1; Directory.Exists(Path.Combine(_projectHome, venvName)); ++i) {
venvName = "env" + i.ToString();
}
VirtualEnvName = venvName;
CanInstallRequirementsTxt = File.Exists(PathUtils.GetAbsoluteFilePath(_projectHome, "requirements.txt"));
WillInstallRequirementsTxt = CanInstallRequirementsTxt;
}
示例3: AddInterpreterView
public AddInterpreterView(
PythonProjectNode project,
IServiceProvider serviceProvider,
IEnumerable<IPythonInterpreterFactory> selected
) {
_project = project;
Interpreters = new ObservableCollection<InterpreterView>(InterpreterView.GetInterpreters(serviceProvider, project));
var map = new Dictionary<IPythonInterpreterFactory, InterpreterView>();
foreach (var view in Interpreters) {
map[view.Interpreter] = view;
view.IsSelected = false;
}
foreach (var interp in selected) {
InterpreterView view;
if (map.TryGetValue(interp, out view)) {
view.IsSelected = true;
} else {
view = new InterpreterView(interp, interp.Configuration.FullDescription, false);
view.IsSelected = true;
Interpreters.Add(view);
}
}
_project.InterpreterFactoriesChanged += OnInterpretersChanged;
}
示例4: CustomCommand
private CustomCommand(
PythonProjectNode project,
string target,
string label
) {
_project = project;
_target = target;
_label = string.IsNullOrWhiteSpace(label) ? target : label;
var match = _customCommandLabelRegex.Match(label);
if (match.Success) {
DisplayLabel = LoadResourceFromAssembly(
match.Groups["assembly"].Value,
match.Groups["namespace"].Value,
match.Groups["key"].Value
);
} else {
DisplayLabel = _label;
}
DisplayLabel = PerformSubstitutions(project, DisplayLabel);
_canExecute = !string.IsNullOrEmpty(target);
Verb = "Project." + Regex.Replace(
DisplayLabelWithoutAccessKeys,
"[^a-z0-9]+",
"",
RegexOptions.CultureInvariant | RegexOptions.IgnoreCase
);
AlternateCmdId = AddNamedCommand(project.Site, Verb);
_errorListProvider = new ErrorListProvider(_project.Site);
}
示例5: EnsureReplWindow
internal static IVsInteractiveWindow/*!*/ EnsureReplWindow(IServiceProvider serviceProvider, IPythonInterpreterFactory factory, PythonProjectNode project) {
var compModel = serviceProvider.GetComponentModel();
var provider = compModel.GetService<InteractiveWindowProvider>();
string replId = PythonReplEvaluatorProvider.GetReplId(factory, project);
var window = provider.FindReplWindow(replId);
if (window == null) {
window = provider.CreateInteractiveWindow(
serviceProvider.GetPythonContentType(),
factory.Description + " Interactive",
typeof(PythonLanguageInfo).GUID,
replId
);
var toolWindow = window as ToolWindowPane;
if (toolWindow != null) {
toolWindow.BitmapImageMoniker = KnownMonikers.PYInteractiveWindow;
}
var pyService = serviceProvider.GetPythonToolsService();
window.InteractiveWindow.SetSmartUpDown(pyService.GetInteractiveOptions(factory).ReplSmartHistory);
}
if (project != null && project.Interpreters.IsProjectSpecific(factory)) {
project.AddActionOnClose(window, BasePythonReplEvaluator.CloseReplWindow);
}
return window;
}
示例6: PythonExtensionReferenceNode
internal PythonExtensionReferenceNode(PythonProjectNode root, ProjectElement element, string filename)
: base(root, element) {
Utilities.ArgumentNotNullOrEmpty("filename", filename);
_filename = CommonUtils.GetAbsoluteFilePath(root.ProjectHome, filename);
AnalyzeReference(root.GetInterpreter() as IPythonInterpreterWithProjectReferences);
InitializeFileChangeEvents();
}
示例7: ShowDialog
public static IEnumerable<IPythonInterpreterFactory> ShowDialog(
PythonProjectNode project,
IInterpreterOptionsService service) {
using (var wnd = new AddInterpreter(project, service)) {
if (wnd.ShowModal() ?? false) {
return wnd._view.Interpreters.Where(iv => iv.IsSelected).Select(iv => iv.Interpreter);
}
}
return null;
}
示例8: OpenProject
internal void OpenProject(VisualStudioApp app, string slnName, out PythonProjectNode projectNode, out EnvDTE.Project dteProject) {
PythonVersion.AssertInstalled();
dteProject = app.OpenProject("TestData\\Targets\\" + slnName);
projectNode = dteProject.GetPythonProject();
var fact = projectNode.InterpreterFactories.Where(x => x.Configuration.Id == PythonVersion.Id).FirstOrDefault();
Assert.IsNotNull(fact, "Project does not contain expected interpreter");
projectNode.ActiveInterpreter = fact;
dteProject.Save();
}
示例9: InterpretersPackageNode
public InterpretersPackageNode(PythonProjectNode project, PackageSpec spec)
: base(project, new VirtualProjectElement(project)) {
ExcludeNodeFromScc = true;
_package = spec.Clone();
_packageName = spec.FullSpec;
if (spec.ExactVersion.IsEmpty) {
_caption = spec.Name;
_canUninstall = false;
} else {
_caption = string.Format("{0} ({1})", spec.Name, spec.ExactVersion);
_canUninstall = !CannotUninstall.Contains(spec.Name);
}
}
示例10: UpdateProject
public void UpdateProject(PythonProjectNode node, MSBuild.Project project) {
lock (_projects) {
if (project == null) {
_projects.Remove(node);
} else if (!_projects.ContainsKey(node) || _projects[node] != project) {
_projects[node] = project;
}
}
// Always raise the event, this also occurs when we're adding projects
// to the MSBuild.Project.
ProjectsChanaged?.Invoke(this, EventArgs.Empty);
}
示例11: EnsureReplWindow
internal static IVsInteractiveWindow/*!*/ EnsureReplWindow(IServiceProvider serviceProvider, InterpreterConfiguration config, PythonProjectNode project) {
var compModel = serviceProvider.GetComponentModel();
var provider = compModel.GetService<InteractiveWindowProvider>();
var vsProjectContext = compModel.GetService<VsProjectContextProvider>();
string replId = config != null ?
PythonReplEvaluatorProvider.GetEvaluatorId(config) :
PythonReplEvaluatorProvider.GetEvaluatorId(project);
var window = provider.OpenOrCreate(replId);
project?.AddActionOnClose(window, InteractiveWindowProvider.Close);
return window;
}
示例12: InterpretersPackageNode
public InterpretersPackageNode(PythonProjectNode project, string name)
: base(project, new VirtualProjectElement(project)) {
ExcludeNodeFromScc = true;
_packageName = name;
var match = PipFreezeRegex.Match(name);
if (match.Success) {
var namePart = match.Groups["name"].Value;
_caption = string.Format("{0} ({1})", namePart, match.Groups["version"]);
_canUninstall = !CannotUninstall.Contains(namePart);
} else {
_caption = name;
_canUninstall = false;
}
}
示例13: AddVirtualEnvironmentOperation
public AddVirtualEnvironmentOperation(
PythonProjectNode project,
string virtualEnvPath,
IPythonInterpreterFactory baseInterpreter,
bool create,
bool useVEnv,
bool installRequirements,
Redirector output = null
) {
_project = project;
_virtualEnvPath = virtualEnvPath;
_baseInterpreter = baseInterpreter;
_create = create;
_useVEnv = useVEnv;
_installRequirements = installRequirements;
_output = output;
}
示例14: EnsureReplWindow
internal static IVsInteractiveWindow/*!*/ EnsureReplWindow(IServiceProvider serviceProvider, InterpreterConfiguration config, PythonProjectNode project) {
var compModel = serviceProvider.GetComponentModel();
var provider = compModel.GetService<InteractiveWindowProvider>();
var vsProjectContext = compModel.GetService<VsProjectContextProvider>();
var projectId = project != null ? PythonReplEvaluatorProvider.GetEvaluatorId(project) : null;
var configId = config != null ? PythonReplEvaluatorProvider.GetEvaluatorId(config) : null;
IVsInteractiveWindow window;
// If we find an open window for the project, prefer that to a per-config one
if (!string.IsNullOrEmpty(projectId)) {
window = provider.Open(projectId);
if (window != null) {
if (window.InteractiveWindow.GetPythonEvaluator()?.AssociatedProjectHasChanged == true) {
// We have an existing window, but it needs to be reset.
// Let's create a new one
window = provider.Create(projectId);
project.AddActionOnClose(window, InteractiveWindowProvider.Close);
}
return window;
}
}
// If we find an open window for the configuration, return that
if (!string.IsNullOrEmpty(configId)) {
window = provider.Open(configId);
if (window != null) {
return window;
}
}
// No window found, so let's create one
if (!string.IsNullOrEmpty(projectId)) {
window = provider.Create(projectId);
project.AddActionOnClose(window, InteractiveWindowProvider.Close);
} else if (!string.IsNullOrEmpty(configId)) {
window = provider.Create(configId);
} else {
var interpService = compModel.GetService<IInterpreterOptionsService>();
window = provider.Create(PythonReplEvaluatorProvider.GetEvaluatorId(interpService.DefaultInterpreter.Configuration));
}
return window;
}
示例15: InterpretersNode
public InterpretersNode(
PythonProjectNode project,
ProjectItem item,
IPythonInterpreterFactory factory,
bool isInterpreterReference,
bool canDelete,
bool isGlobalDefault = false
)
: base(project, ChooseElement(project, item)) {
ExcludeNodeFromScc = true;
_interpreters = project.Interpreters;
_interpreterService = project.Site.GetComponentModel().GetService<IInterpreterOptionsService>();
_factory = factory;
_isReference = isInterpreterReference;
_canDelete = canDelete;
_isGlobalDefault = isGlobalDefault;
_canRemove = !isGlobalDefault;
_captionSuffix = isGlobalDefault ? SR.GetString(SR.GlobalDefaultSuffix) : "";
if (Directory.Exists(_factory.Configuration.LibraryPath)) {
// TODO: Need to handle watching for creation
try {
_fileWatcher = new FileSystemWatcher(_factory.Configuration.LibraryPath);
} catch (ArgumentException) {
// Path was not actually valid, despite Directory.Exists
// returning true.
}
if (_fileWatcher != null) {
try {
_fileWatcher.IncludeSubdirectories = true;
_fileWatcher.Deleted += PackagesChanged;
_fileWatcher.Created += PackagesChanged;
_fileWatcher.EnableRaisingEvents = true;
// Only create the timer if the file watcher is running.
_timer = new Timer(CheckPackages);
} catch (IOException) {
// Raced with directory deletion
_fileWatcher.Dispose();
_fileWatcher = null;
}
}
}
}