<commit_before><commit_msg>Implements parts of urllib (quote, urlencode).<commit_after>def quote(s):
    """
    This function is equivalent to urllib.quote().

    Example:

    >>> quote("hey")
    'hey'
    >>> quote("$%&/?/+ s")
    '%24%25%26/%3F/%2B%20s'

    """
    JS("""return encodeURIComponent(s);""")

def urlencode(d):
    """
    Equivalent of urllib.urlencode().

    Examples:
    >>> urlencode({"a": 34, "bbb": "ccc"})
    'a=34&bbb=ccc'
    >>> urlencode({"a": 34, "bbb": "$%&/?/+ s"})
    'a=34&bbb=%24%25%26/%3F/%2B%20s'
    >>> urlencode({"a": 34})
    'a=34'
    >>> urlencode({})
    ''

    """
    s = ""
    for i, v in d.iteritems():
        s += "%s=%s&" % (i, quote(str(v)))
    if s != "":
        s = s[:-1]
    return s
{'fraction_non_alphanumeric': 0.25930851063829785, 'fraction_numerical': 0.043882978723404256, 'mean_word_length': 2.535211267605634, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5601050', 'n_tokens_mistral': 336, 'n_tokens_neox': 306, 'n_words': 57}