Parse ISO-8601 duration string.

    Args:
        __string: Duration string to parse
    Returns:
        Parsed delta object

def parse_delta(__string: str) -> datetime.timedelta:
    """Parse ISO-8601 duration string.

    Args:
        __string: Duration string to parse
    Returns:
        Parsed delta object
    """
    if not __string:
        return datetime.timedelta(0)
    match = re.fullmatch(r"""
        P
        ((?P<days>\d+)D)?
        T?
        ((?P<hours>\d{1,2})H)?
        ((?P<minutes>\d{1,2})M)?
        ((?P<seconds>\d{1,2})?((?:\.(?P<microseconds>\d+))?S)?)
    """, __string, re.VERBOSE)
    if not match:
        raise ValueError('Unable to parse delta {!r}'.format(__string))
    match_dict = {k: int(v) if v else 0 for k, v in match.groupdict().items()}
    return datetime.timedelta(**match_dict)