setup.py moved to python/python. moved python tests to python/python. added __init__.py under python/tests. added 'test_' before all python test names. test_ prefix added to tests. setup.py and python tests moved back to python base. setuptools executes from root python. python: tests run from root python w/ setup.py. python tests: temp reduced to test_deck only. python setup.py: manually linked opmcommon. setup.py: linked ecl. setup.py linked boost_filesystem. setup.py: linked boost_regex. python all tests run. removec usr/local from setup.py ext_module. cmake make copies entire python dir to build. setup.py can execute from build. setup.py executes from build/python. python tests run under setup.py. setup.py library_dirs and include-dirs set by cmake command. removed cmake files from sunbeam. sunbeam: added code for install. setup.py: removed 'import ecl'. python/src -> python->src_sunbeam. setup.py: discontinued use of glob, all files listed instead. build-opm_module.sh: added prefix_path to opm. build-opm-module.sh: changed spell error for EXTRA_MODULE_FLAGS[opm-common]. setup.py: infer include directories from cmake target CMakeLists.txt: under python: align install statement. CMakeLists build python: removed find_package. src_sunbeam -> cxx. setup.py: test_suite as string. setup.py: tests_suite -> test_suite. setup.py: added exception if 'build_ext' not used. temporarily moved files to python/sunbeam.
77 lines
2.5 KiB
C++
77 lines
2.5 KiB
C++
#include <opm/json/JsonObject.hpp>
|
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
|
#include <pybind11/stl.h>
|
|
|
|
#include "sunbeam_state.hpp"
|
|
#include "sunbeam.hpp"
|
|
|
|
|
|
namespace {
|
|
|
|
Deck create_deck( const std::string& deckStr,
|
|
const ParseContext& pc,
|
|
const Parser& parser) {
|
|
|
|
Opm::ErrorGuard guard;
|
|
auto p = parser.parseFile( deckStr, pc, guard );
|
|
guard.clear();
|
|
return p;
|
|
}
|
|
|
|
|
|
Deck create_deck_string( const std::string& deckStr,
|
|
const ParseContext& pc,
|
|
const Parser& parser) {
|
|
Opm::ErrorGuard guard;
|
|
auto p = parser.parseString( deckStr, pc, guard );
|
|
guard.clear();
|
|
return p;
|
|
}
|
|
|
|
|
|
SunbeamState * parse_file(const std::string& filename, const ParseContext& context, const Parser& parser) {
|
|
return new SunbeamState(true, filename, context, parser);
|
|
}
|
|
|
|
SunbeamState * parse_string(const std::string& filename, const ParseContext& context, const Parser& parser) {
|
|
return new SunbeamState(false, filename, context, parser);
|
|
}
|
|
|
|
void (ParseContext::*ctx_update)(const std::string&, InputError::Action) = &ParseContext::update;
|
|
|
|
void add_keyword(Parser* parser, const std::string& json_string) {
|
|
const Json::JsonObject keyword(json_string);
|
|
parser->addParserKeyword(keyword);
|
|
}
|
|
}
|
|
|
|
void sunbeam::export_Parser(py::module& module) {
|
|
|
|
module.def( "parse", parse_file );
|
|
module.def( "parse_string", parse_string);
|
|
module.def( "create_deck", &create_deck );
|
|
module.def( "create_deck_string", &create_deck_string);
|
|
|
|
py::class_<SunbeamState>(module, "SunbeamState")
|
|
.def("_schedule", &SunbeamState::getSchedule, ref_internal)
|
|
.def("_state", &SunbeamState::getEclipseState, ref_internal)
|
|
.def("_deck", &SunbeamState::getDeck, ref_internal)
|
|
.def("_summary_config", &SunbeamState::getSummmaryConfig, ref_internal);
|
|
|
|
py::class_< ParseContext >(module, "ParseContext" )
|
|
.def(py::init<>())
|
|
.def(py::init<const std::vector<std::pair<std::string, InputError::Action>>>())
|
|
.def( "update", ctx_update );
|
|
|
|
py::enum_< InputError::Action >( module, "action" )
|
|
.value( "throw", InputError::Action::THROW_EXCEPTION )
|
|
.value( "warn", InputError::Action::WARN )
|
|
.value( "ignore", InputError::Action::IGNORE );
|
|
|
|
|
|
py::class_<Parser>(module, "Parser")
|
|
.def(py::init<>())
|
|
.def("add_keyword", add_keyword);
|
|
}
|