Merge pull request #1211 from joakim-hove/monkey-patch-rename
Minor refactor to monkey-patching
This commit is contained in:
@@ -7,15 +7,18 @@ from opm._common import EclFile
|
||||
# ensure the EclFile class returns normal Python strings in the case of CHAR
|
||||
# arrays. The return value is normal Python list of strings.
|
||||
|
||||
__getitem__ = EclFile.__getitem__
|
||||
|
||||
def getitem(self, index):
|
||||
data = __getitem__(self, index)
|
||||
data = self.__getitem(index)
|
||||
array_type = self.arrays[index][1]
|
||||
if array_type == eclArrType.CHAR:
|
||||
return [ x.decode("utf-8") for x in data ]
|
||||
|
||||
return data
|
||||
|
||||
setattr(EclFile, "__getitem__", getitem)
|
||||
|
||||
def make_getitem(cls):
|
||||
setattr(cls, "__getitem", cls.__getitem__)
|
||||
setattr(cls, "__getitem__", getitem)
|
||||
|
||||
|
||||
make_getitem(EclFile)
|
||||
|
||||
Reference in New Issue
Block a user