mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-20 05:14:20 +08:00
Remove trailing space characters (#1256)
Also add two newlines (rebased from `aaronfranke/formatting`) resolves #1220 Co-authored-by: Aaron Franke <arnfranke@yahoo.com>
This commit is contained in:
@@ -15,7 +15,7 @@ import types
|
||||
if len(sys.argv) != 2:
|
||||
print("Usage: %s input-json-file", sys.argv[0])
|
||||
sys.exit(3)
|
||||
|
||||
|
||||
input_path = sys.argv[1]
|
||||
base_path = os.path.splitext(input_path)[0]
|
||||
actual_path = base_path + '.actual'
|
||||
@@ -23,7 +23,7 @@ rewrite_path = base_path + '.rewrite'
|
||||
rewrite_actual_path = base_path + '.actual-rewrite'
|
||||
|
||||
def valueTreeToString(fout, value, path = '.'):
|
||||
ty = type(value)
|
||||
ty = type(value)
|
||||
if ty is types.DictType:
|
||||
fout.write('%s={}\n' % path)
|
||||
suffix = path[-1] != '.' and '.' or ''
|
||||
@@ -49,7 +49,7 @@ def valueTreeToString(fout, value, path = '.'):
|
||||
fout.write('%s=null\n' % path)
|
||||
else:
|
||||
assert False and "Unexpected value type"
|
||||
|
||||
|
||||
def parseAndSaveValueTree(input, actual_path):
|
||||
root = json.loads(input)
|
||||
fout = file(actual_path, 'wt')
|
||||
@@ -62,7 +62,7 @@ def rewriteValueTree(value, rewrite_path):
|
||||
#rewrite = rewrite[1:-1] # Somehow the string is quoted ! jsonpy bug ?
|
||||
file(rewrite_path, 'wt').write(rewrite + '\n')
|
||||
return rewrite
|
||||
|
||||
|
||||
input = file(input_path, 'rt').read()
|
||||
root = parseAndSaveValueTree(input, actual_path)
|
||||
rewrite = rewriteValueTree(json.write(root), rewrite_path)
|
||||
|
Reference in New Issue
Block a user