def check_regexp(option, opt, value):
 if hasattr(value, 'pattern'):
  return value
 try:
  return re.compile(value)
 except ValueError:
  raise OptionValueError(('option %s: invalid regexp value: %r' % (opt, value)))

def check_regexp ( option , opt , value ) : if hasattr ( value , 'pattern' ) : return value try : return re . compile ( value ) except ValueError : raise OptionValueError ( ( 'option %s: invalid regexp value: %r' % ( opt , value ) ) )
check a regexp value by trying to compile it return the compiled regexp .