JSON wrapper which inputs to a dictionary and outputs a JSON object
Review Request #11521 — Created March 20, 2021 and submitted
JSON wrapper class which inputs to a dictionary and outputs a JSON object. Class
is defined inrbtools/commands/__init__.py
Command class. New command--json
added to global options, which can be added to any command. When--json
is active
run_from_argv
will print the json object using Python's json library.For a full list of proposed JSON objects for each command see:
https://www.notion.so/reviewboard/a8cd6ee32806415fb7bba484d630863e?v=25fb1c9182064421ab17e55606da765b
Passed all tests in
Command
. Added new tests intest_main.py
for initializing
wrapper, adding key value pairs to dictionary, getting correct JSON string from
dictionary, and printing to output stream with correct JSON string.
Summary | ID |
---|---|
fc3442b40f7688eae2dc8943c3905de1189aba49 | |
93a7f52f930aec3fe39c3d0d9c0f15ee4a14922c | |
8d6ea988b098794628c133cbbcd42f524293d873 | |
312b2d649dc71fa01637c427209d5f972c193402 | |
9ecb2ddb435c1889c5b000d2ad2d57f7bc3f04b8 | |
99df72a53c52f7b839decff237fa694d19baa190 | |
505c93c8f2a525fc8a8114e37b69ccdf4f283b9d | |
1c4e3367bd82af470f4889056c35e1e137b9d9ff | |
c110d05aca25324d53b55ed678169610aa9a7c07 | |
d58d4e8f8bbe7b1c4486479d2d4ebc25cb545010 | |
29daf66756b65033e122b5cb2466e588ad4a7635 | |
a0ee53dabe7e1c7894412281719b38db1410f16f | |
40c9ab291084fd36bed86e74761ed579706a612c | |
fe0dd7c90d293e3885890f4ca3be0dafe506a63a | |
b662b573e9452277ea177d990b2f8d750028f2f2 | |
412f531a218f3c9bf2eac16ebb765ef74d0bcb30 | |
4225f35a6f49eb25af995c27b7cdbc1978a31edc | |
f7e7e1ae2398aaa2aec3e63dcad942edc72a8b3e |
Description | From | Last Updated |
---|---|---|
W293 blank line contains whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
E303 too many blank lines (2) |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
E501 line too long (80 > 79 characters) |
reviewbot | |
This class and all the methods inside need docstrings. Perhaps instead of "Wrapper" (it's not really wrapping anything), just call … |
david | |
W293 blank line contains whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
Let's make the help be something like "Output results as JSON data instead of text" |
david | |
W293 blank line contains whitespace |
reviewbot | |
This comment isn't necessary--the code is pretty self explanatory. |
david | |
Looks like this still needs to be done. But initialize_scm_tool isn't the right place to do it. |
david | |
Let's do import kgb and inherit from kgb.SpyAgency |
david | |
These two lines can be combined: from rbtools.commands import JSONWrapper, main as rbt_main |
david | |
It might be worth defining a setUp method that sets self.json = JSONWrapper(sys.stdout). That way you don't have to do … |
david | |
E303 too many blank lines (2) |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
E501 line too long (80 > 79 characters) |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
E127 continuation line over-indented for visual indent |
reviewbot | |
E501 line too long (83 > 79 characters) |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
I think it might be better to do self.json.add_error(str(e)) because most of the errors raised (ex. CommandError, ApiError) are not … |
amohapatra |
- Commits:
-
Summary ID 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f
Checks run (1 failed, 1 succeeded)
flake8
-
-
This class and all the methods inside need docstrings.
Perhaps instead of "Wrapper" (it's not really wrapping anything), just call it something like "JSONOutput"?
-
-
-
-
-
-
It might be worth defining a
setUp
method that setsself.json = JSONWrapper(sys.stdout)
. That way you don't have to do it individually in each test.
- Commits:
-
Summary ID 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d
Checks run (2 succeeded)
- Commits:
-
Summary ID 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867
- Commits:
-
Summary ID 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac
Checks run (2 succeeded)
- Commits:
-
Summary ID 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac 0e811e589d36ff193279d6e6d8a01a67d9b2074b
- Commits:
-
Summary ID 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac 0e811e589d36ff193279d6e6d8a01a67d9b2074b 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac 0e811e589d36ff193279d6e6d8a01a67d9b2074b b3970c176e63810f47ad5e642d947259d3d54d7a
- Commits:
-
Summary ID 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac 0e811e589d36ff193279d6e6d8a01a67d9b2074b b3970c176e63810f47ad5e642d947259d3d54d7a 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac 0e811e589d36ff193279d6e6d8a01a67d9b2074b b3970c176e63810f47ad5e642d947259d3d54d7a 9623fa15b41db8b60b8ed18fba179b5d94bd0d31
- Commits:
-
Summary ID 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac 0e811e589d36ff193279d6e6d8a01a67d9b2074b b3970c176e63810f47ad5e642d947259d3d54d7a 9623fa15b41db8b60b8ed18fba179b5d94bd0d31 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac 0e811e589d36ff193279d6e6d8a01a67d9b2074b b3970c176e63810f47ad5e642d947259d3d54d7a 9623fa15b41db8b60b8ed18fba179b5d94bd0d31 dc879872ed0c58fb6c82c93663a1c3a54e32e34b
- Commits:
-
Summary ID 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac 0e811e589d36ff193279d6e6d8a01a67d9b2074b b3970c176e63810f47ad5e642d947259d3d54d7a 9623fa15b41db8b60b8ed18fba179b5d94bd0d31 dc879872ed0c58fb6c82c93663a1c3a54e32e34b 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac 0e811e589d36ff193279d6e6d8a01a67d9b2074b b3970c176e63810f47ad5e642d947259d3d54d7a 9623fa15b41db8b60b8ed18fba179b5d94bd0d31 dc879872ed0c58fb6c82c93663a1c3a54e32e34b ae3587acb5acf8b999ab248eb52415d6864748de
Checks run (2 succeeded)
- Commits:
-
Summary ID 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac 0e811e589d36ff193279d6e6d8a01a67d9b2074b b3970c176e63810f47ad5e642d947259d3d54d7a 9623fa15b41db8b60b8ed18fba179b5d94bd0d31 dc879872ed0c58fb6c82c93663a1c3a54e32e34b ae3587acb5acf8b999ab248eb52415d6864748de 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac 0e811e589d36ff193279d6e6d8a01a67d9b2074b b3970c176e63810f47ad5e642d947259d3d54d7a 9623fa15b41db8b60b8ed18fba179b5d94bd0d31 dc879872ed0c58fb6c82c93663a1c3a54e32e34b ae3587acb5acf8b999ab248eb52415d6864748de 21aba6d129b5b7dc5686e4af6ed3430697056994
Checks run (2 succeeded)
- Commits:
-
Summary ID 9bfcd1b986f5b42603b0809c7d78b638f6cee848 fbd48ac58a17e2f8d9feb7a219f66d061eed989c 9cf5b3f5bb931691494dfb7922a5a0c910ea8a2d 2876f2452d8b0655055e362ef6684de8b8e32ae7 bcf004f831c02cbb35dfb5dc3d61b5e3406af2b5 195b6bf5193604d04511431c6761790a033fb74f 6bb1b7d1a5798e5c1b547cc7b705b848b1a4d13d 75af994a92e6b1ebae91f8a5da0ce5cf4aadc867 572bb4ce5998732a35c0380c17bf31d6cef461ac 0e811e589d36ff193279d6e6d8a01a67d9b2074b b3970c176e63810f47ad5e642d947259d3d54d7a 9623fa15b41db8b60b8ed18fba179b5d94bd0d31 dc879872ed0c58fb6c82c93663a1c3a54e32e34b ae3587acb5acf8b999ab248eb52415d6864748de 21aba6d129b5b7dc5686e4af6ed3430697056994 fc3442b40f7688eae2dc8943c3905de1189aba49 93a7f52f930aec3fe39c3d0d9c0f15ee4a14922c 8d6ea988b098794628c133cbbcd42f524293d873 312b2d649dc71fa01637c427209d5f972c193402 9ecb2ddb435c1889c5b000d2ad2d57f7bc3f04b8 99df72a53c52f7b839decff237fa694d19baa190 505c93c8f2a525fc8a8114e37b69ccdf4f283b9d 1c4e3367bd82af470f4889056c35e1e137b9d9ff c110d05aca25324d53b55ed678169610aa9a7c07 d58d4e8f8bbe7b1c4486479d2d4ebc25cb545010 29daf66756b65033e122b5cb2466e588ad4a7635 a0ee53dabe7e1c7894412281719b38db1410f16f 40c9ab291084fd36bed86e74761ed579706a612c fe0dd7c90d293e3885890f4ca3be0dafe506a63a b662b573e9452277ea177d990b2f8d750028f2f2 412f531a218f3c9bf2eac16ebb765ef74d0bcb30 4225f35a6f49eb25af995c27b7cdbc1978a31edc
Checks run (2 succeeded)
- Groups:
- Commits:
-
Summary ID fc3442b40f7688eae2dc8943c3905de1189aba49 93a7f52f930aec3fe39c3d0d9c0f15ee4a14922c 8d6ea988b098794628c133cbbcd42f524293d873 312b2d649dc71fa01637c427209d5f972c193402 9ecb2ddb435c1889c5b000d2ad2d57f7bc3f04b8 99df72a53c52f7b839decff237fa694d19baa190 505c93c8f2a525fc8a8114e37b69ccdf4f283b9d 1c4e3367bd82af470f4889056c35e1e137b9d9ff c110d05aca25324d53b55ed678169610aa9a7c07 d58d4e8f8bbe7b1c4486479d2d4ebc25cb545010 29daf66756b65033e122b5cb2466e588ad4a7635 a0ee53dabe7e1c7894412281719b38db1410f16f 40c9ab291084fd36bed86e74761ed579706a612c fe0dd7c90d293e3885890f4ca3be0dafe506a63a b662b573e9452277ea177d990b2f8d750028f2f2 412f531a218f3c9bf2eac16ebb765ef74d0bcb30 4225f35a6f49eb25af995c27b7cdbc1978a31edc fc3442b40f7688eae2dc8943c3905de1189aba49 93a7f52f930aec3fe39c3d0d9c0f15ee4a14922c 8d6ea988b098794628c133cbbcd42f524293d873 312b2d649dc71fa01637c427209d5f972c193402 9ecb2ddb435c1889c5b000d2ad2d57f7bc3f04b8 99df72a53c52f7b839decff237fa694d19baa190 505c93c8f2a525fc8a8114e37b69ccdf4f283b9d 1c4e3367bd82af470f4889056c35e1e137b9d9ff c110d05aca25324d53b55ed678169610aa9a7c07 d58d4e8f8bbe7b1c4486479d2d4ebc25cb545010 29daf66756b65033e122b5cb2466e588ad4a7635 a0ee53dabe7e1c7894412281719b38db1410f16f 40c9ab291084fd36bed86e74761ed579706a612c fe0dd7c90d293e3885890f4ca3be0dafe506a63a b662b573e9452277ea177d990b2f8d750028f2f2 412f531a218f3c9bf2eac16ebb765ef74d0bcb30 4225f35a6f49eb25af995c27b7cdbc1978a31edc f7e7e1ae2398aaa2aec3e63dcad942edc72a8b3e
Checks run (2 succeeded)
- Description:
-
JSON wrapper class which inputs to a dictionary and outputs a JSON object. Class
is defined in rbtools/commands/__init__.py
Command class. New command--json
added to global options, which can be added to any command. When --json
is activerun_from_argv
will print the json object using Python's json library.+ + For a full list of proposed JSON objects for each command see:
+ https://www.notion.so/reviewboard/a8cd6ee32806415fb7bba484d630863e?v=25fb1c9182064421ab17e55606da765b