From 46bab49281efd0e065c90e094b754208cbac60b4 Mon Sep 17 00:00:00 2001 From: Zixuan Chen Date: Sat, 4 Jan 2025 14:26:19 +0800 Subject: [PATCH] chore: rm loro py (#601) --- crates/loro-python/Cargo.toml | 12 -------- crates/loro-python/README.md | 7 ----- crates/loro-python/examples/main.py | 6 ---- crates/loro-python/src/lib.rs | 44 ----------------------------- 4 files changed, 69 deletions(-) delete mode 100644 crates/loro-python/Cargo.toml delete mode 100644 crates/loro-python/README.md delete mode 100644 crates/loro-python/examples/main.py delete mode 100644 crates/loro-python/src/lib.rs diff --git a/crates/loro-python/Cargo.toml b/crates/loro-python/Cargo.toml deleted file mode 100644 index 88efff89..00000000 --- a/crates/loro-python/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "pyloro" -version = "0.1.0" -edition = "2021" -license = "MIT" -publish = false - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -pyo3 = { version = "0.17", features = ["extension-module"] } -loro-internal = { path = "../loro-internal" } diff --git a/crates/loro-python/README.md b/crates/loro-python/README.md deleted file mode 100644 index 27f84903..00000000 --- a/crates/loro-python/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# loro-python - -```bash -pip3 install maturin -maturin build # or python3 -m maturin build - -``` diff --git a/crates/loro-python/examples/main.py b/crates/loro-python/examples/main.py deleted file mode 100644 index 07fddbc5..00000000 --- a/crates/loro-python/examples/main.py +++ /dev/null @@ -1,6 +0,0 @@ -from pyloro import Loro, LoroText; - -loro = Loro() -text = loro.get_text("text") -text.insert(loro, 0, "123") -print(text.value()) \ No newline at end of file diff --git a/crates/loro-python/src/lib.rs b/crates/loro-python/src/lib.rs deleted file mode 100644 index 7e20d57c..00000000 --- a/crates/loro-python/src/lib.rs +++ /dev/null @@ -1,44 +0,0 @@ -use std::sync::Arc; - -use loro_internal::{LoroDoc, TextHandler}; -use pyo3::prelude::*; - -#[pyclass] -struct Loro(LoroDoc); - -#[pyclass] -struct LoroText(TextHandler); - -#[pymethods] -impl Loro { - #[new] - pub fn __new__() -> Self { - Self(LoroDoc::default()) - } - - pub fn get_text(&mut self, id: &str) -> LoroText { - let text = self.0.get_text(id); - LoroText(text) - } -} - -#[pymethods] -impl LoroText { - pub fn insert(&mut self, ctx: &Loro, pos: usize, value: &str) -> PyResult<()> { - self.0 - .insert_with_txn(&mut ctx.0.txn().unwrap(), pos, value) - .unwrap(); - Ok(()) - } - - pub fn value(&self) -> String { - Arc::try_unwrap(self.0.get_value().into_string().unwrap()).unwrap_or_else(|x| (*x).clone()) - } -} - -#[pymodule] -fn pyloro(_py: Python, m: &PyModule) -> PyResult<()> { - m.add_class::()?; - m.add_class::()?; - Ok(()) -}