def get_selection(args):
    """Parse args of the form LAYOUT, LAYOUT:NAME or LAYOUT:NAME1,NAME2."""
    if not args:
        return [(layout, sorted(specs[layout].keys())) for layout in sorted(specs.keys())]

    errors = []
    selection = []
    for arg in args:
        if ":" in arg:
            layout, names = arg.split(":")
            if layout not in specs:
                errors.append("There is no spec for layout " + layout)
                continue
            names = names.split(",")
            for name in names:
                if name not in specs[layout]:
                    errors.append(f"There is no spec for {layout}:{name}")
            selection.append((layout, names))
        else:
            if arg not in specs:
                errors.append("There is no spec for layout " + arg)
                continue
            selection.append((arg, sorted(specs[arg].keys())))

    if errors:
        raise LookupError("\n".join(errors))

    return selection
Parse args of the form LAYOUT, LAYOUT:NAME or LAYOUT:NAME1,NAME2.
docs/screenshots/take_all.py