Convert Python dictionary to string, which is passed to C API.
(data)
| 132 | |
| 133 | |
| 134 | def param_dict_to_str(data): |
| 135 | """Convert Python dictionary to string, which is passed to C API.""" |
| 136 | if data is None or not data: |
| 137 | return "" |
| 138 | pairs = [] |
| 139 | for key, val in data.items(): |
| 140 | if isinstance(val, (list, tuple, set)) or is_numpy_1d_array(val): |
| 141 | pairs.append(str(key) + '=' + ','.join(map(str, val))) |
| 142 | elif isinstance(val, string_type) or isinstance(val, numeric_types) or is_numeric(val): |
| 143 | pairs.append(str(key) + '=' + str(val)) |
| 144 | elif val is not None: |
| 145 | raise TypeError('Unknown type of parameter:%s, got:%s' |
| 146 | % (key, type(val).__name__)) |
| 147 | return ' '.join(pairs) |
| 148 | |
| 149 | |
| 150 | class _TempFile(object): |
no test coverage detected