diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | README.md | 46 | ||||
| -rw-r--r-- | README.rst | 52 | ||||
| -rw-r--r-- | makefile | 21 | ||||
| -rw-r--r-- | setup.py | 11 |
5 files changed, 62 insertions, 69 deletions
@@ -1,5 +1,4 @@ *.pyc -/README /_virtualenv /build /jq.c diff --git a/README.md b/README.md deleted file mode 100644 index 5802171..0000000 --- a/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# jq.py: a lightweight and flexible JSON processor - -Warning: the API is not stable. - -This project contains Python bindings for [jq](http://stedolan.github.io/jq/). - -## Examples - -```python -from jq import jq - -jq(".").transform("42") == "42" -``` - -If the value is unparsed JSON text, pass it in using the `text` argument: - -```python -jq(".").transform(text="42") == 42 -``` - -The `text_output` argument can be used to serialise the output into JSON text: - -```python -jq(".").transform("42", text_output=True) == '"42"' -``` - -If there are multiple output elements, -each element is represented by a separate line, -irrespective of the value of `multiple_output`: - -```python -jq(".[]").transform("[1, 2, 3]", text_output=True) == "1\n2\n3" -``` - -If `multiple_output` is `False` (the default), then the first output is used: - -```python -jq(".[]+1").transform([1, 2, 3]) == 2 -``` - -If `multiple_output` is `True`, -all output elements are returned in an array: - -```python -jq(".[]+1").transform([1, 2, 3], multiple_output=True) == [2, 3, 4] -``` diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..ac66f30 --- /dev/null +++ b/README.rst @@ -0,0 +1,52 @@ +jq.py: a lightweight and flexible JSON processor +================================================ + +Warning: the API is not stable. + +This project contains Python bindings for +`jq <http://stedolan.github.io/jq/>`_. + +Examples +-------- + +.. code-block:: python + + from jq import jq + + jq(".").transform("42") == "42" + +If the value is unparsed JSON text, pass it in using the ``text`` +argument: + +.. code-block:: python + + jq(".").transform(text="42") == 42 + +The ``text_output`` argument can be used to serialise the output into +JSON text: + +.. code-block:: python + + jq(".").transform("42", text_output=True) == '"42"' + +If there are multiple output elements, each element is represented by a +separate line, irrespective of the value of ``multiple_output``: + +.. code-block:: python + + jq(".[]").transform("[1, 2, 3]", text_output=True) == "1\n2\n3" + +If ``multiple_output`` is ``False`` (the default), then the first output +is used: + +.. code-block:: python + + jq(".[]+1").transform([1, 2, 3]) == 2 + +If ``multiple_output`` is ``True``, all output elements are returned in +an array: + +.. code-block:: python + + jq(".[]+1").transform([1, 2, 3], multiple_output=True) == [2, 3, 4] + @@ -1,41 +1,34 @@ -.PHONY: test upload clean bootstrap setup assert-converted-readme +.PHONY: test test-all upload register clean bootstrap test: bootstrap _virtualenv/bin/nosetests tests -test-all: setup +test-all: _virtualenv/bin/tox make clean -upload: setup assert-converted-readme jq.c +upload: jq.c python setup.py sdist upload make clean -register: setup +register: python setup.py register -README: - pandoc --from=markdown --to=rst README.md > README || cp README.md README - -assert-converted-readme: - test "`cat README`" != "`cat README.md`" - clean: - rm -f README rm -f MANIFEST rm -rf dist -bootstrap: _virtualenv jq.c setup +bootstrap: _virtualenv jq.c _virtualenv/bin/pip install -e . ifneq ($(wildcard test-requirements.txt),) _virtualenv/bin/pip install -r test-requirements.txt endif make clean -setup: README - _virtualenv: virtualenv _virtualenv + _virtualenv/bin/pip install --upgrade pip + _virtualenv/bin/pip install --upgrade setuptools jq.c: _virtualenv jq.pyx _virtualenv/bin/pip install cython @@ -10,13 +10,8 @@ from distutils.command.build_ext import build_ext def path_in_dir(relative_path): return os.path.join(os.path.dirname(__file__), relative_path) - -def read_or_empty_string(fname): - path = path_in_dir(fname) - if os.path.exists(path): - return open(path).read() - else: - return "" +def read(fname): + return open(os.path.join(os.path.dirname(__file__), fname)).read() jq_lib_dir = path_in_dir("_jq-lib") @@ -60,7 +55,7 @@ setup( name='jq', version='0.1.0', description='jq is a lightweight and flexible JSON processor.', - long_description=read_or_empty_string("README"), + long_description=read("README.rst"), author='Michael Williamson', url='http://github.com/mwilliamson/jq.py', license='BSD 2-Clause', |
