Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#include <ostream>
#include <iostream>
#include <string>
#include <vector>

#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Utilities/interface/Parse.h"
#include "FWCore/ParameterSet/interface/ParseTree.h"
#include "FWCore/ParameterSet/src/PythonFormWriter.h"

using namespace edm;
using namespace edm::pset;

void writePythonForm(std::string const& config, std::ostream& out) {
  edm::pset::ParseTree parsetree(config);

  PythonFormWriter writer;
  writer.write(parsetree, out);
}

int main() {
  // Read input from cin into configstring..
  std::string configstring;
  edm::read_from_cin(configstring);

  // Now parse this configuration string, writing the Python format to
  // standard out.

  int rc = 1;  // failure
  try {
    writePythonForm(configstring, std::cout);
    rc = 0;  // success
  } catch (edm::Exception const& x) {
    std::cerr << x << '\n';
  } catch (...) {
    std::cerr << "Unidentified exception caught\n";
  }
  return rc;
}