This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
.. :readme:

JSONConfigParser
================

A JSON config editor built on top of
`jsonpath-rw. <https: github.com="" kennknowles="" python-jsonpath-rw=""/>`__.

Installation
------------

Simple as ``pip install --user jsonconfigparser``

Use
---

Right now there is an example of building a CLI utility in the examples
directory.

It can also be used programmatically as well by importing the
``JSONConfigParser`` class and the commands modules.

CLI App
~~~~~~~

This is built with argparse. Using it is as simple as:

::

jsonconf path/to/conf.json view -p $

That command will view the entire JSON file. Other actions include:

+------------+-----------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| command | description | |
+============+=========================================================================================================================================+==========================================================================================================================================================================================================================+
| addfile | Concatenates a second JSON file onto the current. Warning: This will overwrite any shared keys. | ``jsonconf conf.json addfile -o path/to/other.json`` |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| addfield | Adds a key and value to a specified JSONPath | ``jsonconf conf.json addfield -p $.name -v jsonconfigparser`` |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| append | Appends a value to the specified JSONPath. Optionally, converts the field to another type. Optionally, apply to every found endpoint. | ``jsonconf conf.json append -p $.things.[0] -v "Star bellied sneeches"`` ``jsonconf conf.json append -p $.products.hats -v "23.44" -t float`` ``jsonconf conf.json append -p $.products.[*].descript -v "A thing" -m`` |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| delete | Deletes an item from the specific JSONPath. | ``jsonconf conf.json delete $.products.hats`` |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| edit | Reset the value at the endpoint of the JSONPath | ``jsonconf conf.json edit -p $.products.hats.descript -v "A really cool hat."`` |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| shell | Drop into the interactive prompt. | ``jsonconf conf.json shell`` |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Arguments:

+----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| flags | description |
+================+==========================================================================================================================================================================================================+
| -p/--path | The path flag the only acceptable value is a JSONPath string |
+----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -o/--other | The other file flag, used with addfile to concatenate files together |
+----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -v/--value | The value flag, used with any action that requires a value |
+----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -m/--multi | The multi boolean flag. Currently only used with append action. Defaults to false, if True append will add the value to every path found |
+----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -c/--convert | The conversion flag. Currently only used with append. Defaults to False. If passed, a value must be provided of ``int``, ``float``, ``list``, ``dict``, ``bool``,\ ``str`` or some combination of them |
+----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Interactive Shell Prompt
~~~~~~~~~~~~~~~~~~~~~~~~

This is built with readlines. To enter it, simply run
``jsonconf path/to/conf.json shell``

Executing commands is exactly the same as on the command line, except
the shell can't be reinstantiated inside itself.

To exit, two consecutive keyboard interrupts are needed. If a command is
run between them, then the exit flag is reset.

There is also an extra method available in the shell ``write`` which
saves the current state of the file.

Todo:
-----

There are several things that I want to do, small and big:

- Apply the multiflag where needed.
- Clean up the whole package up and turn what I can into
classes/objects.
- Ability to write to a different file for CLI and Shell.

.. :changelog:

0.1.2 (2014-10-13)
+++++++++++++++++

* Fixed nested dictionary shim.
* More robust error handling in shell (still pretty fragile though)

0.1.0 (2014-10-12)
++++++++++++++++++

* PyPI Launch (holy crap: `pip3 install jsonconfigparser`)
* Minimum viable package (still plenty of errors and features to touch though)
* CLI functionality moved into main app
* Interactive Prompt functionality merged into master
* Several Bug Fixes:
- Shim for nesting dictionaries.
- Consolidated string for root node in several modules

0.0.7 (2014-10-12)
++++++++++++++++++

* Basic interactive prompt
- Tab complete for commands
- Added write command for prompt use
- Handle exiting script with ^C followed by ^C again.
* Better type conversion support
* Moved CLI into package
* Improved docstrings on functions

0.0.5 (2014-11-12)
++++++++++++++++++

* Cleaned up commands module
* Added `act_on_path` and `set_on_path` functions
* Added initialization options on ``JSONConfigParser``
- `storage`: A filepath to write to
- `source`: Initial file to read from
* Replaced fragile, custom value parsing with more robust ``shlex.split``
* Tests added!
* Sorted out some imports
* Initial implementation of conversion functionality
* Updated CLI example

0.0.3 (2014-10-08)
++++++++++++++++++

* Added JSONpath support
* Added function registry with `command` and `call` support

0.0.1 (2014-10-07)
++++++++++++++++++

* Initial concept
Release History

Release History

0.1.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
jsonconfigparser-0.1.2-py3-none-any.whl (15.2 kB) Copy SHA256 Checksum SHA256 3.4 Wheel Oct 13, 2014
jsonconfigparser-0.1.2.tar.gz (12.5 kB) Copy SHA256 Checksum SHA256 Source Oct 13, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting