• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.query_string函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.query_string函数的典型用法代码示例。如果您正苦于以下问题:Python query_string函数的具体用法?Python query_string怎么用?Python query_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: build

    def build(self, base_path = ''):
        '''Generates the href of the button based on the base_path provided.'''

        # append to the path or update the get params dependent on presence
        # of opt 
        if self.opt:
            p = self.request_params.copy()
            if self.dest:
                p[self.opt] = self.dest
            elif self.opt in p:
                del p[self.opt]
        else:
            p = {}
            base_path = ("%s/%s/" % (base_path, self.dest)).replace('//', '/')

        self.action_params = p

        self.bare_path = _force_unicode(base_path.replace('//', '/')).lower()
        self.bare_path = self.bare_path.rstrip('/')
        self.base_path = base_path
        
        # append the query string
        base_path += query_string(p)
        
        # since we've been sloppy of keeping track of "//", get rid
        # of any that may be present
        self.path = base_path.replace('//', '/')
开发者ID:Gelob,项目名称:reddit,代码行数:27,代码来源:menus.py


示例2: load_traffic_uncached

def load_traffic_uncached(interval, what, iden, 
                          start_time = None, stop_time = None,
                          npoints = None):
    """
    Fetches pickled traffic from the traffic server and returns it as a list.
    On connection failure (or no data) returns an empy list. 
    """
    def format_date(d):
        if hasattr(d, "tzinfo"):
            if d.tzinfo is None:
                d = d.replace(tzinfo = g.tz)
            else:
                d = d.astimezone(g.tz)
        return ":".join(map(str, d.timetuple()[:6]))
    
    traffic_url = os.path.join(g.traffic_url, interval, what, iden)
    args = {}
    if start_time:
        args['start_time'] = format_date(start_time)
    if stop_time:
        args['stop_time'] = format_date(stop_time)
    if npoints:
        args['n'] = npoints
    u = urlparse(traffic_url)
    try:
        conn = HTTPConnection(u.hostname, u.port)
        conn.request("GET", u.path + query_string(args))
        res = conn.getresponse()
        res = loads(res.read()) if res.status == 200 else []
        conn.close()
        return res
    except socket.error:
        return []
开发者ID:JediWatchman,项目名称:reddit,代码行数:33,代码来源:traffic.py


示例3: build

    def build(self, base_path=""):
        """Generates the href of the button based on the base_path provided."""
        if self.style == "external":
            self.path = self.dest
            self.bare_path = self.dest
            return

        # append to the path or update the get params dependent on presence
        # of opt
        if self.opt:
            p = request.get.copy()
            p[self.opt] = self.dest
        else:
            p = {}
            base_path = ("%s/%s/" % (base_path, self.dest)).replace("//", "/")
        p.update(self.dest_params)

        self.bare_path = _force_unicode(base_path.replace("//", "/")).lower()
        self.bare_path = self.bare_path.rstrip("/")

        # append the query string
        base_path += query_string(p)

        # since we've been sloppy of keeping track of "//", get rid
        # of any that may be present
        self.path = base_path.replace("//", "/")
开发者ID:brendanlong,项目名称:lesswrong,代码行数:26,代码来源:menus.py


示例4: build

    def build(self, base_path = ''):
        '''Generates the href of the button based on the base_path provided.'''

        # append to the path or update the get params dependent on presence
        # of opt 
        if self.opt:
            p = request.get.copy()
            p[self.opt] = self.dest
        else:
            p = {}
            base_path = ("%s/%s/" % (base_path, self.dest)).replace('//', '/')

        self.bare_path = base_path.replace('//', '/')
        
        # append the query string
        base_path += query_string(p)
        
        # since we've been sloppy of keeping track of "//", get rid
        # of any that may be present
        self.path = base_path.replace('//', '/')
开发者ID:cmak,项目名称:reddit,代码行数:20,代码来源:menus.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.rdata函数代码示例发布时间:2022-05-26
下一篇:
Python utils.propagate_expose函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap