@@ -88,46 +88,62 @@ def __exit__(self, *_args):
88
88
89
89
class Client :
90
90
91
- def __init__ (self , url : str , config : Optional [Dict [str , str ]] = None ):
91
+ def __init__ (
92
+ self ,
93
+ url : Optional [str ] = None ,
94
+ config : Optional [Dict [str , str ]] = None ,
95
+ ):
92
96
self .inner = RawClient (url , config )
93
97
94
98
def get_file_info (self , path : str ) -> "FileStatus" :
95
99
"""Gets the file status for the file at `path`"""
96
100
return self .inner .get_file_info (path )
97
101
98
- def list_status (self , path : str , recursive : bool ) -> Iterator ["FileStatus" ]:
102
+ def list_status (self , path : str , recursive : bool = False ) -> Iterator ["FileStatus" ]:
99
103
"""Gets the status of files rooted at `path`. If `recursive` is true, lists all files recursively."""
100
104
return self .inner .list_status (path , recursive )
101
105
102
106
def read (self , path : str ) -> FileReader :
103
107
"""Opens a file for reading at `path`"""
104
108
return FileReader (self .inner .read (path ))
105
109
106
- def create (self , path : str , write_options : WriteOptions ) -> FileWriter :
110
+ def create (
111
+ self ,
112
+ path : str ,
113
+ write_options : Optional [WriteOptions ] = None ,
114
+ ) -> FileWriter :
107
115
"""Creates a new file and opens it for writing at `path`"""
116
+ if not write_options :
117
+ write_options = WriteOptions ()
118
+
108
119
return FileWriter (self .inner .create (path , write_options ))
109
120
110
121
def append (self , path : str ) -> FileWriter :
111
122
"""Opens an existing file to append to at `path`"""
112
123
return FileWriter (self .inner .append (path ))
113
124
114
- def mkdirs (self , path : str , permission : int , create_parent : bool ) -> None :
125
+ def mkdirs (
126
+ self ,
127
+ path : str ,
128
+ permission : int = 0o0755 ,
129
+ create_parent : bool = False ,
130
+ ) -> None :
115
131
"""
116
132
Creates a directory at `path` with unix permissions `permission`. If `create_parent` is true,
117
133
any parent directories that don't exist will also be created. Otherwise this will fail if
118
134
all parent directories don't already exist.
119
135
"""
120
136
return self .inner .mkdirs (path , permission , create_parent )
121
137
122
- def rename (self , src : str , dst : str , overwrite : bool ) -> None :
138
+ def rename (self , src : str , dst : str , overwrite : bool = False ) -> None :
123
139
"""
124
140
Moves a file or directory from `src` to `dst`. If `overwrite` is True, the destination will be
125
141
overriden if it already exists, otherwise the operation will fail if the destination
126
142
exists.
127
143
"""
128
144
return self .inner .rename (src , dst , overwrite )
129
145
130
- def delete (self , path : str , recursive : bool ) -> bool :
146
+ def delete (self , path : str , recursive : bool = False ) -> bool :
131
147
"""
132
148
Deletes a file or directory at `path`. If `recursive` is True and the target is a directory,
133
149
this will delete all contents underneath the directory. If `recursive` is False and the target
0 commit comments