當前位置: 首頁>>代碼示例>>Python>>正文


Python http.limited_parse_qsl方法代碼示例

本文整理匯總了Python中django.utils.http.limited_parse_qsl方法的典型用法代碼示例。如果您正苦於以下問題:Python http.limited_parse_qsl方法的具體用法?Python http.limited_parse_qsl怎麽用?Python http.limited_parse_qsl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.utils.http的用法示例。


在下文中一共展示了http.limited_parse_qsl方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from django.utils import http [as 別名]
# 或者: from django.utils.http import limited_parse_qsl [as 別名]
def __init__(self, query_string=None, mutable=False, encoding=None):
        super().__init__()
        if not encoding:
            encoding = settings.DEFAULT_CHARSET
        self.encoding = encoding
        query_string = query_string or ''
        parse_qsl_kwargs = {
            'keep_blank_values': True,
            'fields_limit': settings.DATA_UPLOAD_MAX_NUMBER_FIELDS,
            'encoding': encoding,
        }
        if isinstance(query_string, bytes):
            # query_string normally contains URL-encoded data, a subset of ASCII.
            try:
                query_string = query_string.decode(encoding)
            except UnicodeDecodeError:
                # ... but some user agents are misbehaving :-(
                query_string = query_string.decode('iso-8859-1')
        for key, value in limited_parse_qsl(query_string, **parse_qsl_kwargs):
            self.appendlist(key, value)
        self._mutable = mutable 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:23,代碼來源:request.py

示例2: infer_identifier

# 需要導入模塊: from django.utils import http [as 別名]
# 或者: from django.utils.http import limited_parse_qsl [as 別名]
def infer_identifier(url, source):
    if source == 'MAL':
        # structure is: protocol://myanimelist.net/(type)/(identifier)
        return int(url.split('/')[4])
    elif source == 'AniDB':
        _, _, _, query_encoded, _ = _urlsplit(url)
        query_params = dict(limited_parse_qsl(query_encoded))
        return query_params.get('aid', None)
    elif source == 'Manga-News':
        # structure is: protocol://www.manga-news.com/index.php/serie/(identifier)
        return url.split('/')[5]
    elif source == 'Icotaku':
        # structure is: protocol://anime.icotaku.com/anime/(identifier)/(name)
        return int(url.split('/')[4])
    elif source == 'Animeka':
        # structure is
        # protocol://www.animeka.com/animes/detail/(identifier).html
        return url.split('/')[5][:-5]
    elif source == 'VGMdb':
        # structure is the same as MAL.
        return int(url.split('/')[4])
    else:
        raise ValueError('Unknown source') 
開發者ID:mangaki,項目名稱:mangaki,代碼行數:25,代碼來源:0088_auto_20171225_1534.py

示例3: __init__

# 需要導入模塊: from django.utils import http [as 別名]
# 或者: from django.utils.http import limited_parse_qsl [as 別名]
def __init__(self, query_string=None, mutable=False, encoding=None):
        super().__init__()
        self.encoding = encoding or settings.DEFAULT_CHARSET
        query_string = query_string or ''
        parse_qsl_kwargs = {
            'keep_blank_values': True,
            'fields_limit': settings.DATA_UPLOAD_MAX_NUMBER_FIELDS,
            'encoding': self.encoding,
        }
        if isinstance(query_string, bytes):
            # query_string normally contains URL-encoded data, a subset of ASCII.
            try:
                query_string = query_string.decode(self.encoding)
            except UnicodeDecodeError:
                # ... but some user agents are misbehaving :-(
                query_string = query_string.decode('iso-8859-1')
        for key, value in limited_parse_qsl(query_string, **parse_qsl_kwargs):
            self.appendlist(key, value)
        self._mutable = mutable 
開發者ID:PacktPublishing,項目名稱:Hands-On-Application-Development-with-PyCharm,代碼行數:21,代碼來源:request.py

示例4: __init__

# 需要導入模塊: from django.utils import http [as 別名]
# 或者: from django.utils.http import limited_parse_qsl [as 別名]
def __init__(self, query_string=None, mutable=False, encoding=None):
        super(QueryDict, self).__init__()
        if not encoding:
            encoding = settings.DEFAULT_CHARSET
        self.encoding = encoding
        query_string = query_string or ''
        parse_qsl_kwargs = {
            'keep_blank_values': True,
            'fields_limit': settings.DATA_UPLOAD_MAX_NUMBER_FIELDS,
            'encoding': encoding,
        }
        if six.PY3:
            if isinstance(query_string, bytes):
                # query_string normally contains URL-encoded data, a subset of ASCII.
                try:
                    query_string = query_string.decode(encoding)
                except UnicodeDecodeError:
                    # ... but some user agents are misbehaving :-(
                    query_string = query_string.decode('iso-8859-1')
            for key, value in limited_parse_qsl(query_string, **parse_qsl_kwargs):
                self.appendlist(key, value)
        else:
            for key, value in limited_parse_qsl(query_string, **parse_qsl_kwargs):
                try:
                    value = value.decode(encoding)
                except UnicodeDecodeError:
                    value = value.decode('iso-8859-1')
                self.appendlist(force_text(key, encoding, errors='replace'),
                                value)
        self._mutable = mutable 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:32,代碼來源:request.py


注:本文中的django.utils.http.limited_parse_qsl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。