FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Aether/srcPython/format_json.py at refs/heads/develop · AetherModel/Aether · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
AetherModel
/
Aether
Public
Notifications
You must be signed in to change notification settings
Fork
31
Star
25
Code
Issues
21
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Aether
/
srcPython
/
format_json.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
56 lines (40 loc) · 1.5 KB
Breadcrumbs
Aether
/
srcPython
/
format_json.py
Copy path
File metadata and controls
executable file
·
56 lines (40 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
import
os
import
argparse
import
json
# ----------------------------------------------------------------------------
# Get arguments as inputs into the code
#-----------------------------------------------------------------------------
def
get_args
():
parser
=
argparse
.
ArgumentParser
(
description
=
'reformat json files'
)
# Get the files to plot:
parser
.
add_argument
(
'filelist'
,
nargs
=
'+'
, \
help
=
'list of files for formatting'
)
args
=
parser
.
parse_args
()
return
args
# ----------------------------------------------------------------------
# do system command
# ----------------------------------------------------------------------
def
run_command
(
command
,
verbose
=
False
):
if
(
verbose
):
print
(
" -> Running Command : "
)
print
(
" "
,
command
)
os
.
system
(
command
)
return
True
# Needed to run main script as the default executable from the command line
if
__name__
==
'__main__'
:
# Get the input arguments
args
=
get_args
()
filelist
=
args
.
filelist
for
file
in
filelist
:
fileSave
=
file
+
'.orig'
command
=
'mv '
+
file
+
' '
+
fileSave
run_command
(
command
,
verbose
=
True
)
with
open
(
fileSave
,
'r'
)
as
handle
:
print
(
'-> Reading : '
,
fileSave
)
parsed
=
json
.
load
(
handle
)
fpOut
=
open
(
file
,
'w'
)
print
(
'-> Writing : '
,
file
)
json
.
dump
(
parsed
,
fpOut
,
indent
=
4
)
fpOut
.
close
()
Back
|
FazBrowse Home
|
New Git URL