예제 #1
0
파일: compat.py 프로젝트: sandywij/geopy
    def urlencode(query, doseq=0):
        """
        A version of Python's urllib.urlencode() function that can operate on
        unicode strings. The parameters are first cast to UTF-8 encoded strings
        and then encoded as per normal.

        Based on the urlencode from django.utils.http
        """
        if hasattr(query, 'items'):
            query = query.items()
        return original_urlencode(
            [(force_str(k),
              [force_str(i)
               for i in v] if isinstance(v, (list, tuple)) else force_str(v))
             for k, v in query], doseq)
예제 #2
0
파일: compat.py 프로젝트: AdamsLee/geopy
    def urlencode(query, doseq=0):
        """
        A version of Python's urllib.urlencode() function that can operate on
        unicode strings. The parameters are first cast to UTF-8 encoded strings
        and then encoded as per normal.

        Based on the urlencode from django.utils.http
        """
        if hasattr(query, 'items'):
            query = query.items()
        return original_urlencode(
            [(force_str(k),
              [force_str(i) for i in v]
              if isinstance(v, (list, tuple)) else force_str(v))
             for k, v in query],
            doseq)
예제 #3
0
 def urlencode(obj):
     utf8obj = dict((x.encode('utf-8'), y.encode('utf-8'))
                    for x, y in obj.items())
     return unicode(original_urlencode(utf8obj), 'utf-8')