Package org.openrewrite.python.internal
Class PyProjectHelper
java.lang.Object
org.openrewrite.python.internal.PyProjectHelper
Shared utilities for Python dependency recipes operating on pyproject.toml files.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcorrespondingPyprojectPath(String uvLockPath) Derive the pyproject.toml path that corresponds to a uv.lock path.static @Nullable StringextractPackageName(String pep508Spec) Extract the package name from a PEP 508 dependency spec string.static booleanisInsideProjectDependencies(org.openrewrite.Cursor cursor) Check whether a cursor path represents a position inside the[project].dependenciesarray in a pyproject.toml.static org.openrewrite.toml.tree.Toml.DocumentregenerateLockAndRefreshMarker(org.openrewrite.toml.tree.Toml.Document updated, Map<String, String> updatedLockFiles) After modifying a pyproject.toml document, regenerate the uv.lock file and refresh thePythonResolutionResultmarker.static org.openrewrite.toml.tree.Toml.DocumentreparseToml(org.openrewrite.toml.tree.Toml.Document original, String newContent) Reparse a TOML document from new content while preserving the original document's identity (id) and markers.
-
Constructor Details
-
PyProjectHelper
public PyProjectHelper()
-
-
Method Details
-
extractPackageName
Extract the package name from a PEP 508 dependency spec string. The name is the first token before any version specifier, extras, or marker. -
correspondingPyprojectPath
Derive the pyproject.toml path that corresponds to a uv.lock path. -
reparseToml
public static org.openrewrite.toml.tree.Toml.Document reparseToml(org.openrewrite.toml.tree.Toml.Document original, String newContent) Reparse a TOML document from new content while preserving the original document's identity (id) and markers. -
regenerateLockAndRefreshMarker
public static org.openrewrite.toml.tree.Toml.Document regenerateLockAndRefreshMarker(org.openrewrite.toml.tree.Toml.Document updated, Map<String, String> updatedLockFiles) After modifying a pyproject.toml document, regenerate the uv.lock file and refresh thePythonResolutionResultmarker. Returns the updated document.- Parameters:
updated- the modified pyproject.toml documentupdatedLockFiles- map to store regenerated lock content keyed by pyproject path- Returns:
- the document with refreshed marker (and possibly a warning markup)
-
isInsideProjectDependencies
public static boolean isInsideProjectDependencies(org.openrewrite.Cursor cursor) Check whether a cursor path represents a position inside the[project].dependenciesarray in a pyproject.toml.
-