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


Python utils.query_string函数代码示例

本文整理汇总了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;未经允许,请勿转载。