def _gen_possible_matches( filename ): path_parts = os.environ.get("PATH", "").split( os.pathsep ) path_parts = itertools.chain( (os.curdir,), path_parts ) possible_paths = map( lambda path_part: os.path.join(path_part, filename), path_parts ) if platform.system() == "Windows": possible_paths = itermate.imapchain( lambda path: (path, path+".bat", path+".com", path+".exe"), possible_paths ) possible_paths = map( os.path.abspath, possible_paths ) result = itermate.unique( possible_paths ) return result
def _gen_possible_matches(filename): path_parts = os.environ.get("PATH", "").split(os.pathsep) path_parts = itertools.chain((os.curdir, ), path_parts) possible_paths = map(lambda path_part: os.path.join(path_part, filename), path_parts) if platform.system() == "Windows": possible_paths = itermate.imapchain( lambda path: (path, path + ".bat", path + ".com", path + ".exe"), possible_paths) possible_paths = map(os.path.abspath, possible_paths) result = itermate.unique(possible_paths) return result
def test_imapchain_works(): assert [1, 2, 3, 6] == list( itermate.imapchain(lambda n: (n, n*2), [1, 3]) )
def test_imapchain_works(): assert [1, 2, 3, 6] == list(itermate.imapchain(lambda n: (n, n * 2), [1, 3]))