File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
kotlin/cc/unitmesh/python/provider Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ package cc.unitmesh.python.provider
2
+
3
+ import cc.unitmesh.devti.provider.BuildSystemProvider
4
+ import cc.unitmesh.devti.provider.DevPackage
5
+ import cc.unitmesh.devti.template.context.DockerfileContext
6
+ import com.intellij.openapi.project.Project
7
+ import com.intellij.psi.PsiFile
8
+ import com.jetbrains.python.packaging.PyRequirement
9
+ import com.jetbrains.python.packaging.PyRequirementParser
10
+
11
+ class PythonBuildSystemProvider : BuildSystemProvider () {
12
+ override fun collect (project : Project ): DockerfileContext ? = null
13
+
14
+ override fun collectDependencies (project : Project , psiFile : PsiFile ): List <DevPackage > {
15
+ if (psiFile.language.id != " Python" ) {
16
+ return emptyList()
17
+ }
18
+
19
+ val reqs: List <PyRequirement > = PyRequirementParser .fromFile(psiFile.virtualFile)
20
+
21
+ return reqs.map {
22
+ DevPackage (
23
+ type = " Python" ,
24
+ name = it.name,
25
+ version = it.versionSpecs.firstOrNull()?.version ? : " "
26
+ )
27
+ }
28
+ }
29
+ }
Original file line number Diff line number Diff line change 19
19
20
20
<chatContextProvider implementation =" cc.unitmesh.python.PythonFrameworkContextProvider" />
21
21
22
+ <buildSystemProvider implementation =" cc.unitmesh.python.provider.PythonBuildSystemProvider" />
23
+
22
24
<!-- <devFlowProvider-->
23
25
<!-- language="Python"-->
24
26
<!-- implementation="cc.unitmesh.python.provider.PythonAutoDevFlow"/>-->
You can’t perform that action at this time.
0 commit comments