Guest User

Untitled

a guest
Feb 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. import json
  2. import sys
  3.  
  4.  
  5. def main():
  6.  
  7. if len(sys.argv) < 2:
  8. print "requires JSON file"
  9. else:
  10. try:
  11. x = json.load(open(sys.argv[1],"rb"))
  12. print "file is correct"
  13. return
  14. except:
  15. pass
  16. file = open(sys.argv[1],"a")
  17. file.write("]")
  18. file.close()
  19. try:
  20. x = json.load(open(sys.argv[1],"rb"))
  21. print "file fixed correctly"
  22. except:
  23. print "file broken"
  24.  
  25.  
  26. if __name__ == "__main__":
  27. main()
Add Comment
Please, Sign In to add comment