diff options
| author | Michael Williamson <mike@zwobble.org> | 2020-04-18 22:07:29 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2020-04-18 22:08:52 +0100 |
| commit | 9db282db64e79030eaa695b16d18017b89583dc5 (patch) | |
| tree | 70ad68489ae3fceacb39ad5d6a050501e2ad9aa4 /jq.pyx | |
| parent | f0343c5281cdbd014668c035f4dbdd63cc70c7f9 (diff) | |
Add backwards-compatibility with 0.1.x
Diffstat (limited to 'jq.pyx')
| -rw-r--r-- | jq.pyx | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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) |
