def _normalize_equivalencies(equivalencies):
 if (equivalencies is None):
  return []
 normalized = []
 for (i, equiv) in enumerate(equivalencies):
  if (len(equiv) == 2):
   (funit, tunit) = equiv
   a = b = (lambda x: x)
  elif (len(equiv) == 3):
   (funit, tunit, a) = equiv
   b = a
  elif (len(equiv) == 4):
   (funit, tunit, a, b) = equiv
  else:
   raise ValueError(u'Invalid equivalence entry {0}: {1!r}'.format(i, equiv))
  if (not ((funit is Unit(funit)) and ((tunit is None) or (tunit is Unit(tunit))) and six.callable(a) and six.callable(b))):
   raise ValueError(u'Invalid equivalence entry {0}: {1!r}'.format(i, equiv))
  normalized.append((funit, tunit, a, b))
 return normalized

def _normalize_equivalencies ( equivalencies ) : if ( equivalencies is None ) : return [ ] normalized = [ ] for ( i , equiv ) in enumerate ( equivalencies ) : if ( len ( equiv ) == 2 ) : ( funit , tunit ) = equiv a = b = ( lambda x : x ) elif ( len ( equiv ) == 3 ) : ( funit , tunit , a ) = equiv b = a elif ( len ( equiv ) == 4 ) : ( funit , tunit , a , b ) = equiv else : raise ValueError ( u'Invalid equivalence entry {0}: {1!r}' . format ( i , equiv ) ) if ( not ( ( funit is Unit ( funit ) ) and ( ( tunit is None ) or ( tunit is Unit ( tunit ) ) ) and six . callable ( a ) and six . callable ( b ) ) ) : raise ValueError ( u'Invalid equivalence entry {0}: {1!r}' . format ( i , equiv ) ) normalized . append ( ( funit , tunit , a , b ) ) return normalized
normalizes equivalencies .