Xuanwo commented on code in PR #6054:
URL: https://github.com/apache/opendal/pull/6054#discussion_r2051637221
##########
bindings/python/python/opendal/__init__.pyi:
##########
@@ -282,19 +284,31 @@ class AsyncOperator(_Base):
Returns:
True if the object exists, False otherwise.
"""
- async def list(self, path: PathBuf) -> AsyncIterable[Entry]:
+ async def list(
+ self, path: PathBuf, *, start_after: str | None = None
+ ) -> AsyncIterable[Entry]:
"""List the objects at the given path.
Args:
path (str|Path): The path to the directory.
+ start_after (str | None): The key to start listing from.
Returns:
An iterable of entries representing the objects in the directory.
"""
- async def scan(self, path: PathBuf) -> AsyncIterable[Entry]: ...
- async def presign_stat(
- self, path: PathBuf, expire_second: int
- ) -> PresignedRequest:
+ async def scan(
Review Comment:
Scan should be replaced by `list(recursive=True)`. We can add this for list
first.
##########
bindings/python/src/operator.rs:
##########
@@ -503,27 +508,43 @@ impl AsyncOperator {
}
/// List current dir path.
- pub fn list<'p>(&'p self, py: Python<'p>, path: PathBuf) ->
PyResult<Bound<'p, PyAny>> {
+ #[pyo3(signature = (path, *, start_after=None))]
+ pub fn list<'p>(
+ &'p self,
+ py: Python<'p>,
+ path: PathBuf,
+ start_after: Option<String>,
+ ) -> PyResult<Bound<'p, PyAny>> {
let this = self.core.clone();
let path = path.to_string_lossy().to_string();
future_into_py(py, async move {
- let lister = this.lister(&path).await.map_err(format_pyerr)?;
+ let mut builder = this.lister_with(&path);
+ if let Some(start_after) = start_after {
+ builder = builder.start_after(&start_after);
+ }
+ let lister = builder.await.map_err(format_pyerr)?;
let pylister = Python::with_gil(|py|
AsyncLister::new(lister).into_py_any(py))?;
Ok(pylister)
})
}
/// List dir in flat way.
- pub fn scan<'p>(&'p self, py: Python<'p>, path: PathBuf) ->
PyResult<Bound<'p, PyAny>> {
+ #[pyo3(signature = (path, *, start_after=None))]
+ pub fn scan<'p>(
Review Comment:
Let's keep `scan` unchanged, we will deprecate this API in the future.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]