rename ParseMode as ParseContext in python folder.
This commit is contained in:
22
opm/parser/eclipse/python/c_inter/cparse_context.cc
Normal file
22
opm/parser/eclipse/python/c_inter/cparse_context.cc
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Parser/InputErrorAction.hpp>
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
Opm::ParseContext * parse_mode_alloc() {
|
||||
Opm::ParseContext * parse_mode = new Opm::ParseContext( );
|
||||
return parse_mode;
|
||||
}
|
||||
|
||||
|
||||
void parse_mode_free( Opm::ParseContext * parse_mode ) {
|
||||
delete parse_mode;
|
||||
}
|
||||
|
||||
|
||||
void parse_mode_update( Opm::ParseContext * parse_mode , const char * var , Opm::InputError::Action action) {
|
||||
parse_mode->update( var , action );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#include <opm/parser/eclipse/Parser/ParseMode.hpp>
|
||||
#include <opm/parser/eclipse/Parser/InputErrorAction.hpp>
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
Opm::ParseMode * parse_mode_alloc() {
|
||||
Opm::ParseMode * parse_mode = new Opm::ParseMode( );
|
||||
return parse_mode;
|
||||
}
|
||||
|
||||
|
||||
void parse_mode_free( Opm::ParseMode * parse_mode ) {
|
||||
delete parse_mode;
|
||||
}
|
||||
|
||||
|
||||
void parse_mode_update( Opm::ParseMode * parse_mode , const char * var , Opm::InputError::Action action) {
|
||||
parse_mode->update( var , action );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseMode.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
Opm::Deck * parser_parse_file(const Opm::Parser * parser , const char * file , const Opm::ParseMode * parse_mode) {
|
||||
Opm::Deck * parser_parse_file(const Opm::Parser * parser , const char * file , const Opm::ParseContext * parse_mode) {
|
||||
return parser->newDeckFromFile( file , *parse_mode );
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from .error_action import ErrorAction
|
||||
from .parse_mode import ParseMode
|
||||
from .parse_mode import ParseContext
|
||||
from .parser import Parser
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from ert.cwrap import BaseCClass, CWrapper
|
||||
from opm import OPMPrototype
|
||||
|
||||
class ParseMode(BaseCClass):
|
||||
class ParseContext(BaseCClass):
|
||||
TYPE_NAME = "parse_mode"
|
||||
_alloc = OPMPrototype("void* parse_mode_alloc()")
|
||||
_free = OPMPrototype("void parse_mode_free(parse_mode)")
|
||||
@@ -9,7 +9,7 @@ class ParseMode(BaseCClass):
|
||||
|
||||
def __init__(self):
|
||||
c_ptr = self._alloc()
|
||||
super(ParseMode, self).__init__(c_ptr)
|
||||
super(ParseContext, self).__init__(c_ptr)
|
||||
|
||||
|
||||
def free(self):
|
||||
@@ -6,7 +6,7 @@ from functools import partial
|
||||
from ert.cwrap import BaseCClass
|
||||
from opm import OPMPrototype
|
||||
from opm.deck import Deck
|
||||
from opm.parser import ParseMode
|
||||
from opm.parser import ParseContext
|
||||
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class Parser(BaseCClass):
|
||||
|
||||
if os.path.isfile( filename ):
|
||||
if parse_mode is None:
|
||||
parse_mode = ParseMode( )
|
||||
parse_mode = ParseContext( )
|
||||
return parser._parse_file(parser , filename, parse_mode)
|
||||
else:
|
||||
raise IOError("No such file:%s" % filename)
|
||||
|
||||
@@ -4,4 +4,4 @@ set (TEST_SOURCES
|
||||
|
||||
add_python_package("python.tests.parse_mode" "${PYTHON_INSTALL_PREFIX}/tests/parse_mode" "${TEST_SOURCES}" False)
|
||||
|
||||
addPythontest( python.test_parse_mode tests.parse_mode.test_parse_mode.ParseModeTest )
|
||||
addPythontest( python.test_parse_mode tests.parse_mode.test_parse_mode.ParseContextTest )
|
||||
|
||||
@@ -2,14 +2,14 @@ from unittest import TestCase
|
||||
|
||||
from ert.test import TestAreaContext,ExtendedTestCase
|
||||
|
||||
from opm.parser import ParseMode,ErrorAction
|
||||
from opm.parser import ParseContext,ErrorAction
|
||||
|
||||
|
||||
|
||||
class ParseModeTest(ExtendedTestCase):
|
||||
class ParseContextTest(ExtendedTestCase):
|
||||
|
||||
def test_parse_mode(self):
|
||||
pm = ParseMode()
|
||||
pm = ParseContext()
|
||||
|
||||
pm.update( "PARSE*" , ErrorAction.IGNORE )
|
||||
|
||||
@@ -2,14 +2,14 @@ from unittest import TestCase
|
||||
|
||||
from ert.test import TestAreaContext
|
||||
|
||||
from opm.parser import Parser,ParseMode
|
||||
from opm.parser import Parser,ParseContext
|
||||
|
||||
|
||||
|
||||
class ParserTest(TestCase):
|
||||
def test_parse(self):
|
||||
p = Parser()
|
||||
pm = ParseMode()
|
||||
pm = ParseContext()
|
||||
with self.assertRaises(IOError):
|
||||
p.parseFile("does/not/exist" , pm)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user