chore: rm loro py (#601)
Some checks are pending
Release WASM / Release (push) Waiting to run
Test All / build (push) Waiting to run

This commit is contained in:
Zixuan Chen 2025-01-04 14:26:19 +08:00 committed by GitHub
parent c7c1e2fa89
commit 46bab49281
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 0 additions and 69 deletions

View file

@ -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" }

View file

@ -1,7 +0,0 @@
# loro-python
```bash
pip3 install maturin
maturin build # or python3 -m maturin build
```

View file

@ -1,6 +0,0 @@
from pyloro import Loro, LoroText;
loro = Loro()
text = loro.get_text("text")
text.insert(loro, 0, "123")
print(text.value())

View file

@ -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::<Loro>()?;
m.add_class::<LoroText>()?;
Ok(())
}