35#ifndef DRAIN_PYTHON_UTILS
36#define DRAIN_PYTHON_UTILS
40#include <drain/prog/CommandBank.h>
52 const std::string TRIPLE_HYPHEN;
55 std::string indentStr = std::string(4,
' ');
61 std::list<std::string> content = {
"return self._make_cmd(locals())"};
67 void exportImports(
const std::initializer_list<T> & container, std::ostream & ostr=std::cout)
const;
69 void exportCommands(
const std::string &name,
const drain::CommandBank & commandBank, std::ostream & ostr=std::cout,
int indentLevel=0)
const;
71 void exportCommand(
const std::string & name,
const drain::Command & command, std::ostream & ostr=std::cout,
int indentLevel=1,
bool implicit=
false)
const;
110void PythonConverter::exportImports(
const std::initializer_list<T> & container, std::ostream & ostr)
const {
111 for (
const auto & entry: container){
112 ostr <<
"import " << entry <<
'\n';
120 std::ostream & ostr = std::cout;
122 std::string indentStr =
" ";
124 PythonIndent(std::ostream & ostr=std::cout,
int indentLevel=0, std::string indentStr=
" ") : ostr(ostr), indentLevel(indentLevel), indentStr(indentStr) {
128 void setIndent(
int indentLevel){
131 this->indentLevel = indentLevel;
142 if (this->indentLevel < 0)
143 this->indentLevel = 0;
147 void indent()
const {
148 for (
int i=0; i<this->indentLevel; ++i){
149 ostr << this->indentStr;
153 template <
typename ... TT>
154 void write(TT... args)
const {
156 this->flush(args...);
162 void writeTitle(
const std::string & title)
const;
167 template <
typename T,
typename ... TT>
168 void flush(
const T & arg, TT... args)
const {
170 this->flush(args...);
Container and execution tools for commands derived from Command.
Definition CommandBank.h:56
Base class for commands: typically actions taking parameters but also plain variable assignments and ...
Definition Command.h:55
Definition PythonUtils.h:47
Definition PythonUtils.h:116
void writeTitle(const std::string &title) const
Definition PythonUtils.cpp:41
Definition DataSelector.cpp:1277