diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-10-30 15:48:36 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-10-30 15:48:36 -0400 |
commit | 23cfa3e2665c4fdbd22c781fe5b86bf034da71f8 (patch) | |
tree | 1438611b8a3436af86a78efb2824b7fbc5610b83 /cmd2/utils.py | |
parent | 93ec1aa1be8495bf5a131ae4f8f325b574a00332 (diff) | |
download | cmd2-git-23cfa3e2665c4fdbd22c781fe5b86bf034da71f8.tar.gz |
Updated docstring of which to be more accurate in its purpose
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r-- | cmd2/utils.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py index d0ce10bc..88fbc1da 100644 --- a/cmd2/utils.py +++ b/cmd2/utils.py @@ -119,21 +119,21 @@ def cast(current: Any, new: str) -> Any: return current -def which(editor: str) -> Optional[str]: - """Find the full path of a given editor. +def which(exe_name: str) -> Optional[str]: + """Find the full path of a given executable on a Linux or Mac machine - Return the full path of the given editor, or None if the editor can - not be found. - - :param editor: filename of the editor to check, ie 'notepad.exe' or 'vi' - :return: a full path or None + :param exe_name: name of the executable to check, ie 'vi' or 'ls' + :return: a full path or None if exe not found """ + if sys.platform.startswith('win'): + return None + try: - editor_path = subprocess.check_output(['which', editor], stderr=subprocess.STDOUT).strip() - editor_path = editor_path.decode() + exe_path = subprocess.check_output(['which', exe_name], stderr=subprocess.STDOUT).strip() + exe_path = exe_path.decode() except subprocess.CalledProcessError: - editor_path = None - return editor_path + exe_path = None + return exe_path def is_text_file(file_path: str) -> bool: |