Skip to main content

Python bindings for Rust's Ropey library.

Project description

PyRopey

CI Build Status Latest Release Python version Documentation

Python bindings for Rust's Ropey library.

From Ropey's repository: Ropey is a utf8 text rope for Rust, designed to be the backing text-buffer for applications such as text editors. Ropey is fast, robust, and can handle huge texts and memory-incoherent edits with ease.

PyRopey aims to provide the performance and accessible interface of Rope into Python's world.

Installing

PyRopey is available in any platform and can be installed with pip:

pip install ropey

Note: PyRopey is currently in pre-release status and major changes are to be expected.

Example Usage

Adapted from Ropey's example.

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's philosophy is to provide an API that is as close as possible to the original methods in Ropey. This is why we recommend using their documentation for more details.

Contributing

Contributions are more than welcome! Here are a few objectives:

  • Implement (almost) every methods from ropey::Rope
  • Write Python tests for every method
  • Write stubs for every method
  • Document every method
  • Create docs, hosted on ReadTheDocs
  • Build automated benchmarks to compared ropey with builtin alternatives

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ropey-0.0.4_alpha.tar.gz (815.8 kB view hashes)

Uploaded Source

Built Distributions

ropey-0.0.4_alpha-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.0 MB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ x86-64

ropey-0.0.4_alpha-cp310-none-win_amd64.whl (198.2 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

ropey-0.0.4_alpha-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.0 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.5+ x86-64

ropey-0.0.4_alpha-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (589.8 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

ropey-0.0.4_alpha-cp39-none-win_amd64.whl (198.1 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

ropey-0.0.4_alpha-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.0 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.5+ x86-64

ropey-0.0.4_alpha-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (590.3 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

ropey-0.0.4_alpha-cp38-none-win_amd64.whl (198.0 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

ropey-0.0.4_alpha-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.0 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.5+ x86-64

ropey-0.0.4_alpha-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (590.2 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

ropey-0.0.4_alpha-cp37-none-win_amd64.whl (197.9 kB view hashes)

Uploaded CPython 3.7 Windows x86-64

ropey-0.0.4_alpha-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.0 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.5+ x86-64

ropey-0.0.4_alpha-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (590.2 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

ropey-0.0.4_alpha-cp36-none-win_amd64.whl (197.5 kB view hashes)

Uploaded CPython 3.6 Windows x86-64

ropey-0.0.4_alpha-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.0 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.5+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page