Skip to content

Commit b65ff30

Browse files
committed
Remove secho from pipenv.utils.pipfile
1 parent 1a36809 commit b65ff30

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

pipenv/utils/pipfile.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22

33
from pipenv import environments, exceptions
44
from pipenv.patched.pip._vendor import rich
5+
from pipenv.utils import console, err
56
from pipenv.utils.requirements import import_requirements
6-
from pipenv.vendor import click
7-
8-
console = rich.console.Console()
9-
err = rich.console.Console(stderr=True)
107

118

129
def walk_up(bottom):
@@ -74,12 +71,8 @@ def ensure_pipfile(project, validate=True, skip_requirements=False, system=False
7471
# If there's a requirements file, but no Pipfile...
7572
if project.requirements_exists and not skip_requirements:
7673
requirements_dir_path = os.path.dirname(project.requirements_location)
77-
click.echo(
78-
"{} found in {} instead of {}! Converting...".format(
79-
click.style("requirements.txt", bold=True),
80-
click.style(requirements_dir_path, fg="yellow", bold=True),
81-
click.style("Pipfile", bold=True),
82-
)
74+
console.print(
75+
f"[bold]requirements.txt[/bold] found in [bold yellow]{requirements_dir_path}[/bold yellow] instead of [bold]Pipfile[/bold]! Converting...".
8376
)
8477
# Create a Pipfile...
8578
project.create_pipfile(python=python)
@@ -96,18 +89,12 @@ def ensure_pipfile(project, validate=True, skip_requirements=False, system=False
9689
environments.PIPENV_SPINNER_OK_TEXT.format("Success!")
9790
)
9891
# Warn the user of side-effects.
99-
click.echo(
100-
"{0}: Your {1} now contains pinned versions, if your {2} did. \n"
101-
"We recommend updating your {1} to specify the {3} version, instead."
102-
"".format(
103-
click.style("Warning", fg="red", bold=True),
104-
click.style("Pipfile", bold=True),
105-
click.style("requirements.txt", bold=True),
106-
click.style('"*"', bold=True),
107-
)
92+
console.print(
93+
"[bold red]Warning[/bold red]: Your [bold]Pipfile[/bold] now contains pinned versions, if your [bold]requirements.txt[/bold] did. \n"
94+
"We recommend updating your [bold]Pipfile[/bold] to specify the [bold]"*"[/bold] version, instead."
10895
)
10996
else:
110-
click.secho("Creating a Pipfile for this project...", bold=True, err=True)
97+
err.print("Creating a Pipfile for this project...", style="bold")
11198
# Create the pipfile if it doesn't exist.
11299
project.create_pipfile(python=python)
113100
# Validate the Pipfile's contents.
@@ -117,7 +104,5 @@ def ensure_pipfile(project, validate=True, skip_requirements=False, system=False
117104
changed = project.ensure_proper_casing()
118105
# Write changes out to disk.
119106
if changed:
120-
click.echo(
121-
click.style("Fixing package names in Pipfile...", bold=True), err=True
122-
)
107+
err.print("Fixing package names in Pipfile...", style="bold")
123108
project.write_toml(p)

0 commit comments

Comments
 (0)