from datetime import datetime


def parse_timestr(timestr):
    """
    Parse a time string in the format %H:%M:%S with an optional trailing .%f
    """
    if '.' not in timestr:
        timestr = timestr + '.0'
    return datetime.strptime(timestr, "%H:%M:%S.%f")