@@ -28,13 +28,7 @@ def get_hosts_path(file_path: str) -> Path:
28
28
29
29
@staticmethod
30
30
def get_output_path (file_path : str ) -> Path :
31
- resolved_path = FileUtils .resolve_path (file_path )
32
-
33
- if not resolved_path .exists ():
34
- log .debug ("Path %s is not exists, creating required directories" , resolved_path )
35
- FileUtils .create_file (resolved_path )
36
-
37
- return resolved_path
31
+ return FileUtils .resolve_path (file_path )
38
32
39
33
@staticmethod
40
34
def as_package_file (file_path : str ) -> Path :
@@ -58,10 +52,20 @@ def is_empty(file_path: Path) -> bool:
58
52
59
53
@staticmethod
60
54
def create_file (file_path : Path ) -> None :
61
- if not file_path .is_file ():
62
- try :
63
- file_path .parent .mkdir (parents = True , exist_ok = True )
64
- file_path .touch (exist_ok = True )
65
- except OSError as e :
66
- log .exception ("Failed to create file or directory: %s, reason: %s" , file_path , e .strerror )
67
- sys .exit (1 )
55
+ if not file_path .exists ():
56
+ log .debug ("Path %s is not exists, trying to create required folders and file" , file_path )
57
+
58
+ try :
59
+ file_path .parent .mkdir (parents = True , exist_ok = True )
60
+ file_path .touch (exist_ok = True )
61
+ except OSError as e :
62
+ log .exception ("Failed to create file or directory: %s, reason: %s" , file_path , e .strerror )
63
+ sys .exit (1 )
64
+
65
+ @staticmethod
66
+ def write_text (file_path : Path , data : str ) -> None :
67
+ try :
68
+ file_path .write_text (data )
69
+ except OSError as e :
70
+ log .exception ("Failed to create file or directory: %s, reason: %s" , file_path , e .strerror )
71
+ sys .exit (1 )
0 commit comments