コード例 #1
0
ファイル: __init__.py プロジェクト: hweickert/where
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
コード例 #2
0
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
コード例 #3
0
ファイル: test_init.py プロジェクト: hweickert/itermate
def test_imapchain_works():
    assert [1, 2, 3, 6] == list( itermate.imapchain(lambda n: (n, n*2), [1, 3]) )
コード例 #4
0
def test_imapchain_works():
    assert [1, 2, 3,
            6] == list(itermate.imapchain(lambda n: (n, n * 2), [1, 3]))