def _encode_regex(name, value, dummy0, dummy1):
 flags = value.flags
 if (flags == 0):
  return ((('\x0b' + name) + _make_c_string_check(value.pattern)) + '\x00')
 elif (flags == re.UNICODE):
  return ((('\x0b' + name) + _make_c_string_check(value.pattern)) + 'u\x00')
 else:
  sflags = ''
  if (flags & re.IGNORECASE):
   sflags += 'i'
  if (flags & re.LOCALE):
   sflags += 'l'
  if (flags & re.MULTILINE):
   sflags += 'm'
  if (flags & re.DOTALL):
   sflags += 's'
  if (flags & re.UNICODE):
   sflags += 'u'
  if (flags & re.VERBOSE):
   sflags += 'x'
  sflags += '\x00'
  return ((('\x0b' + name) + _make_c_string_check(value.pattern)) + sflags)

def _encode_regex ( name , value , dummy0 , dummy1 ) : flags = value . flags if ( flags == 0 ) : return ( ( ( '\x0b' + name ) + _make_c_string_check ( value . pattern ) ) + '\x00' ) elif ( flags == re . UNICODE ) : return ( ( ( '\x0b' + name ) + _make_c_string_check ( value . pattern ) ) + 'u\x00' ) else : sflags = '' if ( flags & re . IGNORECASE ) : sflags += 'i' if ( flags & re . LOCALE ) : sflags += 'l' if ( flags & re . MULTILINE ) : sflags += 'm' if ( flags & re . DOTALL ) : sflags += 's' if ( flags & re . UNICODE ) : sflags += 'u' if ( flags & re . VERBOSE ) : sflags += 'x' sflags += '\x00' return ( ( ( '\x0b' + name ) + _make_c_string_check ( value . pattern ) ) + sflags )
encode a python regex or bson .