Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow invalid keyword combinations when parsing schedule sections in time_vector.py #4165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions python/opm/tools/time_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
except ImportError:
from io import StringIO

import opm.io
from opm.io.parser import ParseContext
from opm.io.parser import Parser

error_actions = [("PARSE_INVALID_KEYWORD_COMBINATION", opm.io.action.ignore)]

# This is from the TimeMap.cpp implementation in opm
ecl_month = {
"JAN": 1,
Expand Down Expand Up @@ -270,12 +274,13 @@ def __init__(self, start_date, base_string=None, base_file=None):

self._add_dates_block(ts)
start_dt = datetime.datetime(start_date.year, start_date.month, start_date.day)
parse_context = ParseContext(error_actions)
if base_file:
deck = Parser().parse(base_file)
deck = Parser().parse(base_file, parse_context)
self._add_deck(deck, start_dt)

if base_string:
deck = Parser().parse_string(base_string)
deck = Parser().parse_string(base_string, parse_context)
self._add_deck(deck, start_dt)

def __len__(self):
Expand Down Expand Up @@ -391,14 +396,16 @@ def load(self, filename, date=None):
tv.load("well.sch", date = datetime.datetime(2017, 4, 1))

"""
deck = Parser().parse(filename)
parse_context = ParseContext(error_actions)
deck = Parser().parse(filename, parse_context)
self._add_deck(deck, date)

def load_string(self, deck_string, date=None):
"""
Like load() - but load from a string literal instead of file.
"""
deck = Parser().parse_string(deck_string)
parse_context = ParseContext(error_actions)
deck = Parser().parse_string(deck_string, parse_context)
self._add_deck(deck, date)

def __str__(self):
Expand Down