def standardize_patterns(column_names, patterns):
 try:
  patterns = dict(((k, pattern_as_function(v)) for (k, v) in patterns.items() if v))
  if (not column_names):
   return patterns
  p2 = {}
  for k in patterns:
   if (k in column_names):
    idx = column_names.index(k)
    if (idx in patterns):
     raise ColumnIdentifierError(('Column %s has index %i which already has a pattern.' % (k, idx)))
    p2[idx] = patterns[k]
   else:
    p2[k] = patterns[k]
  return p2
 except AttributeError:
  return dict(((i, pattern_as_function(x)) for (i, x) in enumerate(patterns)))

def standardize_patterns ( column_names , patterns ) : try : patterns = dict ( ( ( k , pattern_as_function ( v ) ) for ( k , v ) in patterns . items ( ) if v ) ) if ( not column_names ) : return patterns p2 = { } for k in patterns : if ( k in column_names ) : idx = column_names . index ( k ) if ( idx in patterns ) : raise ColumnIdentifierError ( ( 'Column %s has index %i which already has a pattern.' % ( k , idx ) ) ) p2 [ idx ] = patterns [ k ] else : p2 [ k ] = patterns [ k ] return p2 except AttributeError : return dict ( ( ( i , pattern_as_function ( x ) ) for ( i , x ) in enumerate ( patterns ) ) )
given patterns in any of the permitted input forms .