mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 03:25:21 +00:00
added ignore option
This commit is contained in:
parent
8b7a9815d9
commit
c888100470
@ -13,6 +13,7 @@ Options:
|
||||
$ export HTTP_PROXY="http://10.10.1.10:3128"
|
||||
$ export HTTPS_PROXY="https://10.10.1.10:1080"
|
||||
--debug Print debug information
|
||||
--ignore <dirs>... Ignore extra directories
|
||||
--encoding <charset> Use encoding parameter for file open
|
||||
--savepath <file> Save the list of requirements in the given file
|
||||
--force Overwrite existing requirements.txt
|
||||
@ -43,12 +44,13 @@ else:
|
||||
open_func = codecs.open
|
||||
|
||||
|
||||
def get_all_imports(path, encoding=None):
|
||||
def get_all_imports(path, encoding=None, extra_ignore_dirs = []):
|
||||
imports = set()
|
||||
raw_imports = set()
|
||||
candidates = []
|
||||
ignore_errors = False
|
||||
ignore_dirs = [".hg", ".svn", ".git", "__pycache__", "env", "venv"]
|
||||
ignore_dirs.extend(extra_ignore_dirs)
|
||||
|
||||
for root, dirs, files in os.walk(path):
|
||||
dirs[:] = [d for d in dirs if d not in ignore_dirs]
|
||||
@ -193,7 +195,11 @@ def join(f):
|
||||
|
||||
def init(args):
|
||||
encoding = args.get('--encoding')
|
||||
candidates = get_all_imports(args['<path>'], encoding=encoding)
|
||||
extra_ignore_dirs = args.get('--ignore', [])
|
||||
|
||||
candidates = get_all_imports(args['<path>'],
|
||||
encoding=encoding,
|
||||
extra_ignore_dirs = extra_ignore_dirs)
|
||||
candidates = get_pkg_names(candidates)
|
||||
logging.debug("Found imports: " + ", ".join(candidates))
|
||||
pypi_server = "https://pypi.python.org/pypi/"
|
||||
|
Loading…
x
Reference in New Issue
Block a user