@@ -50,6 +50,25 @@ impl From<FileStatus> for PyFileStatus {
50
50
}
51
51
}
52
52
53
+ #[ pymethods]
54
+ impl PyFileStatus {
55
+ /// Return a dataclass-esque format for the repr
56
+ fn __repr__ ( & self ) -> String {
57
+ format ! ( "FileStatus(path='{}', length={}, isdir={}, permission={}, owner={}, group={}, modification_time={}, access_time={}, replication={}, blocksize={})" ,
58
+ self . path,
59
+ self . length,
60
+ self . isdir,
61
+ self . permission,
62
+ self . owner,
63
+ self . group,
64
+ self . modification_time,
65
+ self . access_time,
66
+ self . replication. map( |r| r. to_string( ) ) . unwrap_or( "None" . to_string( ) ) ,
67
+ self . blocksize. map( |r| r. to_string( ) ) . unwrap_or( "None" . to_string( ) )
68
+ )
69
+ }
70
+ }
71
+
53
72
#[ pyclass( name = "FileStatusIter" ) ]
54
73
struct PyFileStatusIter {
55
74
inner : ListStatusIterator ,
@@ -96,6 +115,21 @@ impl From<ContentSummary> for PyContentSummary {
96
115
}
97
116
}
98
117
118
+ #[ pymethods]
119
+ impl PyContentSummary {
120
+ /// Return a dataclass-esque format for the repr
121
+ fn __repr__ ( & self ) -> String {
122
+ format ! ( "ContentSummary(length={}, file_count={}, directory_count={}, quota={}, space_consumed={}, space_quota={})" ,
123
+ self . length,
124
+ self . file_count,
125
+ self . directory_count,
126
+ self . quota,
127
+ self . space_consumed,
128
+ self . space_quota,
129
+ )
130
+ }
131
+ }
132
+
99
133
#[ pyclass]
100
134
struct RawFileReader {
101
135
inner : FileReader ,
@@ -173,9 +207,42 @@ impl From<WriteOptions> for PyWriteOptions {
173
207
#[ pymethods]
174
208
impl PyWriteOptions {
175
209
#[ new]
176
- #[ pyo3( signature = ( ) ) ]
177
- pub fn new ( ) -> Self {
178
- Self :: from ( WriteOptions :: default ( ) )
210
+ pub fn new (
211
+ block_size : Option < u64 > ,
212
+ replication : Option < u32 > ,
213
+ permission : Option < u32 > ,
214
+ overwrite : Option < bool > ,
215
+ create_parent : Option < bool > ,
216
+ ) -> Self {
217
+ let mut write_options = WriteOptions :: default ( ) ;
218
+ if let Some ( block_size) = block_size {
219
+ write_options = write_options. block_size ( block_size) ;
220
+ }
221
+ if let Some ( replication) = replication {
222
+ write_options = write_options. replication ( replication) ;
223
+ }
224
+ if let Some ( permission) = permission {
225
+ write_options = write_options. permission ( permission) ;
226
+ }
227
+ if let Some ( overwrite) = overwrite {
228
+ write_options = write_options. overwrite ( overwrite) ;
229
+ }
230
+ if let Some ( create_parent) = create_parent {
231
+ write_options = write_options. create_parent ( create_parent) ;
232
+ }
233
+
234
+ PyWriteOptions :: from ( write_options)
235
+ }
236
+
237
+ /// Return a dataclass-esque format for the repr
238
+ fn __repr__ ( & self ) -> String {
239
+ format ! ( "WriteOptions(block_size={}, replication={}, permission={}, overwrite={}, create_parent={})" ,
240
+ self . block_size. map( |x| x. to_string( ) ) . unwrap_or( "None" . to_string( ) ) ,
241
+ self . replication. map( |x| x. to_string( ) ) . unwrap_or( "None" . to_string( ) ) ,
242
+ self . permission,
243
+ self . overwrite,
244
+ self . create_parent
245
+ )
179
246
}
180
247
}
181
248
0 commit comments