-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57f3043
commit 4d20d86
Showing
6 changed files
with
177 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use object_store::path::Path; | ||
use pyo3::exceptions::PyTypeError; | ||
use pyo3::prelude::*; | ||
|
||
pub(crate) enum PyPaths { | ||
One(Path), | ||
// TODO: also support an Arrow String Array here. | ||
Many(Vec<Path>), | ||
} | ||
|
||
impl<'py> FromPyObject<'py> for PyPaths { | ||
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> { | ||
if let Ok(path) = ob.extract::<String>() { | ||
Ok(Self::One(path.into())) | ||
} else if let Ok(paths) = ob.extract::<Vec<String>>() { | ||
Ok(Self::Many( | ||
paths.into_iter().map(|path| path.into()).collect(), | ||
)) | ||
} else { | ||
Err(PyTypeError::new_err( | ||
"Expected string path or sequence of string paths.", | ||
)) | ||
} | ||
} | ||
} |
Oops, something went wrong.