Seed 2019-06-03

By Max Woerner Chase

I was focused on other stuff again today, and then I tried to write stubs for as many commands as I could think of. I then forgot to do anything resembling TDD, and put together these monstrosities with no tests whatsoever:

def cast_out_different(
    left_list: typing.List[str], right_list: typing.List[str]
) -> typing.Iterable[str]:
    left_set = set(left_list)
    right_set = set(right_list)
    left_list[:] = right_list[:] = sorted(left_set.intersection(right_set))
    yield from left_set.symmetric_difference(right_set)


def compare_trees(left: str, right: str) -> typing.Iterable[str]:
    for (
        (left_dirpath, left_dirnames, left_filenames),
        (right_dirpath, right_dirnames, right_filenames),
    ) in zip(os.walk(left), os.walk(right)):
        yield from cast_out_different(left_dirnames, right_dirnames)
        yield from cast_out_different(left_filenames, right_filenames)
        for fn in left_filenames:
            if not filecmp.cmp(
                os.path.join(left_dirpath, fn),
                os.path.join(right_dirpath, fn),
                shallow=False,
            ):
                yield fn

I'm not at all sure these work right, and I don't know if it's obvious what they're supposed to do. In any case, I'm going to try later to get things set up a little more correctly. Things to do include:

Misc other stuff from today:

I'd better wrap things up now so I have a chance to get on some of that tomorrow. Good night.