def _regex_iptables_save(cmd_output, filters=None):
 if ('iptables.save_filters' not in __context__):
  __context__['iptables.save_filters'] = []
  for pattern in (filters or _conf_save_filters()):
   try:
    __context__['iptables.save_filters'].append(re.compile(pattern))
   except re.error as e:
    log.warning("Skipping regex rule: '{0}': {1}".format(pattern, e))
    continue
 if (len(__context__['iptables.save_filters']) > 0):
  _filtered_cmd_output = [line for line in cmd_output.splitlines(True) if (not any((reg.search(line) for reg in __context__['iptables.save_filters'])))]
  return ''.join(_filtered_cmd_output)
 return cmd_output

def _regex_iptables_save ( cmd_output , filters = None ) : if ( 'iptables.save_filters' not in __context__ ) : __context__ [ 'iptables.save_filters' ] = [ ] for pattern in ( filters or _conf_save_filters ( ) ) : try : __context__ [ 'iptables.save_filters' ] . append ( re . compile ( pattern ) ) except re . error as e : log . warning ( "Skipping regex rule: '{0}': {1}" . format ( pattern , e ) ) continue if ( len ( __context__ [ 'iptables.save_filters' ] ) > 0 ) : _filtered_cmd_output = [ line for line in cmd_output . splitlines ( True ) if ( not any ( ( reg . search ( line ) for reg in __context__ [ 'iptables.save_filters' ] ) ) ) ] return '' . join ( _filtered_cmd_output ) return cmd_output
return string with save_filter regex entries removed .