def _regex_instance_filter(query, filters):
 model = models.Instance
 (safe_regex_filter, db_regexp_op) = _get_regexp_ops(CONF.database.connection)
 for filter_name in filters:
  try:
   column_attr = getattr(model, filter_name)
  except AttributeError:
   continue
  if ('property' == type(column_attr).__name__):
   continue
  filter_val = filters[filter_name]
  if (not isinstance(filter_val, six.string_types)):
   filter_val = str(filter_val)
  if (db_regexp_op == 'LIKE'):
   query = query.filter(column_attr.op(db_regexp_op)(((u'%' + filter_val) + u'%')))
  else:
   filter_val = safe_regex_filter(filter_val)
   query = query.filter(column_attr.op(db_regexp_op)(filter_val))
 return query

def _regex_instance_filter ( query , filters ) : model = models . Instance ( safe_regex_filter , db_regexp_op ) = _get_regexp_ops ( CONF . database . connection ) for filter_name in filters : try : column_attr = getattr ( model , filter_name ) except AttributeError : continue if ( 'property' == type ( column_attr ) . __name__ ) : continue filter_val = filters [ filter_name ] if ( not isinstance ( filter_val , six . string_types ) ) : filter_val = str ( filter_val ) if ( db_regexp_op == 'LIKE' ) : query = query . filter ( column_attr . op ( db_regexp_op ) ( ( ( u'%' + filter_val ) + u'%' ) ) ) else : filter_val = safe_regex_filter ( filter_val ) query = query . filter ( column_attr . op ( db_regexp_op ) ( filter_val ) ) return query
applies regular expression filtering to an instance query .