'Try to extract transforms and lookup from given lhs.
The lhs value is something that works like SQLExpression.
The rhs value is what the lookup is going to compare against.
The lookups is a list of names to extract using get_lookup()
and get_transform().'

def build_lookup(self, lookups, lhs, rhs):

    if (len(lookups) == 0):
        lookups = ['exact']
    for name in lookups[:(-1)]:
        lhs = self.try_transform(lhs, name)
    lookup_class = lhs.get_lookup(lookups[(-1)])
    if (not lookup_class):
        if lhs.field.is_relation:
            raise FieldError('Related    Field    got    invalid    lookup:    {}'.format(lookups[(-1)]))
        lhs = self.try_transform(lhs, lookups[(-1)])
        lookup_class = lhs.get_lookup('exact')
    if (not lookup_class):
        return
    lookup = lookup_class(lhs, rhs)
    if (lookup.rhs is None):
        if (lookup.lookup_name not in ('exact', 'iexact')):
            raise ValueError('Cannot    use    None    as    a    query    value')
        return lhs.get_lookup('isnull')(lhs, True)
    if (connections[DEFAULT_DB_ALIAS].features.interprets_empty_strings_as_nulls and (lookup.lookup_name == 'exact') and (lookup.rhs == '')):
        return lhs.get_lookup('isnull')(lhs, True)
    return lookup
