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