File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed
src/main/kotlin/com/github/pyvenvmanage Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -15,10 +15,12 @@ class VenvProjectViewNodeDecorator : ProjectViewNodeDecorator {
1515 val pyVenvCfgPath = VenvUtils .getPyVenvCfg(node.getVirtualFile())
1616 if (pyVenvCfgPath != null ) {
1717 val pythonVersion = VenvUtils .getPythonVersionFromPyVenv(pyvenvCfgPath = pyVenvCfgPath)
18- val fileName: String? = data.getPresentableText()
19- data.clearText()
20- data.addText(fileName, SimpleTextAttributes .REGULAR_ATTRIBUTES )
21- data.addText(" [" + pythonVersion + " ]" , SimpleTextAttributes .GRAY_ATTRIBUTES )
18+ if (pythonVersion != null ) {
19+ val fileName: String? = data.getPresentableText()
20+ data.clearText()
21+ data.addText(fileName, SimpleTextAttributes .REGULAR_ATTRIBUTES )
22+ data.addText(" [$pythonVersion ]" , SimpleTextAttributes .GRAY_ATTRIBUTES )
23+ }
2224 data.setIcon(Virtualenv )
2325 }
2426 }
Original file line number Diff line number Diff line change @@ -27,24 +27,22 @@ object VenvUtils {
2727 }
2828
2929 @JvmStatic
30- fun getPythonVersionFromPyVenv (pyvenvCfgPath : Path ): String {
31- val unknownVersion = " unknown"
32-
30+ fun getPythonVersionFromPyVenv (pyvenvCfgPath : Path ): String? {
3331 val props = Properties ()
3432
3533 try {
3634 Files .newBufferedReader(pyvenvCfgPath, StandardCharsets .UTF_8 ).use { reader ->
3735 props.load(reader)
3836 }
3937 } catch (e: IOException ) {
40- return unknownVersion // file could not be read
38+ return null // file could not be read
4139 }
4240
43- val version = props.getProperty(" version_info " )
41+ val version = props.getProperty(" version " )
4442 if (version != null ) {
4543 return version.trim { it <= ' ' }
4644 }
4745
48- return unknownVersion
46+ return null
4947 }
5048}
You can’t perform that action at this time.
0 commit comments