Exemple #1
0
Fichier : CD.py Projet : rec/grit
def _move_root(forward, prefix=''):
    root = GitRoot.ROOT
    container = GitRoot.root_container()
    roots = sorted(File.each(path=container, select=GitRoot.select(prefix)))

    if roots:
        try:
            index = roots.index(root)
        except ValueError:
            print(roots[0] if forward else roots[-1])
            return
        index += (1 if forward else -1)
        path = roots[index % len(roots)]
        sub = os.path.join(path, os.path.relpath(os.getcwd(), root))
        print((sub if os.path.exists(sub) else path) or '.')
    else:
        print('.')
Exemple #2
0
Fichier : Call.py Projet : rec/grit
def for_each_directory(
        command, select=None, path=None, before=None, after=None, **kwds):
    for f in File.each(path=path, select=select):
        before and before(f)
        call(command, cwd=f, **kwds)
        after and after(f)