mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
[python] Code Review Changes(PY-60410)
GitOrigin-RevId: c4054e33a65db334dd5c9c2a7e2e6a9b38766eb2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a53a6fce7c
commit
388604d4a9
@@ -112,6 +112,10 @@ const val ENV_TYPE_VIRTUAL: String = "virtual"
|
||||
* Manage project environments
|
||||
*/
|
||||
class HatchEnv(runtime: HatchRuntime) : HatchCommand("env", runtime) {
|
||||
companion object {
|
||||
private val SHOW_RESPONSE_REGEX = """^\s+Standalone\s*\n((?:[+|].*[+|]\n)+)(?:\s+Matrices\s*\n((?:[+|].*[+|]\n)+))?$""".toRegex()
|
||||
}
|
||||
|
||||
enum class CreateResult {
|
||||
Created,
|
||||
AlreadyExists,
|
||||
@@ -228,9 +232,7 @@ class HatchEnv(runtime: HatchRuntime) : HatchCommand("env", runtime) {
|
||||
suspend fun show(vararg envs: String, internal: Boolean = false): Result<HatchEnvironments, ExecException> {
|
||||
val options = listOf(internal to "--internal").makeOptions()
|
||||
|
||||
val expectedOutput = """^\s+Standalone\s*\n((?:[+|].*[+|]\n)+)(?:\s+Matrices\s*\n((?:[+|].*[+|]\n)+))?$""".toRegex()
|
||||
|
||||
return executeAndMatch("show", "--ascii", *options, *envs, expectedOutput = expectedOutput) { matchResult ->
|
||||
return executeAndMatch("show", "--ascii", *options, *envs, expectedOutput = SHOW_RESPONSE_REGEX) { matchResult ->
|
||||
val (standaloneTable, matricesTable) = matchResult.destructured
|
||||
val standalone = standaloneTable.parseAsciiTable()?.parseHatchEnvironments()?.map { it.first } ?: emptyList()
|
||||
val matrices = matricesTable.parseAsciiTable()?.parseHatchEnvironments()?.mapNotNull {
|
||||
|
||||
@@ -42,20 +42,32 @@ class FileSystemOperationHatchError(eelFsError: EelFsError) : HatchError(
|
||||
|
||||
data class HatchVirtualEnvironment(
|
||||
val hatchEnvironment: HatchEnvironment,
|
||||
val pythonVirtualEnvironment: PythonVirtualEnvironment,
|
||||
val pythonVirtualEnvironment: PythonVirtualEnvironment?,
|
||||
) {
|
||||
companion object {
|
||||
val AVAILABLE_ENVIRONMENTS_FOR_NEW_PROJECT: List<HatchVirtualEnvironment> = listOf(
|
||||
HatchVirtualEnvironment(HatchEnvironment.DEFAULT, PythonVirtualEnvironment.NotExisting())
|
||||
HatchVirtualEnvironment(HatchEnvironment.DEFAULT, null)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Python virtual environment that can be either existing or non-existing.
|
||||
*/
|
||||
sealed interface PythonVirtualEnvironment {
|
||||
val pythonHomePath: PythonHomePath?
|
||||
val pythonHomePath: PythonHomePath
|
||||
|
||||
/**
|
||||
* Represents an existing Python virtual environment.
|
||||
* The environment was verified and the Python version was already discovered.
|
||||
*/
|
||||
data class Existing(override val pythonHomePath: PythonHomePath, val pythonVersion: String) : PythonVirtualEnvironment
|
||||
data class NotExisting(override val pythonHomePath: PythonHomePath? = null) : PythonVirtualEnvironment
|
||||
|
||||
/**
|
||||
* Represents a non-existing Python virtual environment.
|
||||
* This class is used for cases where the Python virtual environment is expected or referenced but does not exist on the file system.
|
||||
*/
|
||||
data class NotExisting(override val pythonHomePath: PythonHomePath) : PythonVirtualEnvironment
|
||||
}
|
||||
|
||||
data class ProjectStructure(
|
||||
|
||||
Reference in New Issue
Block a user