summaryrefslogtreecommitdiff
path: root/jq.pyx
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2020-04-18 22:07:29 +0100
committerMichael Williamson <mike@zwobble.org>2020-04-18 22:08:52 +0100
commit9db282db64e79030eaa695b16d18017b89583dc5 (patch)
tree70ad68489ae3fceacb39ad5d6a050501e2ad9aa4 /jq.pyx
parentf0343c5281cdbd014668c035f4dbdd63cc70c7f9 (diff)
Add backwards-compatibility with 0.1.x
Diffstat (limited to 'jq.pyx')
-rw-r--r--jq.pyx15
1 files changed, 15 insertions, 0 deletions
diff --git a/jq.pyx b/jq.pyx
index 520e21c..229faa4 100644
--- a/jq.pyx
+++ b/jq.pyx
@@ -138,6 +138,16 @@ cdef class _Program(object):
def __repr__(self):
return "jq.compile({!r})".format(self.program_string)
+ # Support the 0.1.x API for backwards compatibility
+ def transform(self, value=_NO_VALUE, text=_NO_VALUE, text_output=False, multiple_output=False):
+ program_with_input = self.input(value, text=text)
+ if text_output:
+ return program_with_input.text()
+ elif multiple_output:
+ return program_with_input.all()
+ else:
+ return program_with_input.first()
+
cdef class _ProgramWithInput(object):
cdef object _program_bytes
@@ -226,3 +236,8 @@ cdef class _ResultIterator(object):
raise ValueError(u"parse error: " + message)
else:
raise StopIteration()
+
+
+# Support the 0.1.x API for backwards compatibility
+def jq(object program):
+ return compile(program)