Class RequirementsTxtParser

java.lang.Object
org.openrewrite.python.RequirementsTxtParser
All Implemented Interfaces:
org.openrewrite.Parser

public class RequirementsTxtParser extends Object implements org.openrewrite.Parser
Parser for requirements.txt files that delegates to PlainTextParser and attaches a PythonResolutionResult marker with dependency metadata resolved via uv pip freeze.
  • Constructor Details

    • RequirementsTxtParser

      public RequirementsTxtParser()
    • RequirementsTxtParser

      public RequirementsTxtParser(Map<String,String> subprocessEnvironment)
  • Method Details

    • parseInputs

      public Stream<org.openrewrite.SourceFile> parseInputs(Iterable<org.openrewrite.Parser.Input> sources, @Nullable Path relativeTo, org.openrewrite.ExecutionContext ctx)
      Specified by:
      parseInputs in interface org.openrewrite.Parser
    • parseFreezeOutput

      public static List<PythonResolutionResult.ResolvedDependency> parseFreezeOutput(Path workspace)
    • dependenciesFromResolved

      public static List<PythonResolutionResult.Dependency> dependenciesFromResolved(List<PythonResolutionResult.ResolvedDependency> resolved)
      Convert resolved dependencies into declared (direct) dependencies. When the dependency graph has been linked (via linkDependenciesFromMetadata(java.util.List<org.openrewrite.python.marker.PythonResolutionResult.ResolvedDependency>, java.nio.file.Path)), only root packages (those not depended on by any other package) are included. When the graph is unlinked (all dependencies fields are null), all packages are treated as direct so that client code traversing getDependencies() finds every package.
    • dependenciesFromResolved

      public static List<PythonResolutionResult.Dependency> dependenciesFromResolved(List<PythonResolutionResult.ResolvedDependency> resolved, Set<String> declaredPackageNames)
    • accept

      public boolean accept(Path path)
      Specified by:
      accept in interface org.openrewrite.Parser
    • sourcePathFromSourceText

      public Path sourcePathFromSourceText(Path prefix, String sourceCode)
      Specified by:
      sourcePathFromSourceText in interface org.openrewrite.Parser
    • builder

      public static RequirementsTxtParser.Builder builder()