Skip to main content

No project description provided

Project description

Build Status Documentation PyPI

ripgrepy

ripgrepy is a python interface to ripgrep. It is written to support Python 3.7+ only and is built on ripgrep version 11.0.1

For complete usage and details, refer to the docs at

Readthedocs

Instal

Use pip to install

pip install ripgrepy

Requirements

ripgrepy leverages the system ripgrep to run its commands. So either the standalone binary, rg in $PATH or a path to ripgrep needs to be provided.

Usage

Ripgrep is a simple module that allows chaining ripgrep options on top of each other and get the result back. There is a couple of helper methods included to help in parsing, such as the as_dict module which shows all valid matches as a dictionary object.

To instantiate the class, use:

from ripgrepy import Ripgrepy
# The Ripgrepy class takes two arguments. The regex to search for and the folder path to search in

rg = Ripgrepy('he[l]{2}o', '/some/path/to/files')

The syntax for ripgrepy is simliar to that of ripgrep itself.

rg.with_filename().line_number()...run().as_string

# the same can be executed using the rg shorthands

rg.H().n().run().as_string

The above is eqivalent to running

rg --with-filename --line-number "he[l]{2}o" /path/to/some/files

Important run() should always be the last method that is being run followed by one of the output methods. If ripgrep options are placed after run, they will not be part of the command being executed. Refer to Readthedocs for complete documentation. The docs are obtained from ripgreps man pages itself.

Output methods

Output can be obtained using the following three properties

  • as_dict
  • as_json
  • as_string

Not all ripgrep output is compitable with as_dict and as_json output formats

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

ripgrepy-1.0.1.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

ripgrepy-1.0.1-py3-none-any.whl (29.9 kB view details)

Uploaded Python 3

File details

Details for the file ripgrepy-1.0.1.tar.gz.

File metadata

  • Download URL: ripgrepy-1.0.1.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for ripgrepy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0104bf9202146264c73c72c5e0c6a7f241eeea68934268d43ef5fd540331a7ea
MD5 a15396bc777d1ad7db400dec4c0477f3
BLAKE2b-256 c583d447881af9ac9c5aa652a2fa5d57889748c47f809fdc34dd9b2c3a7f11fe

See more details on using hashes here.

File details

Details for the file ripgrepy-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ripgrepy-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 29.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for ripgrepy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 040ea70427f1567ddffe4ba5f7e3e6d492a02b54aea4306022f166336ea0b60e
MD5 73ab5cb31d821618c3ddf5c657617565
BLAKE2b-256 d6fd44647080d1e2dcac7ebab1d8a8df79d7686c7192277a660ac78eab8df2c8

See more details on using hashes here.

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