Skip to content

Commit

Permalink
Users/oakeredolu/newpipservice (#683)
Browse files Browse the repository at this point in the history
Created new PythonResolver for SimplePypiClient
  • Loading branch information
Omotola committed Aug 1, 2023
1 parent d968c32 commit 838766b
Show file tree
Hide file tree
Showing 6 changed files with 807 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Microsoft.ComponentDetection.Detectors.Pip;

using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.ComponentDetection.Contracts;

public interface ISimplePythonResolver
{
/// <summary>
/// Resolves the root Python packages from the initial list of packages.
/// </summary>
/// <param name="singleFileComponentRecorder">The component recorder for file that is been processed.</param>
/// <param name="initialPackages">The initial list of packages.</param>
/// <returns>The root packages, with dependencies associated as children.</returns>
Task<IList<PipGraphNode>> ResolveRootsAsync(ISingleFileComponentRecorder singleFileComponentRecorder, IList<PipDependencySpecification> initialPackages);
}
14 changes: 1 addition & 13 deletions src/Microsoft.ComponentDetection.Detectors/pip/PythonResolver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.ComponentDetection.Detectors.Pip;
namespace Microsoft.ComponentDetection.Detectors.Pip;

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -216,16 +216,4 @@ private void AddGraphNode(PythonResolverState state, PipGraphNode parent, string
node.Parents.Add(parent);
}
}

private class PythonResolverState
{
public IDictionary<string, SortedDictionary<string, IList<PythonProjectRelease>>> ValidVersionMap { get; }
= new Dictionary<string, SortedDictionary<string, IList<PythonProjectRelease>>>(StringComparer.OrdinalIgnoreCase);

public Queue<(string PackageName, PipDependencySpecification Package)> ProcessingQueue { get; } = new Queue<(string, PipDependencySpecification)>();

public IDictionary<string, PipGraphNode> NodeReferences { get; } = new Dictionary<string, PipGraphNode>(StringComparer.OrdinalIgnoreCase);

public IList<PipGraphNode> Roots { get; } = new List<PipGraphNode>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Microsoft.ComponentDetection.Detectors.Pip;

using System;
using System.Collections.Generic;

public class PythonResolverState
{
public IDictionary<string, SortedDictionary<string, IList<PythonProjectRelease>>> ValidVersionMap { get; }
= new Dictionary<string, SortedDictionary<string, IList<PythonProjectRelease>>>(StringComparer.OrdinalIgnoreCase);

public Queue<(string PackageName, PipDependencySpecification Package)> ProcessingQueue { get; } = new Queue<(string, PipDependencySpecification)>();

public IDictionary<string, PipGraphNode> NodeReferences { get; } = new Dictionary<string, PipGraphNode>(StringComparer.OrdinalIgnoreCase);

public IList<PipGraphNode> Roots { get; } = new List<PipGraphNode>();
}
Loading

0 comments on commit 838766b

Please sign in to comment.