def walk(repo, tree, topdown=True):
    names = lambda entries: [e.name for e in entries]

    dirs, nondirs = [], []
    for e in tree:
        is_tree = repo[e.oid].type == pygit2.GIT_OBJ_TREE
        if is_tree:
            dirs.append(e)
        else:
            nondirs.append(e)

    if topdown:
        yield tree, names(dirs), names(nondirs)
    for entry in dirs:
        new_tree = repo[entry.oid]
        for x in walk(repo, new_tree, topdown):
            yield x
    if not topdown:
        yield tree, names(dirs), names(nondirs)
Helper to parse the input from the user into a list of rules.
dataset/ETHPy150Open bendavis78/python-gitmodel/gitmodel/utils/path.py/walk--crossover with--dataset/ETHPy150Open softlayer/softlayer-python/SoftLayer/CLI/firewall/edit.py/parse_rules