From 72f52a18069c2a04b9cb8bbe6f5185fe4c384be1 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 27 Mar 2014 14:56:05 +0000 Subject: Replace raw_input with the text argument --- jq.pyx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'jq.pyx') diff --git a/jq.pyx b/jq.pyx index 980662d..cec6e69 100644 --- a/jq.pyx +++ b/jq.pyx @@ -100,6 +100,11 @@ cdef class _ErrorStore(object): self._errors = [] +class EmptyValue(object): + pass + +_NO_VALUE = EmptyValue() + cdef class _Program(object): cdef jq_state* _jq cdef _ErrorStore _error_store @@ -107,8 +112,10 @@ cdef class _Program(object): def __dealloc__(self): jq_teardown(&self._jq) - def transform(self, input, raw_input=False, raw_output=False, multiple_output=False): - string_input = input if raw_input else json.dumps(input) + def transform(self, value=_NO_VALUE, text=_NO_VALUE, raw_output=False, multiple_output=False): + if (value is _NO_VALUE) == (text is _NO_VALUE): + raise ValueError("Either the value or text argument should be set") + string_input = text if text is not _NO_VALUE else json.dumps(value) bytes_input = string_input.encode("utf8") self._error_store.clear() -- cgit v1.2.3