@sessioned
    def find_streams(self, count=False, stream_id=None, state=None,
                     older_than=None, younger_than=None,
                     name=None, distinguishing_traits=None,
                     session=None, include_events=False,
                     limit=None, mark=None):

        order_desc = True

        q = session.query(models.Stream)
        if mark is not None:
            if mark.startswith('+'):
                order_desc = False
                mark = mark[1:]
            if mark.startswith('-'):
                order_desc = True
                mark = mark[1:]
            if mark:
                if order_desc:
                    q = q.filter(models.Stream.id < int(mark, 16))
                else:
                    q = q.filter(int(mark, 16) > models.Stream.id)
        if stream_id is not None:
            q = q.filter(models.Stream.id == stream_id)
        if state is not None:
            q = q.filter(models.Stream.state == int(state))
        if older_than is not None:
            q = q.filter(models.Stream.first_event < older_than)
        if younger_than is not None:
            q = q.filter(models.Stream.last_event > younger_than)
        if name is not None:
            q = q.filter(models.Stream.name == name)
        if distinguishing_traits is not None:
            for name, val in distinguishing_traits.items():
                q = q.filter(models.Stream.distinguished_by.any(and_(
                    models.DistinguishingTrait.name == name,
                    models.DistinguishingTrait.value == val)))

        if count:
            q = q.count()
            return [{"count": q}]

        if order_desc:
            q = q.order_by(models.Stream.id.desc())
            mark_fmt = '%x'
        else:
            q = q.order_by(models.Stream.id.asc())
            mark_fmt = '+%x'

        if limit is not None:
            q = q.limit(limit)

        stream_info = []
        for stream in q.all():
            info = stream.as_dict
            info['_mark'] = mark_fmt % stream.id
            if include_events:
                info['events'] = self.get_stream_events(
                    stream, session=session)
            stream_info.append(info)
        return stream_info
dataset/ETHPy150Open openstack/stacktach-winchester/winchester/db/interface.py/DBInterface.find_streams/swapped operands of `>`