Skip to content

Commit

Permalink
Refactor, more descriptive function name
Browse files Browse the repository at this point in the history
  • Loading branch information
OleJoik committed Jun 12, 2024
1 parent f91345f commit 50c893f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions htpy/html2htpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def _get_formatter(
) -> Formatter | None:
formatter: Formatter | None = None
if format == "ruff":
if _is_package_installed("ruff"):
if _is_command_available("ruff"):
formatter = RuffFormatter()
else:
_printerr(
Expand All @@ -277,7 +277,7 @@ def _get_formatter(
sys.exit(1)

if format == "black":
if _is_package_installed("black"):
if _is_command_available("black"):
formatter = BlackFormatter()
else:
_printerr(
Expand All @@ -288,16 +288,16 @@ def _get_formatter(
sys.exit(1)

elif format == "auto":
if _is_package_installed("ruff"):
if _is_command_available("ruff"):
formatter = RuffFormatter()
elif _is_package_installed("black"):
elif _is_command_available("black"):
formatter = BlackFormatter()

return formatter


def _is_package_installed(package_name: str):
return shutil.which(package_name) is not None
def _is_command_available(command: str):
return shutil.which(command) is not None


def main():
Expand Down

0 comments on commit 50c893f

Please sign in to comment.