Add is_exe function to filesystem.

This commit is contained in:
Todd Gamblin 2015-01-22 13:52:28 -08:00
parent 4e3662f318
commit e6b4530234

View File

@ -24,7 +24,7 @@
############################################################################## ##############################################################################
__all__ = ['set_install_permissions', 'install', 'expand_user', 'working_dir', __all__ = ['set_install_permissions', 'install', 'expand_user', 'working_dir',
'touch', 'mkdirp', 'force_remove', 'join_path', 'ancestor', 'touch', 'mkdirp', 'force_remove', 'join_path', 'ancestor',
'can_access', 'filter_file', 'change_sed_delimiter'] 'can_access', 'filter_file', 'change_sed_delimiter', 'is_exe']
import os import os
import sys import sys
@ -154,6 +154,11 @@ def install(src, dest):
os.chmod(dest, dest_mode) os.chmod(dest, dest_mode)
def is_exe(path):
"""True if path is an executable file."""
return os.path.isfile(path) and os.access(path, os.X_OK)
def expand_user(path): def expand_user(path):
"""Find instances of '%u' in a path and replace with the current user's """Find instances of '%u' in a path and replace with the current user's
username.""" username."""