mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-20735 Fixed: Creating a setup.py with "'" in the description breaks the output in the resulting file
Implement setup.py template handler which escapes `description` property.
This commit is contained in:
@@ -615,6 +615,8 @@
|
||||
|
||||
<toolWindow id="Data View" factoryClass="com.jetbrains.python.debugger.containerview.PyDataViewToolWindowFactory" anchor="right" icon="PythonIcons.Python.DataView"/>
|
||||
<projectService serviceInterface="com.jetbrains.python.debugger.containerview.PyDataView" serviceImplementation="com.jetbrains.python.debugger.containerview.PyDataView"/>
|
||||
|
||||
<createFromTemplateHandler implementation="com.jetbrains.python.packaging.setupPy.PyCreateSetupPyFromTemplateHandler"/>
|
||||
</extensions>
|
||||
|
||||
<extensionPoints>
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jetbrains.python.packaging.setupPy
|
||||
|
||||
import com.intellij.ide.fileTemplates.DefaultCreateFromTemplateHandler
|
||||
import com.intellij.ide.fileTemplates.FileTemplate
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
|
||||
class PyCreateSetupPyFromTemplateHandler : DefaultCreateFromTemplateHandler() {
|
||||
|
||||
override fun handlesTemplate(template: FileTemplate?): Boolean {
|
||||
return template == FileTemplateManager.getDefaultInstance().getInternalTemplate("Setup Script")
|
||||
}
|
||||
|
||||
override fun prepareProperties(props: MutableMap<String, Any>?) {
|
||||
if (props != null) {
|
||||
val description = props["Description"]
|
||||
if (description is String) {
|
||||
props["Description"] = StringUtil.escapeChar(description, '\'')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user