diff options
author | Tim O'Shea <tim.oshea753@gmail.com> | 2014-05-14 23:05:43 -0400 |
---|---|---|
committer | Tim O'Shea <tim.oshea753@gmail.com> | 2014-05-14 23:07:33 -0400 |
commit | e99fdb1edc3778d9e007fb5896392d6090a05cdb (patch) | |
tree | 159d9d61418895d8c4fe7a5910309c9ad9f9d93f /gnuradio-runtime/python/pmt/pmt_to_python.py | |
parent | a74a7f3f3172acd33680c3298f60279c11092d36 (diff) |
pmt: support conversion of basic pmt pairs to python
Diffstat (limited to 'gnuradio-runtime/python/pmt/pmt_to_python.py')
-rw-r--r-- | gnuradio-runtime/python/pmt/pmt_to_python.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gnuradio-runtime/python/pmt/pmt_to_python.py b/gnuradio-runtime/python/pmt/pmt_to_python.py index 3344eba163..8973b886e6 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): |