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
Joanne Hugé
slapos
Commits
cecf100b
Commit
cecf100b
authored
Sep 03, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format-json: new tool to format software release JSON
parent
880dcfdf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
format-json
format-json
+34
-0
No files found.
format-json
0 → 100755
View file @
cecf100b
#!/usr/bin/env python
r"""Command-line tool to format software release JSON for slapos.
Inspired by json.tool from python
Usage::
format-json infile outfile
"""
import
os
import
sys
import
json
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
'
)
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