"""Lexical segment walk for the printed pairs. Does not touch a filesystem.

pathlib.Path.resolve can follow a real disk and symbolic links.
This file does not call it. Authoring did not run this file.
"""


def collapse(base, relative):
    parts = []
    for segment in (base.strip("/") + "/" + relative.strip("/")).split("/"):
        if segment in ("", "."):
            continue
        if segment == "..":
            if parts:
                parts.pop()
            continue
        parts.append(segment)
    return parts


def main():
    worked = collapse("/lab/public", "../draft/note")
    activity = collapse("/lab/public/images", "../../draft/seal")
    print("worked", worked)
    print("activity", activity)


if __name__ == "__main__":
    main()
