[CHANGED] removed python program to pretty print JSON, used jj in Ruby instead.

This commit is contained in:
Sami Samhuri 2009-11-27 07:44:29 -08:00
parent 32f7a8ac7b
commit 157503c13c
2 changed files with 9 additions and 38 deletions

View file

@ -3,6 +3,7 @@
require 'rubygems'
require 'json'
require 'fileutils'
require 'stringio'
def inject
FileUtils.cp_r(mojo_ext_path, target_mojo_ext_path)
@ -27,9 +28,15 @@ def sources_file
end
def save_sources!
# capture pretty-print output to string
pretty_json = StringIO.new
orig_stdout = $stdout
$stdout = pretty_json
jj sources
$stdout = orig_stdout
pretty_json.rewind()
FileUtils.mv(sources_file, File.join(project_path, 'sources.json-backup'))
File.open(sources_file, 'w') {|f| f.puts(sources.to_json)}
`./prettyprint.py "#{sources_file}" "#{sources_file}"`
File.open(sources_file, 'w') {|f| f.puts(pretty_json.read)}
end
def project_path

View file

@ -1,36 +0,0 @@
#!/usr/bin/env python
"""
Convert JSON data to human-readable form.
Usage:
prettyJSON.py inputFile [outputFile]
"""
import sys
import simplejson as json
def main(args):
try:
inputFile = open(args[1])
input = json.load(inputFile)
inputFile.close()
except IndexError:
usage()
return False
if len(args) < 3:
print json.dumps(input, sort_keys = False, indent = 4)
else:
outputFile = open(args[2], "w")
json.dump(input, outputFile, sort_keys = False, indent = 4)
outputFile.close()
return True
def usage():
print __doc__
if __name__ == "__main__":
sys.exit(not main(sys.argv))