def dqsegdb2_query_segments(result, deactivated=False,<EOL>active_indicates_ifo_badness=False, **kwargs):
def query_segments(flag, start, end, host=None):<EOL><INDENT>try:<EOL><INDENT>ifo, name, version = flag.split('<STR_LIT::>')<EOL>version = int(version)<EOL><DEDENT>except ValueError:<EOL><INDENT>ifo, name = flag.split('<STR_LIT::>', <NUM_LIT:1>)<EOL>version = None<EOL><DEDENT>span = SegmentList([Segment(start, end)])<EOL>reflag = re.compile(flag)<EOL>try:<EOL><INDENT>actual = list(filter(reflag.match, result))[<NUM_LIT:0>]<EOL><DEDENT>except IndexError:<EOL><INDENT>raise HTTPError('<STR_LIT>', <NUM_LIT>, '<STR_LIT>', None, None)<EOL><DEDENT>return {<EOL>'<STR_LIT>': ifo,<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT:version>': version,<EOL>'<STR_LIT>': list(map(tuple, result[actual].known & span)),<EOL>'<STR_LIT>': list(map(tuple, result[actual].active & span)),<EOL>'<STR_LIT>': {},<EOL>'<STR_LIT>': kwargs,<EOL>}<EOL><DEDENT>return query_segments<EOL>
Build a mock of `dqsegdb2.query.query_segments` for testing