commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 02/12: pmt: support conversion of basic pmt


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/12: pmt: support conversion of basic pmt pairs to python
Date: Fri, 23 May 2014 17:35:56 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit e99fdb1edc3778d9e007fb5896392d6090a05cdb
Author: Tim O'Shea <address@hidden>
Date:   Wed May 14 23:05:43 2014 -0400

    pmt: support conversion of basic pmt pairs to python
---
 gnuradio-runtime/python/pmt/pmt_to_python.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gnuradio-runtime/python/pmt/pmt_to_python.py 
b/gnuradio-runtime/python/pmt/pmt_to_python.py
index 3344eba..8973b88 100644
--- a/gnuradio-runtime/python/pmt/pmt_to_python.py
+++ b/gnuradio-runtime/python/pmt/pmt_to_python.py
@@ -110,12 +110,17 @@ type_mappings = ( #python type, check pmt type, to 
python, from python
     (tuple, pmt.is_tuple, pmt_to_tuple, pmt_from_tuple),
     (list, pmt.is_vector, pmt_to_vector, pmt_from_vector),
     (dict, pmt.is_dict, pmt_to_dict, pmt_from_dict),
+    (tuple, pmt.is_pair, lambda x: (pmt_to_python(pmt.car(x)), 
pmt_to_python(pmt.cdr(x))), lambda x: pmt.cons(python_to_pmt(x[0]), 
python_to_pmt(x[1]))),
     (numpy.ndarray, pmt.is_uniform_vector, uvector_to_numpy, numpy_to_uvector),
 )
 
 def pmt_to_python(p):
     for python_type, pmt_check, to_python, from_python in type_mappings:
-        if pmt_check(p): return to_python(p)
+        if pmt_check(p): 
+            try:
+                return to_python(p)
+            except:
+                pass
     raise ValueError("can't convert %s type to pmt (%s)"%(type(p),p))
 
 def python_to_pmt(p):



reply via email to

[Prev in Thread] Current Thread [Next in Thread]