def create_filter(parameters):
 if parameters['filters']:
  cli_filters = parameters['filters']
  real_filters = []
  for (filter_type, filter_pattern) in cli_filters:
   real_filters.append((filter_type.lstrip('-'), filter_pattern))
  source_location = parameters['src']
  if source_location.startswith('s3://'):
   src_rootdir = _get_s3_root(source_location, parameters['dir_op'])
  else:
   src_rootdir = _get_local_root(parameters['src'], parameters['dir_op'])
  destination_location = parameters['dest']
  if destination_location.startswith('s3://'):
   dst_rootdir = _get_s3_root(parameters['dest'], parameters['dir_op'])
  else:
   dst_rootdir = _get_local_root(parameters['dest'], parameters['dir_op'])
  return Filter(real_filters, src_rootdir, dst_rootdir)
 else:
  return Filter({}, None, None)

def create_filter ( parameters ) : if parameters [ 'filters' ] : cli_filters = parameters [ 'filters' ] real_filters = [ ] for ( filter_type , filter_pattern ) in cli_filters : real_filters . append ( ( filter_type . lstrip ( '-' ) , filter_pattern ) ) source_location = parameters [ 'src' ] if source_location . startswith ( 's3://' ) : src_rootdir = _get_s3_root ( source_location , parameters [ 'dir_op' ] ) else : src_rootdir = _get_local_root ( parameters [ 'src' ] , parameters [ 'dir_op' ] ) destination_location = parameters [ 'dest' ] if destination_location . startswith ( 's3://' ) : dst_rootdir = _get_s3_root ( parameters [ 'dest' ] , parameters [ 'dir_op' ] ) else : dst_rootdir = _get_local_root ( parameters [ 'dest' ] , parameters [ 'dir_op' ] ) return Filter ( real_filters , src_rootdir , dst_rootdir ) else : return Filter ( { } , None , None )
create a filter function from a string parameter .