当前位置: 首页>>代码示例>>Python>>正文


Python QueryString.items方法代码示例

本文整理汇总了Python中urlobject.query_string.QueryString.items方法的典型用法代码示例。如果您正苦于以下问题:Python QueryString.items方法的具体用法?Python QueryString.items怎么用?Python QueryString.items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urlobject.query_string.QueryString的用法示例。


在下文中一共展示了QueryString.items方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_active_mquery

# 需要导入模块: from urlobject.query_string import QueryString [as 别名]
# 或者: from urlobject.query_string.QueryString import items [as 别名]
    def handle_active_mquery(self, value):



        active = None

        query_to_trigger = self.prepare_value(value)
        if isinstance(query_to_trigger, basestring):
            query_to_trigger = QueryString(query_to_trigger).dict
        current_query = self.url.query.dict

        for key, value in query_to_trigger.items():

            # exact match of query -> unset it
            if key in current_query and query_to_trigger[key] == current_query[key]:
                active = True

            # check if current query has multiple items
            try:
                ext = current_query[key]
                ext = ext.split(',')
            except Exception as e:
                ext = None

            if ext and len(ext) > 1:

                if key in current_query and value in ext:
                    active = True

        self.url = active
开发者ID:hzlf,项目名称:openbroadcast.org,代码行数:32,代码来源:spurl.py

示例2: handle_active_query

# 需要导入模块: from urlobject.query_string import QueryString [as 别名]
# 或者: from urlobject.query_string.QueryString import items [as 别名]
    def handle_active_query(self, value):
        query_to_toggle = self.prepare_value(value)
        if isinstance(query_to_toggle, basestring):
            query_to_toggle = QueryString(query_to_toggle).dict
        current_query = self.url.query.dict
        for key, value in query_to_toggle.items():

            if key in current_query and value in current_query[key]:
                self.url = True
            else:
                self.url = False
开发者ID:hzlf,项目名称:openbroadcast.org,代码行数:13,代码来源:spurl.py

示例3: handle_toggle_query

# 需要导入模块: from urlobject.query_string import QueryString [as 别名]
# 或者: from urlobject.query_string.QueryString import items [as 别名]
 def handle_toggle_query(self, value):
     query_to_toggle = self.prepare_value(value)
     if isinstance(query_to_toggle, six.string_types):
         query_to_toggle = QueryString(query_to_toggle).dict
     current_query = self.url.query.dict
     for key, value in list(query_to_toggle.items()):
         if isinstance(value, six.string_types):
             value = value.split(',')
         first, second = value
         if key in current_query and first in current_query[key]:
             self.url = self.url.set_query_param(key, second)
         else:
             self.url = self.url.set_query_param(key, first)
开发者ID:albertkoch,项目名称:django-spurl,代码行数:15,代码来源:spurl.py

示例4: handle_trigger_query

# 需要导入模块: from urlobject.query_string import QueryString [as 别名]
# 或者: from urlobject.query_string.QueryString import items [as 别名]
    def handle_trigger_query(self, value):
        query_to_trigger = self.prepare_value(value)
        if isinstance(query_to_trigger, basestring):
            query_to_trigger = QueryString(query_to_trigger).dict
        current_query = self.url.query.dict
        for key, value in query_to_trigger.items():

            if isinstance(value, basestring):
                value = value

            if key in current_query and value in current_query[key]:
                # unset
                self.url = self.url.del_query_param(key)
            else:
                # set
                self.url = self.url.set_query_param(key, value)
开发者ID:hzlf,项目名称:openbroadcast.org,代码行数:18,代码来源:spurl.py

示例5: handle_trigger_mquery

# 需要导入模块: from urlobject.query_string import QueryString [as 别名]
# 或者: from urlobject.query_string.QueryString import items [as 别名]
    def handle_trigger_mquery(self, value):

        query_to_trigger = self.prepare_value(value)
        if isinstance(query_to_trigger, basestring):
            query_to_trigger = QueryString(query_to_trigger).dict
        current_query = self.url.query.dict

        for key, value in query_to_trigger.items():

            # exact match of query -> unset it
            if key in current_query and query_to_trigger[key] == current_query[key]:

                self.url = self.url.del_query_param(key)
                return

            # check if current query has multiple items
            try:
                ext = current_query[key]
                ext = ext.split(',')
            except Exception as e:
                ext = None

            if ext and len(ext) > 1:

                if key in current_query and value in ext:

                    # we have a key-match, so remove it from the string
                    ext = [x for x in ext if x != value]

                else:

                    # no key match, so add it to the string
                    ext.append(value)

                ext.sort()

                self.url = self.url.set_query_param(key, ",".join(ext))


            elif ext and len(ext) == 1:

                # param already here > append
                ext.append(value)
                ext.sort()

                ext = list(set(ext))

                self.url = self.url.set_query_param(key, ",".join(ext))


            else:

                if isinstance(value, basestring):
                    value = value

                if key in current_query and value in current_query[key]:
                    # unset
                    pass
                    #self.url = self.url.del_query_param(key)
                else:
                    # set
                    self.url = self.url.set_query_param(key, value)
开发者ID:hzlf,项目名称:openbroadcast.org,代码行数:64,代码来源:spurl.py


注:本文中的urlobject.query_string.QueryString.items方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。