未验证 提交 9e9eb1ff 编写于 作者: G George 提交者: GitHub

#14591 add python for copy as source code (#15902)

* #14591 add python for copy as source code

* #14591 remove string builder generation for python
上级 63a65c94
......@@ -22,6 +22,7 @@ sql.convert.unformatted.text.description = Converts SQL text into unformatted si
sql.convert.unformatted.text.name = Unformatted text
sql.convert.java.description = Convert SQL text to Java format
sql.convert.python.description = Convert SQL text to Python format
sql.convert.c.description = Convert SQL text to C/C++ format
sql.convert.delphi.description = Convert SQL text to Delphi format
sql.convert.html.description = Convert SQL text to HTML format
......
......@@ -36,6 +36,9 @@
<property id="line-delimiter" label="%sql.convert.label.line.delimiter.name" type="string" description="%sql.convert.label.line.delimiter.discription" required="false" defaultValue=" "/>
<property id="use-string-builder" label="%sql.convert.label.use.string.builder.name" type="boolean" description="%sql.convert.label.use.string.builder.description" required="false" defaultValue="false"/>
</target>
<target id="python" label="Python" description="%sql.convert.python.description" class="org.jkiss.dbeaver.ui.editors.sql.convert.impl.PythonCodeConverter">
<property id="keep-formatting" label="%sql.convert.label.keep.formatting.name" type="boolean" description="%sql.convert.label.keep.formatting.discription" required="false" defaultValue="false"/>
</target>
<target id="cpp" label="C/C++" description="%sql.convert.c.description" class="org.jkiss.dbeaver.ui.editors.sql.convert.impl.CPPSQLConverter">
<property id="keep-formatting" label="%sql.convert.label.keep.formatting.name" type="boolean" description="%sql.convert.label.keep.formatting.discription" required="false" defaultValue="false"/>
<property id="line-delimiter" label="%sql.convert.label.line.delimiter.name" type="string" description="%sql.convert.label.line.delimiter.discription" required="false" defaultValue=" "/>
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2022 DBeaver Corp and others
*
* 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 org.jkiss.dbeaver.ui.editors.sql.convert.impl;
import org.jkiss.utils.CommonUtils;
import java.util.Map;
public class PythonCodeConverter extends SourceCodeSQLConverter {
@Override
protected void convertSourceLines(StringBuilder result, String[] sourceLines, String lineDelimiter, Map<String, Object> options) {
result.append("\"\"\"").append('\n');
for (String sourceLine : sourceLines) {
String escapedString = CommonUtils.escapeJavaString(sourceLine);
result.append(escapedString).append('\n');
}
result.append("\"\"\"").append('\n');
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册