CMS 3D CMS Logo

PythonParseTree Class Reference

#include <FWCore/ParameterSet/interface/PythonParseTree.h>

List of all members.

Public Member Functions

boost::python::list children (const std::string &dotDelimitedNode) const
 names of the nodes below this one. Includes are transparent
void dump (const std::string &dotDelimitedNode) const
std::string dumpTree () const
 dump the tree to a string, to be written to a file.
boost::python::list modules () const
 the names of all modules in this parse tree
boost::python::list modulesOfType (const std::string &type) const
 names of all modules of type, e.g., service or es_source
boost::python::list outputModules () const
void process ()
 processes all includes, renames, etc.
 PythonParseTree (const std::string &filename)
void replaceValue (const std::string &dotDelimitedNode, const std::string &value)
 replaces the value of an entry
void replaceValues (const std::string &dotDelimitedNode, boost::python::list &values)
 WARNING the input list gets destroyed by pop()s.
std::string typeOf (const std::string &dotDelimitedNode) const
std::string value (const std::string &dotDelimitedNode) const
 only works for EntryNodes inside modules. Hope to include top-level PSets soon
boost::python::list values (const std::string &dotDelimitedNode) const
 only works for VEntryNodes

Static Public Member Functions

static void exceptionTranslator (const edm::Exception &e)
 changes edm::Exceptions to python exceptions

Private Attributes

edm::pset::ParseTree theTree


Detailed Description

Definition at line 9 of file PythonParseTree.h.


Constructor & Destructor Documentation

PythonParseTree::PythonParseTree ( const std::string &  filename  ) 

Definition at line 7 of file PythonParseTree.cc.

References edm::pset::ParseTree::process(), and theTree.

00008 :  theTree(edm::read_whole_file(filename))
00009 {
00010 
00011   theTree.process();
00012 }


Member Function Documentation

boost::python::list PythonParseTree::children ( const std::string &  dotDelimitedNode  )  const

names of the nodes below this one. Includes are transparent

Definition at line 73 of file PythonParseTree.cc.

References edm::pset::ParseTree::children(), and theTree.

Referenced by BOOST_PYTHON_MODULE().

00074 {
00075   return edm::toPythonList<std::string>(theTree.children(dotDelimitedNode));
00076 }

void PythonParseTree::dump ( const std::string &  dotDelimitedNode  )  const

Definition at line 49 of file PythonParseTree.cc.

References edm::pset::ParseTree::print(), and theTree.

Referenced by BOOST_PYTHON_MODULE().

00050 {
00051   theTree.print(dotDelimitedNode);
00052 }

std::string PythonParseTree::dumpTree (  )  const

dump the tree to a string, to be written to a file.

Definition at line 79 of file PythonParseTree.cc.

References edm::pset::Node::COMPRESSED, theTree, and edm::pset::ParseTree::top().

Referenced by BOOST_PYTHON_MODULE().

00080 {
00081   std::ostringstream ost;
00082   theTree.top()->print(ost, edm::pset::Node::COMPRESSED);
00083   return ost.str();
00084 }

void PythonParseTree::exceptionTranslator ( const edm::Exception e  )  [static]

changes edm::Exceptions to python exceptions

Definition at line 87 of file PythonParseTree.cc.

References cms::Exception::what().

Referenced by BOOST_PYTHON_MODULE().

00088 {
00089   PyErr_SetString(PyExc_RuntimeError, e.what());
00090 }

boost::python::list PythonParseTree::modules (  )  const

the names of all modules in this parse tree

Definition at line 16 of file PythonParseTree.cc.

References edm::pset::ParseTree::modules(), and theTree.

Referenced by BOOST_PYTHON_MODULE().

00017 {
00018   return edm::toPythonList<std::string>(theTree.modules());
00019 }

boost::python::list PythonParseTree::modulesOfType ( const std::string &  type  )  const

names of all modules of type, e.g., service or es_source

Definition at line 23 of file PythonParseTree.cc.

References edm::pset::ParseTree::modulesOfType(), and theTree.

Referenced by BOOST_PYTHON_MODULE().

00024 {
00025   return edm::toPythonList<std::string>(theTree.modulesOfType(type));
00026 }

boost::python::list PythonParseTree::outputModules (  )  const

void PythonParseTree::process (  ) 

processes all includes, renames, etc.

Definition at line 29 of file PythonParseTree.cc.

References edm::pset::ParseTree::process(), and theTree.

Referenced by BOOST_PYTHON_MODULE().

00030 {
00031   theTree.process();
00032 }

void PythonParseTree::replaceValue ( const std::string &  dotDelimitedNode,
const std::string &  value 
)

replaces the value of an entry

Definition at line 35 of file PythonParseTree.cc.

References edm::pset::ParseTree::replace(), and theTree.

Referenced by BOOST_PYTHON_MODULE().

00037 {
00038   theTree.replace(dotDelimitedNode, value);
00039 }

void PythonParseTree::replaceValues ( const std::string &  dotDelimitedNode,
boost::python::list &  values 
)

WARNING the input list gets destroyed by pop()s.

Definition at line 42 of file PythonParseTree.cc.

References edm::pset::ParseTree::replace(), and theTree.

Referenced by BOOST_PYTHON_MODULE().

00044 {
00045   theTree.replace(dotDelimitedNode, edm::toVector<std::string>(values));
00046 }

std::string PythonParseTree::typeOf ( const std::string &  dotDelimitedNode  )  const

Definition at line 55 of file PythonParseTree.cc.

References theTree, and edm::pset::ParseTree::typeOf().

Referenced by BOOST_PYTHON_MODULE().

00056 {
00057   return theTree.typeOf(dotDelimitedNode);
00058 }

std::string PythonParseTree::value ( const std::string &  dotDelimitedNode  )  const

only works for EntryNodes inside modules. Hope to include top-level PSets soon

Definition at line 61 of file PythonParseTree.cc.

References theTree, and edm::pset::ParseTree::value().

Referenced by BOOST_PYTHON_MODULE().

00062 {
00063   return theTree.value(dotDelimitedNode);
00064 }

boost::python::list PythonParseTree::values ( const std::string &  dotDelimitedNode  )  const

only works for VEntryNodes

Definition at line 67 of file PythonParseTree.cc.

References theTree, and edm::pset::ParseTree::values().

Referenced by BOOST_PYTHON_MODULE().

00068 {
00069   return edm::toPythonList<std::string>(theTree.values(dotDelimitedNode));
00070 }


Member Data Documentation

edm::pset::ParseTree PythonParseTree::theTree [private]

Definition at line 54 of file PythonParseTree.h.

Referenced by children(), dump(), dumpTree(), modules(), modulesOfType(), process(), PythonParseTree(), replaceValue(), replaceValues(), typeOf(), value(), and values().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:30:32 2009 for CMSSW by  doxygen 1.5.4