File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change 2
2
import sys
3
3
import json
4
4
import os
5
+ import logging
5
6
from .file_peeking import get_structure
6
7
7
8
@@ -27,27 +28,20 @@ def run_from_command():
27
28
dataset_file = args .dataset [0 ]
28
29
29
30
if not os .path .isfile (dataset_file ):
30
- print (
31
- f"\033 [91mError: JSON file '{ dataset_file } ' not found.\033 [0m" ,
32
- file = sys .stderr ,
33
- )
31
+ logging .error (f"Error: JSON file '{ dataset_file } ' not found." )
34
32
sys .exit (1 )
35
33
36
34
try :
37
35
with open (dataset_file , "r" ) as f :
38
36
dataset = json .load (f )
39
37
40
38
if not isinstance (dataset , dict ):
41
- print (
42
- f"\033 [91mError: The JSON file must contain a dictionary.\033 [0m" ,
43
- file = sys .stderr ,
44
- )
39
+ logging .error (f"Error: The JSON file must contain a dictionary." )
45
40
sys .exit (1 )
46
41
47
42
except json .JSONDecodeError :
48
- print (
49
- f"\033 [91mError: '{ dataset_file } ' is not a valid JSON file.\033 [0m" ,
50
- file = sys .stderr ,
43
+ logging .error (
44
+ f"Error: '{ dataset_file } ' is not a valid JSON file." , exc_info = True
51
45
)
52
46
sys .exit (1 )
53
47
You can’t perform that action at this time.
0 commit comments