Skip to content

Commit

Permalink
sys.argv practice
Browse files Browse the repository at this point in the history
  • Loading branch information
s-shahpouri committed Dec 27, 2024
0 parents commit decfd45
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions sys/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"alpha": 1, "beta": 7, "zetta": true}
18 changes: 18 additions & 0 deletions sys/jformat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os
import sys
import json

def formatter(string, sort_keys=True, indent=4):

loaded_json = json.loads(string)

return json.dumps(loaded_json,sort_keys=sort_keys, indent=indent)


def main(path):
with open(path, 'r') as _f:
print(formatter(_f.read()))


if __name__ == "__main__":
main(sys.argv[-1])

0 comments on commit decfd45

Please sign in to comment.