Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tom Niget
slapos
Commits
3d113b4f
Commit
3d113b4f
authored
Oct 23, 2018
by
Jérome Perrin
Committed by
Rafael Monnerat
Oct 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format-json: change the invocation, we now edit files in-place
parent
5e9fb957
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
15 deletions
+13
-15
format-json
format-json
+13
-15
No files found.
format-json
View file @
3d113b4f
#!/usr/bin/env python
r"""Command-line tool to format software release JSON for slapos.
Inspired by json.tool from python
Inspired by json.tool from python, but enforcing 2 spaces and non-sorted keys.
The files are modified in-place.
Usage::
format-json
infile outfile
format-json
file1.json [file2.json]
"""
...
...
@@ -16,19 +17,16 @@ import collections
def
main
():
if
len
(
sys
.
argv
)
!=
3
:
raise
SystemExit
(
sys
.
argv
[
0
]
+
" infile outfile"
)
with
open
(
sys
.
argv
[
1
],
'rb'
)
as
infile
:
try
:
obj
=
json
.
load
(
infile
,
object_pairs_hook
=
collections
.
OrderedDict
)
except
ValueError
,
e
:
raise
SystemExit
(
e
)
with
open
(
sys
.
argv
[
2
],
'wb'
)
as
outfile
:
json
.
dump
(
obj
,
outfile
,
sort_keys
=
False
,
indent
=
2
,
separators
=
(
','
,
': '
))
outfile
.
write
(
'
\
n
'
)
for
f
in
sys
.
argv
[
1
:]:
with
open
(
f
,
'rb'
)
as
infile
:
try
:
obj
=
json
.
load
(
infile
,
object_pairs_hook
=
collections
.
OrderedDict
)
except
ValueError
as
e
:
raise
SystemExit
(
e
)
with
open
(
f
,
'wb'
)
as
outfile
:
json
.
dump
(
obj
,
outfile
,
sort_keys
=
False
,
indent
=
2
,
separators
=
(
','
,
': '
))
outfile
.
write
(
'
\
n
'
)
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment