Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some reformatting for more concise printout. #8

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions conda/plugins/subcommands/doctor/health_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@
logger = getLogger(__name__)

OK_MARK = "✅"
REPORT_TITLE = "\nENVIRONMENT HEALTH REPORT\n"
DETAILED_REPORT_TITLE = "\nDETAILED ENVIRONMENT HEALTH REPORT\n"
MISSING_FILES_SUCCESS_MESSAGE = f"{OK_MARK} There are no packages with missing files.\n"
ALTERED_FILES_SUCCESS_MESSAGE = f"{OK_MARK} There are no packages with altered files.\n"


def display_report_heading(prefix: str) -> None:
"""Displays our report heading."""
print("-" * 20)
print(REPORT_TITLE)
print(f"Environment Name: {Path(prefix).name}\n")
print(f"Environment Health Report for: {Path(prefix)}\n")


def find_packages_with_missing_files(prefix: str | Path) -> dict[str, list[str]]:
Expand Down Expand Up @@ -87,30 +81,28 @@ def find_altered_packages(prefix: str | Path) -> dict[str, list[str]]:
def display_health_checks(prefix: str, verbose: bool) -> None:
"""Prints health report."""
display_report_heading(prefix)
print("1. Missing Files:\n")
missing_files = find_packages_with_missing_files(prefix)
if missing_files:
print("Missing Files\n")
for package_name, missing_files in missing_files.items():
if verbose:
delimiter = "\n "
print(f"{package_name}:{delimiter}{delimiter.join(missing_files)}\n")
print(f"{package_name}:{delimiter}{delimiter.join(missing_files)}")
else:
print(f"{package_name}: {len(missing_files)}")

print("\n")
print(f"{package_name}: {len(missing_files)}\n")
else:
print(MISSING_FILES_SUCCESS_MESSAGE)
print(f"{OK_MARK} There are no packages with missing files.\n")

if verbose:
print("")
print("2. Altered Files:\n")
altered_packages = find_altered_packages(prefix)
if altered_packages:
print("Altered Files\n")
for package_name, altered_files in altered_packages.items():
if verbose:
delimiter = "\n "
delimiter = "\n "
print(f"{package_name}:{delimiter}{delimiter.join(altered_files)}\n")
else:
print(f"{package_name}: {len(altered_files)}")

print("\n")
else:
print(ALTERED_FILES_SUCCESS_MESSAGE)
print(f"{OK_MARK} There are no packages with altered files.\n")