def retrieve_backups(filename, directory):
    """Return list of existing backups.

    Works by listing paths that are considered backups of
    the file with the given name, in the given directory.

    Also, the backups are sorted so that the oldest backups
    appear at the end of the list.

    Parameters
    ==========

    filename (string)
        name of the file for whose backups we are looking
        for.
    directory (pathlib.Path instance)
        directory wherein to look for backups.
    """
    ### return list of backups, sorted so that the oldest
    ### backups appear last

    return sorted(
        ## all backups
        (
            ## backups are items within the given directory...
            item
            for item in directory.iterdir()
            ## ...whose digits before the last 20 ones are
            ## equal to the original path name (we use 20
            ## instead of 19 to account for the '.' before the
            ## timestamp)...
            if item.name[:-20] == filename
            ## ...and whose last 19 digits are a timestamp,
            ## that is, they match our timestamp pattern
            if fullmatch(TIMESTAMP_PATTERN, item.name[-19:])
        ),
        ## sorted by their timestamps
        key=lambda item: item.name[-19:],
        ## in reverse order
        reverse=True,
    )
Return list of existing backups.

    Works by listing paths that are considered backups of
    the file with the given name, in the given directory.

    Also, the backups are sorted so that the oldest backups
    appear at the end of the list.

    Parameters
    ==========

    filename (string)
        name of the file for whose backups we are looking
        for.
    directory (pathlib.Path instance)
        directory wherein to look for backups.
    
nodezator/ourstdlibs/path.py