added parseData and test

This commit is contained in:
Pål Grønås Drange
2017-01-12 12:54:21 +01:00
parent f26bc01f54
commit bdb579b8db
3 changed files with 35 additions and 2 deletions
+2
View File
@@ -143,6 +143,7 @@ py::list get_groups( const Schedule& sch ) {
}
EclipseState (*parse)( const std::string&, const ParseContext& ) = &Parser::parse;
EclipseState (*parseData) (const std::string &data, const ParseContext& context) = &Parser::parseData;
void (ParseContext::*ctx_update)(const std::string&, InputError::Action) = &ParseContext::update;
}
@@ -161,6 +162,7 @@ py::to_python_converter< const boost::posix_time::ptime,
py::register_exception_translator< key_error >( &key_error::translate );
py::def( "parse", parse );
py::def( "parseData", parseData );
py::class_< EclipseState >( "EclipseState", py::no_init )
.add_property( "title", &EclipseState::getTitle )
+6 -2
View File
@@ -1,3 +1,4 @@
from os.path import isfile
import libsunbeam as lib
class _delegate(object):
@@ -163,5 +164,8 @@ def _parse_context(actions):
return ctx
def parse(path, actions = None):
return EclipseState(lib.parse(path, _parse_context(actions)))
def parse(deck, actions = None):
"""deck may be a deck string, or a file path"""
if isfile(deck):
return EclipseState(lib.parse(deck, _parse_context(actions)))
return EclipseState(lib.parseData(deck, _parse_context(actions)))