Giter Club home page Giter Club logo

ripgrepy's Introduction

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

ripgrepy's People

Contributors

altcoinpirate avatar bobthekingofegypt avatar linalim avatar sboysel avatar securisec avatar securisecctf avatar simonw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.