Skip to content
/ grepy Public

Match regular expressions against python source primitives (e.g. function defs) rather than lines.

Notifications You must be signed in to change notification settings

tomheon/grepy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

grepy

Match regular expressions against logical units in python source (e.g. function or class defs) instead of lines.

Examples

To find all functions in a.py and b.py that contain both 'hello' and goodbye in order in their bodies (perhaps on different lines):

grepy.py -f 'hello.*goodbye' a.py b.py

To find all classes with a method called blah followed by another called heh:

grepy.py -c 'def blah\(.*def heh\(' a.py b.py

How it Works

grepy.py uses the ast module to walk the python source code, and Armin Ronacher's codegen.py to backwards-generate the source to match against from the syntax tree.

Status / Bugs / Etc.

This is very much a proof of concept. I'll probably flesh it out a bit as I see if / how it's useful. Use at your own risk.

About

Match regular expressions against python source primitives (e.g. function defs) rather than lines.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages