blob: 1b6e8db5f8176283c76eeaee4698ad560ca48a29 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.apache.yetus.releasedocmaker;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.python.core.Py;
import org.python.core.PyException;
import org.python.core.PySystemState;
import org.python.util.PythonInterpreter;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
/**
* Jython-based interface to releasedocmaker.
*/
public class ReleaseDocMaker {
/**
*
* This method calls the main() method of the shelldocs Python program.
*
* @param args argument string
* @throws PyException standard exception thrown for Jython
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public static void main(final String[] args) throws PyException {
List<String> list = new LinkedList<String>(Arrays.asList(args));
list.add(0,"releasedocmaker");
String[] newargs = list.toArray(new String[list.size()]);
PythonInterpreter.initialize(System.getProperties(), System.getProperties(), newargs);
PySystemState systemState = Py.getSystemState();
PythonInterpreter interpreter = new PythonInterpreter();
systemState.__setattr__("_jy_interpreter", Py.java2py(interpreter));
String command = "try:\n "
+ " import releasedocmaker\n "
+ " releasedocmaker.main()\n"
+ "except "
+ " SystemExit: pass";
interpreter.exec(command);
}
}