File tree Expand file tree Collapse file tree 2 files changed +20
-11
lines changed
Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change 1- import json
1+ import jstyleson
22import glob
33import os
44import sys
5- import urllib .request
65
76from ignore_json import ignore
87
1110for filename in glob .glob (os .path .join ('.' , '*.json' )):
1211 if filename not in ignore :
1312 print (f"Opening: { filename } " )
14- filecontent = open (filename , "r" ).read ()
13+
14+ with open (filename , "r" ) as file :
15+ filecontent = file .read ()
1516
1617 try :
17- json .loads (filecontent )
18+ jstyleson .loads (filecontent )
1819 print (f"✅ JSON valid" )
1920 except Exception as err :
2021 error = True
21- print (f"❌ JSON invalid:" )
22+ print (f"❌ JSON invalid in { filename } :" )
2223 print (str (err ))
2324
2425if error :
Original file line number Diff line number Diff line change 1- import json
1+ import jstyleson
22import glob
33import os
44import sys
1212 if filename not in ignore :
1313 print (f"Opening: { filename } " )
1414 filecontent = open (filename , "r" ).read ()
15- modlist = json .loads (filecontent )
15+
16+ try :
17+ modlist = jstyleson .loads (filecontent )
18+ except Exception as err :
19+ error = True
20+ print (f"❌ Error reading JSON file { filename } : { err } " )
21+ continue
22+
1623 for mod , data in modlist .items ():
1724 url = data ["mod" ].replace (" " , "%20" )
1825 print (f"{ mod } : { url } " )
1926 try :
2027 response = urllib .request .urlopen (url )
2128 print (f"✅ Download successful" )
22- except :
29+ except Exception as err :
2330 error = True
24- print ("❌ Download failed" )
31+ print (f "❌ Download failed: { err } " )
2532 continue
33+
2634 filecontent = response .read ()
27-
35+
2836 try :
29- json .loads (filecontent )
37+ jstyleson .loads (filecontent )
3038 print (f"✅ JSON valid" )
3139 except Exception as err :
3240 error = True
You can’t perform that action at this time.
0 commit comments