@@ -70,7 +70,7 @@ def read_txt_file(file_path: Union[str, Path], skip_empty: bool = False) -> List
70
70
Returns:
71
71
List[str]: A list of strings representing the lines in the text file.
72
72
"""
73
- with open (file_path . as_posix ( ), "r" ) as file :
73
+ with open (str ( file_path ), "r" ) as file :
74
74
if skip_empty :
75
75
lines = [line .rstrip ("\n " ) for line in file if line .strip ()]
76
76
else :
@@ -87,7 +87,7 @@ def save_text_file(lines: List[str], file_path: Union[str, Path]):
87
87
lines (List[str]): The list of strings to be written to the file.
88
88
file_path (Union[str, Path]): The file path as a string or Path object.
89
89
"""
90
- with open (file_path . as_posix ( ), "w" ) as file :
90
+ with open (str ( file_path ), "w" ) as file :
91
91
for line in lines :
92
92
file .write (line + "\n " )
93
93
@@ -102,7 +102,7 @@ def read_json_file(file_path: Union[str, Path]) -> dict:
102
102
Returns:
103
103
dict: A dict of annotations information
104
104
"""
105
- with open (file_path . as_posix ( ), "r" ) as file :
105
+ with open (str ( file_path ), "r" ) as file :
106
106
data = json .load (file )
107
107
return data
108
108
@@ -116,7 +116,7 @@ def save_json_file(data: dict, file_path: Union[str, Path], indent: int = 3) ->
116
116
data (dict): dict with unique keys and value as pair.
117
117
file_path (Union[str, Path]): The file path as a string or Path object.
118
118
"""
119
- with open (file_path . as_posix ( ), "w" ) as fp :
119
+ with open (str ( file_path ), "w" ) as fp :
120
120
json .dump (data , fp , cls = NumpyJsonEncoder , indent = indent )
121
121
122
122
@@ -130,7 +130,7 @@ def read_yaml_file(file_path: Union[str, Path]) -> dict:
130
130
Returns:
131
131
dict: A dict of content information
132
132
"""
133
- with open (file_path . as_posix ( ), "r" ) as file :
133
+ with open (str ( file_path ), "r" ) as file :
134
134
data = yaml .safe_load (file )
135
135
return data
136
136
@@ -145,5 +145,5 @@ def save_yaml_file(data: dict, file_path: Union[str, Path]) -> None:
145
145
file_path (Union[str, Path]): The file path as a string or Path object.
146
146
"""
147
147
148
- with open (file_path . as_posix ( ), "w" ) as outfile :
148
+ with open (str ( file_path ), "w" ) as outfile :
149
149
yaml .dump (data , outfile , sort_keys = False , default_flow_style = None )
0 commit comments