Skip to content

Commit

Permalink
Slight cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Ryan <dan@danryan.co>
  • Loading branch information
techalchemy committed Nov 14, 2018
1 parent f722121 commit 51319a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/pythonfinder/pythonfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

class Finder(object):
def __init__(self, path=None, system=False, global_search=True, ignore_unsupported=True):
"""Finder A cross-platform Finder for locating python and other executables.
"""
Finder A cross-platform Finder for locating python and other executables.
Searches for python and other specified binaries starting in `path`, if supplied,
but searching the bin path of `sys.executable` if `system=True`, and then
Expand Down
17 changes: 7 additions & 10 deletions src/pythonfinder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@

import vistir

from .environment import PYENV_INSTALLED, PYENV_ROOT, ASDF_INSTALLED, ASDF_DATA_DIR
from .environment import PYENV_ROOT, ASDF_DATA_DIR
from .exceptions import InvalidPythonVersion

six.add_move(six.MovedAttribute("Iterable", "collections", "collections.abc"))
from six.moves import Iterable

try:
from functools import lru_cache
except ImportError:
from backports.functools_lru_cache import lru_cache

six.add_move(six.MovedAttribute("Iterable", "collections", "collections.abc"))
from six.moves import Iterable


PYTHON_IMPLEMENTATIONS = (
"python", "ironpython", "jython", "pypy", "anaconda", "miniconda",
Expand Down Expand Up @@ -64,10 +64,6 @@ def optional_instance_of(cls):
return attr.validators.optional(attr.validators.instance_of(cls))


def path_and_exists(path):
return attr.validators.instance_of(vistir.compat.Path) and path.exists()


def path_is_executable(path):
return os.access(str(path), os.X_OK)

Expand Down Expand Up @@ -95,7 +91,8 @@ def path_is_python(path):

@lru_cache(maxsize=1024)
def ensure_path(path):
"""Given a path (either a string or a Path object), expand variables and return a Path object.
"""
Given a path (either a string or a Path object), expand variables and return a Path object.
:param path: A string or a :class:`~pathlib.Path` object.
:type path: str or :class:`~pathlib.Path`
Expand Down Expand Up @@ -129,7 +126,7 @@ def filter_pythons(path):
path = vistir.compat.Path(str(path))
if not path.is_dir():
return path if path_is_python(path) else None
return filter(lambda x: path_is_python(x), path.iterdir())
return filter(path_is_python, path.iterdir())


# TODO: Port to vistir
Expand Down

0 comments on commit 51319a7

Please sign in to comment.