Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A small utility for searching your source files for specific imports

Project Description
py-import-search
================

Utility to search Python source files for imports matching given patterns.

Installation
------------

```
pip install py-import-search
```

Usage
-----

```
usage: py-import-search [-h] [-p --pattern PATTERN] [-d --dir DIR]
[-r --recursive] [-e --exclude-module MODULE]

Search Python source files for imports

optional arguments:
-h, --help show this help message and exit
-p --pattern PATTERN pattern for matching imports (multiple allowed).
-d --dir DIR path of directory containing Python source files.
-r --recursive read all source files under each directory,
recursively.
-e --exclude-module MODULE
exclude module (multiple allowed).
```

Examples
--------
Print all imports for source files in a directory:
```
$ py-import-search -d .
.../src/py-import-search/setup.py: from setuptools import find_packages
.../src/py-import-search/setup.py: from setuptools import setup
.../src/py-import-search/setup.py: import os
```

Print all imports for source files in a directory all subdirectories:
```
$ py-import-search -d . -r
.../src/py-import-search/setup.py: from setuptools import find_packages
.../src/py-import-search/setup.py: from setuptools import setup
.../src/py-import-search/setup.py: import os
.../src/py-import-search/src/pyimportsearch/__init__.py: import argparse
.../src/py-import-search/src/pyimportsearch/__init__.py: import ast
.../src/py-import-search/src/pyimportsearch/__init__.py: import os
.../src/py-import-search/src/pyimportsearch/__init__.py: import re
```

Print imports matching 'setup':
```
$ py-import-search -d . -p setup
.../src/py-import-search/setup.py: from setuptools import find_packages
.../src/py-import-search/setup.py: from setuptools import setup
```

Print imports matching 'setup$':
```
$ py-import-search -d . -p 'setup$'
.../src/py-import-search/setup.py: from setuptools import setup
```

Print imports matching 'setup$':
```
$ py-import-search -d . -p 'setup$'
.../src/py-import-search/setup.py: from setuptools import setup
```

Print all imports for source files in a directory excluding os module:
```
$ py-import-search -d . -e os
.../src/py-import-search/setup.py: from setuptools import find_packages
.../src/py-import-search/setup.py: from setuptools import setup
```
Release History

Release History

This version
History Node

0.3

History Node

0.2

History Node

0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
py-import-search-0.3.tar.gz (10.6 kB) Copy SHA256 Checksum SHA256 Source Apr 11, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting