-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathlf_json_util.py
More file actions
executable file
·42 lines (33 loc) · 1.31 KB
/
lf_json_util.py
File metadata and controls
executable file
·42 lines (33 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
import argparse
help_summary = '''\
This file contains a helper module standardize_json_results.
standardize_json_results takes a dict of information retrieved from json_get and standardizes
it to use the plural version of the data requested.
The data is returned starting with the "endpoints"
The script will read column data from lanforge GUI using request
'''
def standardize_json_results(results):
# TODO: Add functionality to handle other plural vs singular data representations
if 'endpoints' not in results:
tmp_results = {}
print(results)
results = results['endpoint']
name = results['name'] # noqa: F841
tmp_results['endpoints'] = []
tmp_results['endpoints'].append({results['name']: results})
results = tmp_results
return results['endpoints']
def main():
# Only print help summary when invoked from command line
parser = argparse.ArgumentParser(
prog="lf_json_util.py",
formatter_class=argparse.RawTextHelpFormatter,
description=f"""{help_summary}""")
parser.add_argument('--help_summary', action="store_true", help='Show summary of what this script does')
args = parser.parse_args()
if args.help_summary:
print(help_summary)
exit(0)
if __name__ == "__main__":
main()