Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:28:49

0001 #include <ostream>
0002 #include <iostream>
0003 #include <string>
0004 #include <vector>
0005 
0006 #include "FWCore/Utilities/interface/EDMException.h"
0007 #include "FWCore/Utilities/interface/Parse.h"
0008 #include "FWCore/ParameterSet/interface/ParseTree.h"
0009 #include "FWCore/ParameterSet/src/PythonFormWriter.h"
0010 
0011 using namespace edm;
0012 using namespace edm::pset;
0013 
0014 void writePythonForm(std::string const& config, std::ostream& out) {
0015   edm::pset::ParseTree parsetree(config);
0016 
0017   PythonFormWriter writer;
0018   writer.write(parsetree, out);
0019 }
0020 
0021 int main() {
0022   // Read input from cin into configstring..
0023   std::string configstring;
0024   edm::read_from_cin(configstring);
0025 
0026   // Now parse this configuration string, writing the Python format to
0027   // standard out.
0028 
0029   int rc = 1;  // failure
0030   try {
0031     writePythonForm(configstring, std::cout);
0032     rc = 0;  // success
0033   } catch (edm::Exception const& x) {
0034     std::cerr << x << '\n';
0035   } catch (...) {
0036     std::cerr << "Unidentified exception caught\n";
0037   }
0038   return rc;
0039 }