summaryrefslogtreecommitdiff
path: root/cmd2/utils.py
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-05-24 19:02:32 -0600
committerkotfu <kotfu@kotfu.net>2018-05-24 19:02:32 -0600
commit190fecb34ac91e25f64615f378d6d59ef6d77de8 (patch)
tree3cfa590653af8b7570bd4073384467d2ca736fa0 /cmd2/utils.py
parentdb881e13796abdaabe6cb7d4121389c36e9aa407 (diff)
downloadcmd2-git-190fecb34ac91e25f64615f378d6d59ef6d77de8.tar.gz
Make changes requested in PR #413
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r--cmd2/utils.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py
index a61fd5fd..07969ff1 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -102,6 +102,14 @@ def cast(current, new):
return current
def which(editor: str) -> Optional[str]:
+ """Find the full path of a given editor.
+
+ 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
+ """
import subprocess
try:
editor_path = subprocess.check_output(['which', editor], stderr=subprocess.STDOUT).strip()
@@ -111,9 +119,10 @@ def which(editor: str) -> Optional[str]:
return editor_path
def is_text_file(file_path):
- """
- Returns if a file contains only ASCII or UTF-8 encoded text
+ """Returns if a file contains only ASCII or UTF-8 encoded text
+
:param file_path: path to the file being checked
+ :return: True if the file is a text file, False if it is binary.
"""
import codecs