From 3f329a350930787dedf10369ae869b6851464fa9 Mon Sep 17 00:00:00 2001 From: Chris B Date: Wed, 14 Mar 2018 20:27:49 -0500 Subject: [PATCH 1/2] update readme --- README.md | 42 ----------------------------------------- README.rst | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 42 deletions(-) delete mode 100644 README.md create mode 100644 README.rst diff --git a/README.md b/README.md deleted file mode 100644 index 43d3bcf..0000000 --- a/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# JsonPydexer -A (python) indexer for large collections of json files. -In development and probably not good for general use yet. -`pip install JsonPydexer` - -## Usage -### Starting from zero -```python -from JsonPydexer import JsonPydexer - -# initialize with the root directory containing your json files -jp = JsonPydexer("test_data/1") - -# index on your keys. provide a list of keynamess. keyname elements can be a string for a -# field at root level, or a list of strings for nested fields -jp.index(["id", ["details", "name"]]) -``` -### Opening an existing index -```python -# initialize with the root directory containing your json files and .jp.pkl -jp = JsonPydexer("test_data/1") - -# get all the files that match a search string for non-unique index -search_string = "Foo" -for filename in jp.get_files(["key_name"], search_string): - with open(filename, "r") as f: - print(f) - -# get the file matching a search string for a unique index -search_string = "Bar" -with open(jp.get_file(["unique_key_name"], search_string), "r") as f: - print(f) -``` - -### Added, removed, or modified JSON files? Updating -```python -jp = JsonPydexer("test_data/1") - -jp.update() -``` -New files in the directory will be added to the index. Coming soon are: removing files not present in the directory from the index, and checking for modified files in the directory. - diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..7ef8ff3 --- /dev/null +++ b/README.rst @@ -0,0 +1,55 @@ +JsonPydexer +=========== + +A (python) indexer for large collections of json files. In development +and probably not good for general use yet. + +Installation +------------ + +``pip install JsonPydexer`` + +Usage +----- + +Starting from zero +~~~~~~~~~~~~~~~~~~ + +.. code:: python + + >>>from JsonPydexer import JsonPydexer + >>># initialize with the root directory containing your json files + >>>jp = JsonPydexer("test_data/3") + >>># index on your keys. provide a list of keynamess. keyname elements can be a string for a + >>># field at root level, or a list of strings for nested fields + >>>jp.index(["id", "name", ["field_in_root", "field_below"]]) + +Opening an existing index +~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code:: python + + >>># initialize with the root directory containing your json files and .jp.pkl + >>>jp = JsonPydexer("test_data/3") + >>># get all the files that match a search string for non-unique index + >>>search_string = "alice" + >>>for filename in jp.get_files(["name"], search_string): + >>> print(filename) + 1.json + 3.json + >>># get the file matching a search string for a unique index + >>>filename = jp.get_file(["id"], "id2") + >>>print(filename) + 2.json + +Added, removed, or modified JSON files? Update the index +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code:: python + + >>>jp = JsonPydexer("test_data/3") + >>>jp.update() + +New files in the directory will be added to the index. Coming soon are: +removing files not present in the directory from the index, and checking +for modified files in the directory. From d5805ce74ee14a1c0cf2a3cf95bec4c640457a4e Mon Sep 17 00:00:00 2001 From: Chris B Date: Wed, 14 Mar 2018 21:14:01 -0500 Subject: [PATCH 2/2] includes Index in pypi build --- JsonPydexer.py | 2 +- setup.cfg | 2 +- setup.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/JsonPydexer.py b/JsonPydexer.py index 4648167..bed6ce7 100644 --- a/JsonPydexer.py +++ b/JsonPydexer.py @@ -1,5 +1,5 @@ __author__ = "Christian Bailey (me@christianbailey.me)" -__version__ = "0.3.0" +__version__ = "0.3.1" import os import json diff --git a/setup.cfg b/setup.cfg index b88034e..5aef279 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [metadata] -description-file = README.md +description-file = README.rst diff --git a/setup.py b/setup.py index d856039..9517f80 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ here = path.abspath(path.dirname(__file__)) -with open(path.join(here, "README.md"), encoding="utf-8") as f: +with open(path.join(here, "README.rst"), encoding="utf-8") as f: long_desc = f.read() setup( @@ -27,5 +27,5 @@ packages=find_packages(), install_requires=[], python_requres=">=3", - py_modules=["JsonPydexer"] + py_modules=["JsonPydexer", "Index"] )