def _filter_invalid_entries(entries):
 remove_entries = []
 for (i, entry) in enumerate(entries):
  if ('extensions' not in entry):
   print("Missing field 'extensions' in entry {0}".format(entry))
   remove_entries.append(i)
   continue
  if ('regex' not in entry):
   print("Missing field 'regex' in entry {0}".format(entry))
   remove_entries.append(i)
   continue
  try:
   reg = re.compile(entry['regex'])
  except Exception as e:
   print("Invalid regex: '{0}' ({1})".format(entry['regex'], e))
   remove_entries.append(i)
   continue
  if (reg.groups != 0):
   print('The regex must not have a capturing group, invalidated in entry {0}. You might escape your group with (?:...)'.format(entry))
   remove_entries.append(i)
   continue
  for i in reversed(remove_entries):
   del entries[i]

def _filter_invalid_entries ( entries ) : remove_entries = [ ] for ( i , entry ) in enumerate ( entries ) : if ( 'extensions' not in entry ) : print ( "Missing field 'extensions' in entry {0}" . format ( entry ) ) remove_entries . append ( i ) continue if ( 'regex' not in entry ) : print ( "Missing field 'regex' in entry {0}" . format ( entry ) ) remove_entries . append ( i ) continue try : reg = re . compile ( entry [ 'regex' ] ) except Exception as e : print ( "Invalid regex: '{0}' ({1})" . format ( entry [ 'regex' ] , e ) ) remove_entries . append ( i ) continue if ( reg . groups != 0 ) : print ( 'The regex must not have a capturing group, invalidated in entry {0}. You might escape your group with (?:...)' . format ( entry ) ) remove_entries . append ( i ) continue for i in reversed ( remove_entries ) : del entries [ i ]
remove entries without a regex or sufficient fields .