def _encode_emr_api_params(x):
 if isinstance(x, dict):
  result = {}
  for (key, value) in x.items():
   if ((key == 'Properties') and isinstance(value, dict)):
    value = [{'Key': k, 'Value': v} for (k, v) in sorted(value.items())]
   unpacked_value = _encode_emr_api_params(value)
   if isinstance(unpacked_value, dict):
    for (subkey, subvalue) in unpacked_value.items():
     result[('%s.%s' % (key, subkey))] = subvalue
   else:
    result[key] = unpacked_value
  return result
 if isinstance(x, (list, tuple)):
  return _encode_emr_api_params(dict(((('member.%d' % (i + 1)), item) for (i, item) in enumerate(x))))
 return x

def _encode_emr_api_params ( x ) : if isinstance ( x , dict ) : result = { } for ( key , value ) in x . items ( ) : if ( ( key == 'Properties' ) and isinstance ( value , dict ) ) : value = [ { 'Key' : k , 'Value' : v } for ( k , v ) in sorted ( value . items ( ) ) ] unpacked_value = _encode_emr_api_params ( value ) if isinstance ( unpacked_value , dict ) : for ( subkey , subvalue ) in unpacked_value . items ( ) : result [ ( '%s.%s' % ( key , subkey ) ) ] = subvalue else : result [ key ] = unpacked_value return result if isinstance ( x , ( list , tuple ) ) : return _encode_emr_api_params ( dict ( ( ( ( 'member.%d' % ( i + 1 ) ) , item ) for ( i , item ) in enumerate ( x ) ) ) ) return x
recursively unpack parameters to the emr api .