Class PipfileLockParser

java.lang.Object
org.openrewrite.python.internal.PipfileLockParser

public class PipfileLockParser extends Object
Parses Pipfile.lock files (JSON format) to extract resolved dependency information.

Pipfile.lock has the shape:

 {
   "_meta": { "sources": [...], "requires": {...} },
   "default": { "requests": { "version": "==2.28.0", ... } },
   "develop": { "pytest":   { "version": "==7.0.0",  ... } }
 }
 
  • Constructor Details

    • PipfileLockParser

      public PipfileLockParser()
  • Method Details

    • findAndParse

      public static List<PythonResolutionResult.ResolvedDependency> findAndParse(Path pipfileDir, @Nullable Path boundary)
      Find and parse a Pipfile.lock file, walking up from the given directory.
      Parameters:
      pipfileDir - the directory containing Pipfile
      boundary - the boundary to stop searching at (typically relativeTo)
      Returns:
      list of resolved dependencies, or empty list if no Pipfile.lock found
    • parse

      public static List<PythonResolutionResult.ResolvedDependency> parse(String content)
      Parse Pipfile.lock content into a list of resolved dependencies. Entries from default appear before entries from develop.