Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0c3230b

Browse files
committed
Add support for reading PNG files [MPY-397]
1 parent b34541a commit 0c3230b

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ Changelog for Metview's Python interface
33

44
========================================
55

6+
1.16.0 (unreleased)
7+
-------------------
8+
- Added support for reading PNG files
9+
10+
611
1.15.0
712
------------------
813
- Added arguments() function to mimic the behaviour of the Macro function of the same name

metview/bindings.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,9 +1218,17 @@ def translate_return_val(self, val):
12181218
try:
12191219
return self.funcs[rt](val)
12201220
except Exception:
1221-
raise Exception(
1222-
"value_from_metview got an unhandled return type: " + str(rt)
1223-
)
1221+
# if the type is unknown, it might be a type that is actually stored
1222+
# as a request rather than as a MARS type, e.g. PNG
1223+
try:
1224+
if rt == 99:
1225+
rt = MvRetVal.trequest.value
1226+
return self.funcs[rt](val)
1227+
except Exception:
1228+
raise Exception(
1229+
"value_from_metview got an unhandled return type and could not convert to a Request: "
1230+
+ str(rt)
1231+
)
12241232

12251233

12261234
vr = ValueReturner()

tests/test_metview.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ def test_modify_embedded_request_via_update():
216216
# mv.plot(a, gv)
217217

218218

219+
def test_read_png():
220+
p = mv.read(file_in_testdir("MVPROFILEVIEW.png"))
221+
assert p.get_verb() == "PNG"
222+
223+
219224
def test_print():
220225
mv.print("Start ", 7, 1, 3, " Finished!")
221226
mv.print(6, 2, " Middle ", 6)

0 commit comments

Comments
 (0)