Skip to main content

A query tool for Python abstract syntax trees

Project description

https://badge.fury.io/py/pyastgrep.svg https://github.com/spookylukey/pyastgrep/actions/workflows/tests.yml/badge.svg https://readthedocs.org/projects/pyastgrep/badge/?version=latest

A command-line utility for grepping Python files using XPath syntax (or CSS selectors) against the Python AST (Abstract Syntax Tree).

In other words, this allows you to search Python code against specific syntax elements (function definitions, arguments, assignments, variables etc), instead of grepping for string matches.

The interface and behaviour is designed to match grep and ripgrep as far as it makes sense to do so.

See the documentation for more information, or the docs folder.

History

This project was forked from https://github.com/hchasestevens/astpath by H. Chase Stevens. Main changes:

  • Added a test suite

  • Many bugs fixed

  • Significant rewrite of parts of code

  • Changes to match grep/ripgrep, including formatting and automatic filtering.

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

pyastgrep-1.3.2.tar.gz (27.7 kB view hashes)

Uploaded Source

Built Distribution

pyastgrep-1.3.2-py3-none-any.whl (21.5 kB view hashes)

Uploaded Python 3

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