4 Commits

Author SHA1 Message Date
Roger Luethi
b69c648337 jsoncheck: make formatting check optional
blueprint modularize-doctest

doctest.py expects to enable syntax checks and formatting checks
individually. This patch changes jsoncheck.py to allow that.

The former boolean "format" argument becomes "formatting", a variable
that can be either "check" or "fix".

A ValueError is thrown if an invalid formatting argument is given to the
function (to be caught by external callers).

Change-Id: If57af0c6f0d46de69c0785635cd57c3a0995654e
2014-06-14 11:13:44 +02:00
Roger Luethi
7c43f2d360 remove jsoncheck's check_format()
blueprint modularize-doctest

The split between process_file (formerly main) and check_format resulted
in a function signature that had three parameters transport four pieces
of information (path indicated whether formatting should take place). The
function used an exception to return a custom warning message when JSON
files were not properly formatted.

This patch merges these two functions and splits out format_parsed_json
instead, which takes one argument and returns formatted JSON. This also
eliminates the FormattingException.

Change-Id: Ia15e862abe181909e4007817c97ceb6ce9e133e7
2014-06-10 07:54:58 +02:00
Roger Luethi
c1542b1a5e jsoncheck: split process_one_file from main
blueprint modularize-doctest

This patch moves most of the code from checkjson's main into a new
function process_file. External users of the module will have their
own filesystem walker, they just use the module to check/format a file
of interest.

Change-Id: I510b5d3d5ea20d2c0a694ef3401eb9fafc15bed4
2014-06-07 10:24:05 +02:00
Roger Luethi
3d61e98305 Add new script jsoncheck.py
Add a new script that can reformat JSON files and check for niceness.
We can use this later as niceness check for openstack-doc-test.

Change-Id: I33c5309bfa2e1abfa6a35d1cfcdc984775e85f05
2014-05-07 22:11:21 +02:00