diff --git a/news/2527.feature b/news/2527.feature index e8148a59..ad8e5c30 100644 --- a/news/2527.feature +++ b/news/2527.feature @@ -1,2 +1,2 @@ -Added environment variable `PIPENV_VERBOSITY` to control output verbosity -without needing to pass options. +Added environment variables `PIPENV_VERBOSE` and `PIPENV_QUIET` to control +output verbosity without needing to pass options. diff --git a/pipenv/environments.py b/pipenv/environments.py index b589b9ef..0e21ca3b 100644 --- a/pipenv/environments.py +++ b/pipenv/environments.py @@ -150,7 +150,6 @@ PIPENV_QUIET = bool(os.environ.get("PIPENV_QUIET")) """If set, makes Pipenv quieter. Default is unset, for normal verbosity. ``PIPENV_VERBOSE`` overrides this. -See also ``PIPENV_VERBOSITY``. """ PIPENV_SHELL = os.environ.get("PIPENV_SHELL") @@ -185,29 +184,9 @@ PIPENV_VERBOSE = bool(os.environ.get("PIPENV_VERBOSE")) """If set, makes Pipenv more wordy. Default is unset, for normal verbosity. This takes precedence over -``PIPENV_QUIET``. See also ``PIPENV_VERBOSITY``. +``PIPENV_QUIET``. """ -PIPENV_VERBOSITY = os.environ.get("PIPENV_VERBOSITY", "") -"""Verbosity setting for pipenv. - -Higher values make pipenv more verbose, lower values less so. Default is 0, -for normal verbosity. This takes precedence over both ``PIPENV_QUIET`` and -``PIPENV_VERBOSE``. -""" -# Consolidate the verbosity flags. -if PIPENV_VERBOSITY.isdigit(): - PIPENV_VERBOSITY = int(PIPENV_VERBOSITY) -else: - if PIPENV_VERBOSE: - PIPENV_VERBOSITY = 1 - elif PIPENV_QUIET: - PIPENV_VERBOSITY = -1 - else: - PIPENV_VERBOSITY = 0 -del PIPENV_QUIET -del PIPENV_VERBOSE - PIPENV_YES = bool(os.environ.get("PIPENV_YES")) """If set, Pipenv automatically assumes "yes" at all prompts. @@ -216,14 +195,6 @@ if interactive. """ -def is_verbose(threshold=1): - return PIPENV_VERBOSITY >= threshold - - -def is_quiet(threshold=-1): - return PIPENV_VERBOSITY <= threshold - - # Internal, support running in a different Python from sys.executable. PIPENV_PYTHON = os.environ.get("PIPENV_PYTHON") @@ -250,3 +221,27 @@ PIPENV_SHELL = ( # Internal, to tell whether the command line session is interactive. SESSION_IS_INTERACTIVE = bool(os.isatty(sys.stdout.fileno())) + + +# Internal, consolidated verbosity representation as an integer. The default +# level is 0, increased for wordiness and decreased for terseness. +PIPENV_VERBOSITY = os.environ.get("PIPENV_VERBOSITY", "") +if PIPENV_VERBOSITY.isdigit(): + PIPENV_VERBOSITY = int(PIPENV_VERBOSITY) +else: + if PIPENV_VERBOSE: + PIPENV_VERBOSITY = 1 + elif PIPENV_QUIET: + PIPENV_VERBOSITY = -1 + else: + PIPENV_VERBOSITY = 0 +del PIPENV_QUIET +del PIPENV_VERBOSE + + +def is_verbose(threshold=1): + return PIPENV_VERBOSITY >= threshold + + +def is_quiet(threshold=-1): + return PIPENV_VERBOSITY <= threshold