File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -93,19 +93,22 @@ def report(self, violations):
9393 string += "\n \n \n "
9494 return string
9595
96- def write_results (self , data , name ):
96+ def write_results (self , data , name = None ):
9797 """
9898 Write JSON to file with the specified name.
9999
100- :param name: Name of file to be written to.
100+ :param name: Path to the file to be written to. If no path is passed
101+ a new file will be created.
101102 :param output: JSON object.
102103 """
103- filepath = os .path .abspath (name )
104+
105+ if name :
106+ filepath = os .path .abspath (name )
107+ else :
108+ filepath = os .path .join (os .path .getcwd (), name )
104109
105110 with open (filepath , "w" , encoding = "utf8" ) as f :
106111 try :
107112 f .write (unicode (json .dumps (data , indent = 4 )))
108113 except NameError :
109114 f .write (json .dumps (data , indent = 4 ))
110- except FileNotFoundError as fnf_error :
111- print (fnf_error )
You can’t perform that action at this time.
0 commit comments