Skip to content

Commit

Permalink
Move optional dependency to where it's needed
Browse files Browse the repository at this point in the history
  • Loading branch information
GjjvdBurg committed Sep 13, 2023
1 parent 9382a44 commit fc2941f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 0 additions & 3 deletions clevercsv/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
def main():
# Check that necessary dependencies are available
import_optional_dependency("wilderness")
import_optional_dependency(
"tabview", raise_on_missing=not sys.platform == "win32"
)

# if so, load the actual main function and call it.
from .console import main as realmain
Expand Down
12 changes: 8 additions & 4 deletions clevercsv/console/commands/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from wilderness import Command

from clevercsv._optional import import_optional_dependency
from clevercsv.exceptions import NoDetectionResult
from clevercsv.wrappers import read_table

Expand Down Expand Up @@ -52,14 +53,17 @@ def register(self):
)

def _tabview(self, rows) -> None:
try:
from tabview import view
except ImportError:
if sys.platform == "win32":
print(
"Error: unfortunately Tabview is not available on Windows.",
"Error: unfortunately Tabview is not available on Windows, so "
"the clevercsv view command is not available",
file=sys.stderr,
)
return

import_optional_dependency("tabview", raise_on_missing=True)
from tabview import view

view(rows)

def handle(self) -> int:
Expand Down

0 comments on commit fc2941f

Please sign in to comment.