Skip to main content

Find python identifiers

Project description

Ever tried to refactor some python code and trying to find out where you're code is used?

find . -name \*.py | xargs grep foo.bar

is kinda nice, but it'll find imports, comments, and whatnot.

Meet pygrep, it allows you to find all references to your code,

pygrep foo.bar some/dir other/stuff.py

That will show you some output like

file.py(Class.function):lineno foo.bar.full.identifier

In file.py, there's a reference to foo.bar.full.identifier in the method function in class Class.

Supported

At this point, pygrep resolves

from foo import bar

and

from foo import bar as baz

Example

Given this python file foo.py

from mymod.bar import stuff as a
class A:
    def m(self):
        b = a.mod.method()

all the following commands

pygrep mymod foo.py
pygrep mymod.bar foo.py
pygrep mymod.bar.mod foo.py
pygrep mymod.bar.mod.method foo.py

will return

foo.py(A.m):4 mymod.bar.mod.method

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

pygrep-0.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

pygrep-0.3-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file pygrep-0.3.tar.gz.

File metadata

  • Download URL: pygrep-0.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pygrep-0.3.tar.gz
Algorithm Hash digest
SHA256 18691344afafb1d3fbb028f140fd267af83d761ae93076bbdd99725f969eadd9
MD5 912e9e183228e809917989979aec1d52
BLAKE2b-256 aa3d09412340e71afe576c5534948fb3a65fa9ffd789215431b9209af488bd82

See more details on using hashes here.

File details

Details for the file pygrep-0.3-py3-none-any.whl.

File metadata

  • Download URL: pygrep-0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pygrep-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f1d1f0e6203b69c82f7ac824c687d6f61185b098cfca14c613447795c7683b65
MD5 fd187c248ee15f3bafe6bfea6b8ee4e8
BLAKE2b-256 8229de17971d907e39a3ffd5a2ce73f3ebd5e4259c8491cbfc09b85fb9cb2286

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