Skip to content

Commit

Permalink
use is_readable_dir wherever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Jun 29, 2018
1 parent a4c9b3e commit 08ba46d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/python/pants/backend/native/subsystems/binaries/llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pants.binaries.binary_util import BinaryToolUrlGenerator
from pants.engine.rules import RootRule, rule
from pants.engine.selectors import Select
from pants.util.dirutil import is_readable_dir
from pants.util.memo import memoized_method


Expand Down Expand Up @@ -51,7 +52,7 @@ def select(self):
children = os.listdir(unpacked_path)
if len(children) == 1:
llvm_base_dir = os.path.join(unpacked_path, children[0])
assert(os.path.isdir(llvm_base_dir))
assert(is_readable_dir(llvm_base_dir))
return llvm_base_dir
return unpacked_path

Expand Down
7 changes: 4 additions & 3 deletions src/python/pants/backend/native/subsystems/xcode_cli_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pants.engine.rules import RootRule, rule
from pants.engine.selectors import Select
from pants.subsystem.subsystem import Subsystem
from pants.util.dirutil import is_readable_dir
from pants.util.memo import memoized_method, memoized_property


Expand Down Expand Up @@ -73,13 +74,13 @@ def register_options(cls, register):

@memoized_property
def _all_existing_install_prefixes(self):
return [pfx for pfx in self.get_options().install_prefixes if os.path.isdir(pfx)]
return [pfx for pfx in self.get_options().install_prefixes if is_readable_dir(pfx)]

# NB: We use @memoized_method in this file for methods which may raise.
@memoized_method
def _get_existing_subdirs(self, subdir_name):
maybe_subdirs = [os.path.join(pfx, subdir_name) for pfx in self._all_existing_install_prefixes]
existing_dirs = [existing_dir for existing_dir in maybe_subdirs if os.path.isdir(existing_dir)]
existing_dirs = [existing_dir for existing_dir in maybe_subdirs if is_readable_dir(existing_dir)]

required_files_for_dir = self._REQUIRED_FILES.get(subdir_name)
if required_files_for_dir:
Expand Down Expand Up @@ -123,7 +124,7 @@ def include_dirs(self):
all_inc_dirs = base_inc_dirs
for d in base_inc_dirs:
secure_inc_dir = os.path.join(d, 'secure')
if os.path.isdir(secure_inc_dir):
if is_readable_dir(secure_inc_dir):
all_inc_dirs.append(secure_inc_dir)

return all_inc_dirs
Expand Down

0 comments on commit 08ba46d

Please sign in to comment.