def _nvp_dump(data):
    """
    Dumps a dict out into NVP pairs suitable for PayPal to consume.
    """
    def escape(k, v):
        return '%s=%s' % (k, urlquote(v))

    out = []
    # This must be sorted for chained payments to work correctly.
    for k, v in sorted(data.items()):
        if isinstance(v, (list, tuple)):
            out.extend([escape('%s(%s)' % (k, x), v_)
                        for x, v_ in enumerate(v)])
        else:
            out.append(escape(k, v))

    return '&'.join(out)
dataset/ETHPy150Open mozilla/addons-server/src/olympia/paypal/__init__.py/_nvp_dump/original