Skip to content
Snippets Groups Projects
Commit d2ac5465 authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

Refactor find_executable into an explicit method. (Re: #283)

parent 34cde92c
No related branches found
No related tags found
No related merge requests found
......@@ -29,9 +29,6 @@ except ImportError:
from .profiling import profile
from .external_tools import EXTERNAL_TOOLS, REMAPPED_TOOL_NAMES, GNU_TOOL_NAMES
# Memoize calls to ``which`` to avoid excessive stat calls
find_executable = functools.lru_cache()(shutil.which)
# The output of --help and --list-tools will use the order of this dict.
# Please keep it alphabetized.
OS_NAMES = collections.OrderedDict(
......@@ -44,6 +41,18 @@ OS_NAMES = collections.OrderedDict(
)
@functools.lru_cache()
def find_executable(cmd):
"""
Given a command name (eg. `dumppdf`), return the absolute path to that
command.
Returns an empy string (``) if no command is found.
"""
return shutil.which(f"{cmd}{suffix}")
def get_tools(only_missing=False):
"""Return the tool configuration in a dict"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment