Skip to main content

Rust 的 Ropey 库的 Python 绑定。

项目描述

PyRopey

CI 构建状态 最新发布的 蟒蛇版本 文档

Rust 的Ropey库的 Python 绑定。

来自 Ropey 的存储库:Ropey 是 Rust 的 utf8 文本绳索,旨在作为文本编辑器等应用程序的支持文本缓冲区。Ropey 速度快、功能强大,可以轻松处理大量文本和内存不连贯的编辑。

PyRopey 旨在为 Python 世界提供 Rope 的性能和可访问接口。

安装

PyRopey可在任何平台上使用,并且可以安装pip

pip install ropey

注意:PyRopey 目前处于预发布状态,预计会有重大变化

示例用法

改编自 Ropey 的示例。

from ropey import Rope

# Load a text file.
let text = Rope.from_file("my_great_book.txt")

# Print the 516th line (zero-indexed).
print(text.line(515))  # Not implemented yet

# Get the start/end char indices of the line.
let start_idx = text.line_to_char(515)  # Not implemented yet
let end_idx = text.line_to_char(516)

# Remove the line...
text.remove(slice(start_idx, end_idx))

# ...and replace it with something better.
text.insert(start_idx, "The flowers are... so... dunno.\n")

# Print the changes, along with the previous few lines for context.
let start_idx = text.line_to_char(511)
let end_idx = text.line_to_char(516)
print(text.slice(slice(start_idx, end_idx)))  # Not implemented yet

# Write the file back out to disk.
text.write_to_file("my_great_book.txt")

PyRopey 的理念是提供尽可能接近 Ropey 中原始方法的 API。这就是为什么我们建议使用他们的文档了解更多详细信息。

贡献

贡献是非常受欢迎的!这里有几个目标:

  • 实现(几乎)所有方法ropey::Rope
  • 为每个方法编写 Python 测试
  • 为每个方法编写存根
  • 记录每个方法
  • 创建文档,托管在 ReadTheDocs
  • 构建自动化基准以ropey与内置替代方案进行比较

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

ropey-0.0.4_alpha.tar.gz (815.8 kB 查看哈希

已上传 source

内置发行版

ropey-0.0.4_alpha-cp310-none-win_amd64.whl (198.2 kB 查看哈希

已上传 cp310

ropey-0.0.4_alpha-cp39-none-win_amd64.whl (198.1 kB 查看哈希

已上传 cp39

ropey-0.0.4_alpha-cp38-none-win_amd64.whl (198.0 kB 查看哈希

已上传 cp38

ropey-0.0.4_alpha-cp37-none-win_amd64.whl (197.9 kB 查看哈希

已上传 cp37

ropey-0.0.4_alpha-cp36-none-win_amd64.whl (197.5 kB 查看哈希

已上传 cp36