1010from datetime import datetime
1111from io import open
1212from json import dumps
13- from os import getcwd , path
13+ from pathlib import Path
1414from urllib .parse import parse_qsl , urljoin , urlparse
1515
1616with warnings .catch_warnings ():
@@ -1050,7 +1050,7 @@ def input(self, what):
10501050 return None
10511051 if not isinstance (what , str ):
10521052 return self ._input_json_from_non_string (what )
1053- if path . isfile (what ):
1053+ if Path (what ). is_file ( ):
10541054 return self ._input_json_from_file (what )
10551055 try :
10561056 return self ._input_json_as_string (what )
@@ -1136,7 +1136,7 @@ def output_schema(
11361136 write_mode = "a" if self ._input_boolean (append ) else "w"
11371137 try :
11381138 with open (
1139- path . join ( getcwd (), file_path ) , write_mode , encoding = "utf-8"
1139+ Path . cwd () / file_path , write_mode , encoding = "utf-8"
11401140 ) as file :
11411141 file .write (content )
11421142 except OSError as e :
@@ -1238,7 +1238,7 @@ def output(
12381238 write_mode = "a" if self ._input_boolean (append ) else "w"
12391239 try :
12401240 with open (
1241- path . join ( getcwd (), file_path ) , write_mode , encoding = "utf-8"
1241+ Path . cwd () / file_path , write_mode , encoding = "utf-8"
12421242 ) as file :
12431243 file .write (content )
12441244 except OSError as e :
@@ -1273,10 +1273,12 @@ def rest_instances(self, file_path=None, sort_keys=False):
12731273 outputdir_path = BuiltIn ().get_variable_value ("${OUTPUTDIR}" )
12741274 if self .request ["netloc" ]:
12751275 file_path = (
1276- path . join (outputdir_path , self .request ["netloc" ]) + ".json"
1277- )
1276+ Path (outputdir_path ) / self .request ["netloc" ]
1277+ ). with_suffix ( ".json" )
12781278 else :
1279- file_path = path .join (outputdir_path , "instances" ) + ".json"
1279+ file_path = (Path (outputdir_path ) / "instances" ).with_suffix (
1280+ ".json"
1281+ )
12801282 sort_keys = self ._input_boolean (sort_keys )
12811283 content = dumps (
12821284 self .instances ,
@@ -1287,7 +1289,7 @@ def rest_instances(self, file_path=None, sort_keys=False):
12871289 sort_keys = sort_keys ,
12881290 )
12891291 try :
1290- with open (file_path , "w" , encoding = "utf-8" ) as file :
1292+ with open (Path ( file_path ) , "w" , encoding = "utf-8" ) as file :
12911293 file .write (content )
12921294 except OSError as e :
12931295 raise RuntimeError (
0 commit comments