def _parse_query_segments(args, func):
    """Parse *args for query_dqsegdb() or query_segdb()

    Returns a SegmentList in all cases
    """
    # user passed SegmentList
    if len(args) == 1 and isinstance(args[0], SegmentList):
        return args[0]

    # otherwise unpack two arguments as a segment
    if len(args) == 1:
        args = args[0]

    # if not two arguments, panic
    try:
        start, end = args
    except ValueError as exc:
        exc.args = ('{0}() takes 2 arguments for start and end GPS time, '
                    'or 1 argument containing a Segment or SegmentList'.format(
                        func.__name__),)
        raise

    # return list with one Segment
    return SegmentList([Segment(to_gps(start), to_gps(end))])
Parse *args for query_dqsegdb() or query_segdb()

    Returns a SegmentList in all cases