Python urllib 模块,basejoin() 实例源码

我们从Python开源项目中,提取了以下27个代码示例,用于说明如何使用urllib.basejoin()

项目:oil    作者:oilshell    | 项目源码 | 文件源码
def _appendPackages(self, packages, url):
        """Given a list of dictionaries containing package
        descriptions create the PimpPackage objects and append them
        to our internal storage."""

        for p in packages:
            p = dict(p)
            if 'Download-URL' in p:
                p['Download-URL'] = urllib.basejoin(url, p['Download-URL'])
            flavor = p.get('Flavor')
            if flavor == 'source':
                pkg = PimpPackage_source(self, p)
            elif flavor == 'binary':
                pkg = PimpPackage_binary(self, p)
            elif flavor == 'installer':
                pkg = PimpPackage_installer(self, p)
            elif flavor == 'hidden':
                pkg = PimpPackage_installer(self, p)
            else:
                pkg = PimpPackage(self, dict(p))
            self._packages.append(pkg)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def _appendPackages(self, packages, url):
        """Given a list of dictionaries containing package
        descriptions create the PimpPackage objects and append them
        to our internal storage."""

        for p in packages:
            p = dict(p)
            if 'Download-URL' in p:
                p['Download-URL'] = urllib.basejoin(url, p['Download-URL'])
            flavor = p.get('Flavor')
            if flavor == 'source':
                pkg = PimpPackage_source(self, p)
            elif flavor == 'binary':
                pkg = PimpPackage_binary(self, p)
            elif flavor == 'installer':
                pkg = PimpPackage_installer(self, p)
            elif flavor == 'hidden':
                pkg = PimpPackage_installer(self, p)
            else:
                pkg = PimpPackage(self, dict(p))
            self._packages.append(pkg)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def _appendPackages(self, packages, url):
        """Given a list of dictionaries containing package
        descriptions create the PimpPackage objects and append them
        to our internal storage."""

        for p in packages:
            p = dict(p)
            if 'Download-URL' in p:
                p['Download-URL'] = urllib.basejoin(url, p['Download-URL'])
            flavor = p.get('Flavor')
            if flavor == 'source':
                pkg = PimpPackage_source(self, p)
            elif flavor == 'binary':
                pkg = PimpPackage_binary(self, p)
            elif flavor == 'installer':
                pkg = PimpPackage_installer(self, p)
            elif flavor == 'hidden':
                pkg = PimpPackage_installer(self, p)
            else:
                pkg = PimpPackage(self, dict(p))
            self._packages.append(pkg)
项目:vspheretools    作者:devopshq    | 项目源码 | 文件源码
def SplitQName(qname):
    '''SplitQName(qname) -> (string, string)

       Split Qualified Name into a tuple of len 2, consisting 
       of the prefix and the local name.  

       (prefix, localName)

       Special Cases:
           xmlns -- (localName, 'xmlns')
           None -- (None, localName)
    '''

    l = qname.split(':')
    if len(l) == 1:
        l.insert(0, None)
    elif len(l) == 2:
        if l[0] == 'xmlns':
            l.reverse()
    else:
        return
    return tuple(l)

#
# python2.3 urllib.basejoin does not remove current directory ./
# from path and this causes problems on subsequent basejoins.
#
项目:vspheretools    作者:devopshq    | 项目源码 | 文件源码
def basejoin(base, url): 
        if url.startswith(token) is True:
            return urllib.basejoin(base,url[2:])
        return urllib.basejoin(base,url)
项目:p2pool-bch    作者:amarian12    | 项目源码 | 文件源码
def SplitQName(qname):
        '''SplitQName(qname) -> (string, string)

           Split Qualified Name into a tuple of len 2, consisting 
           of the prefix and the local name.  

           (prefix, localName)

           Special Cases:
               xmlns -- (localName, 'xmlns')
               None -- (None, localName)
        '''

        l = qname.split(':')
        if len(l) == 1:
            l.insert(0, None)
        elif len(l) == 2:
            if l[0] == 'xmlns':
                l.reverse()
        else:
            return
        return tuple(l)

#
# python2.3 urllib.basejoin does not remove current directory ./
# from path and this causes problems on subsequent basejoins.
#
项目:p2pool-bch    作者:amarian12    | 项目源码 | 文件源码
def basejoin(base, url): 
        if url.startswith(token) is True:
            return urllib.basejoin(base,url[2:])
        return urllib.basejoin(base,url)
项目:p2pool-unitus    作者:amarian12    | 项目源码 | 文件源码
def SplitQName(qname):
        '''SplitQName(qname) -> (string, string)

           Split Qualified Name into a tuple of len 2, consisting 
           of the prefix and the local name.  

           (prefix, localName)

           Special Cases:
               xmlns -- (localName, 'xmlns')
               None -- (None, localName)
        '''

        l = qname.split(':')
        if len(l) == 1:
            l.insert(0, None)
        elif len(l) == 2:
            if l[0] == 'xmlns':
                l.reverse()
        else:
            return
        return tuple(l)

#
# python2.3 urllib.basejoin does not remove current directory ./
# from path and this causes problems on subsequent basejoins.
#
项目:p2pool-unitus    作者:amarian12    | 项目源码 | 文件源码
def basejoin(base, url): 
        if url.startswith(token) is True:
            return urllib.basejoin(base,url[2:])
        return urllib.basejoin(base,url)
项目:sahriswiki    作者:prologic    | 项目源码 | 文件源码
def staticuri(self, url):
        base = self.config.get("static-baseurl", None)
        if base:
            return basejoin(base, url)
        else:
            return self.request.uri("/%s" % url)
项目:p2pool-dgb-sha256    作者:ilsawa    | 项目源码 | 文件源码
def SplitQName(qname):
        '''SplitQName(qname) -> (string, string)

           Split Qualified Name into a tuple of len 2, consisting 
           of the prefix and the local name.  

           (prefix, localName)

           Special Cases:
               xmlns -- (localName, 'xmlns')
               None -- (None, localName)
        '''

        l = qname.split(':')
        if len(l) == 1:
            l.insert(0, None)
        elif len(l) == 2:
            if l[0] == 'xmlns':
                l.reverse()
        else:
            return
        return tuple(l)

#
# python2.3 urllib.basejoin does not remove current directory ./
# from path and this causes problems on subsequent basejoins.
#
项目:p2pool-dgb-sha256    作者:ilsawa    | 项目源码 | 文件源码
def basejoin(base, url): 
        if url.startswith(token) is True:
            return urllib.basejoin(base,url[2:])
        return urllib.basejoin(base,url)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def appendURL(self, url, included=0):
        """Append packages from the database with the given URL.
        Only the first database should specify included=0, so the
        global information (maintainer, description) get stored."""

        if url in self._urllist:
            return
        self._urllist.append(url)
        fp = urllib2.urlopen(url).fp
        plistdata = plistlib.Plist.fromFile(fp)
        # Test here for Pimp version, etc
        if included:
            version = plistdata.get('Version')
            if version and version > self._version:
                sys.stderr.write("Warning: included database %s is for pimp version %s\n" %
                    (url, version))
        else:
            self._version = plistdata.get('Version')
            if not self._version:
                sys.stderr.write("Warning: database has no Version information\n")
            elif self._version > PIMP_VERSION:
                sys.stderr.write("Warning: database version %s newer than pimp version %s\n"
                    % (self._version, PIMP_VERSION))
            self._maintainer = plistdata.get('Maintainer', '')
            self._description = plistdata.get('Description', '').strip()
            self._url = url
        self._appendPackages(plistdata['Packages'], url)
        others = plistdata.get('Include', [])
        for o in others:
            o = urllib.basejoin(url, o)
            self.appendURL(o, included=1)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def appendURL(self, url, included=0):
        """Append packages from the database with the given URL.
        Only the first database should specify included=0, so the
        global information (maintainer, description) get stored."""

        if url in self._urllist:
            return
        self._urllist.append(url)
        fp = urllib2.urlopen(url).fp
        plistdata = plistlib.Plist.fromFile(fp)
        # Test here for Pimp version, etc
        if included:
            version = plistdata.get('Version')
            if version and version > self._version:
                sys.stderr.write("Warning: included database %s is for pimp version %s\n" %
                    (url, version))
        else:
            self._version = plistdata.get('Version')
            if not self._version:
                sys.stderr.write("Warning: database has no Version information\n")
            elif self._version > PIMP_VERSION:
                sys.stderr.write("Warning: database version %s newer than pimp version %s\n"
                    % (self._version, PIMP_VERSION))
            self._maintainer = plistdata.get('Maintainer', '')
            self._description = plistdata.get('Description', '').strip()
            self._url = url
        self._appendPackages(plistdata['Packages'], url)
        others = plistdata.get('Include', [])
        for o in others:
            o = urllib.basejoin(url, o)
            self.appendURL(o, included=1)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def open(self, url, data=None, headers={}):
        """Opens the specified url."""
        url = urllib.basejoin(self.url, url)
        req = urllib2.Request(url, data, headers)
        return self.do_request(req)
项目:p2pool-ltc    作者:ilsawa    | 项目源码 | 文件源码
def SplitQName(qname):
        '''SplitQName(qname) -> (string, string)

           Split Qualified Name into a tuple of len 2, consisting 
           of the prefix and the local name.  

           (prefix, localName)

           Special Cases:
               xmlns -- (localName, 'xmlns')
               None -- (None, localName)
        '''

        l = qname.split(':')
        if len(l) == 1:
            l.insert(0, None)
        elif len(l) == 2:
            if l[0] == 'xmlns':
                l.reverse()
        else:
            return
        return tuple(l)

#
# python2.3 urllib.basejoin does not remove current directory ./
# from path and this causes problems on subsequent basejoins.
#
项目:p2pool-ltc    作者:ilsawa    | 项目源码 | 文件源码
def basejoin(base, url): 
        if url.startswith(token) is True:
            return urllib.basejoin(base,url[2:])
        return urllib.basejoin(base,url)
项目:p2pool-bsty    作者:amarian12    | 项目源码 | 文件源码
def SplitQName(qname):
        '''SplitQName(qname) -> (string, string)

           Split Qualified Name into a tuple of len 2, consisting 
           of the prefix and the local name.  

           (prefix, localName)

           Special Cases:
               xmlns -- (localName, 'xmlns')
               None -- (None, localName)
        '''

        l = qname.split(':')
        if len(l) == 1:
            l.insert(0, None)
        elif len(l) == 2:
            if l[0] == 'xmlns':
                l.reverse()
        else:
            return
        return tuple(l)

#
# python2.3 urllib.basejoin does not remove current directory ./
# from path and this causes problems on subsequent basejoins.
#
项目:p2pool-bsty    作者:amarian12    | 项目源码 | 文件源码
def basejoin(base, url): 
        if url.startswith(token) is True:
            return urllib.basejoin(base,url[2:])
        return urllib.basejoin(base,url)
项目:p2pool-cann    作者:ilsawa    | 项目源码 | 文件源码
def SplitQName(qname):
        '''SplitQName(qname) -> (string, string)

           Split Qualified Name into a tuple of len 2, consisting 
           of the prefix and the local name.  

           (prefix, localName)

           Special Cases:
               xmlns -- (localName, 'xmlns')
               None -- (None, localName)
        '''

        l = qname.split(':')
        if len(l) == 1:
            l.insert(0, None)
        elif len(l) == 2:
            if l[0] == 'xmlns':
                l.reverse()
        else:
            return
        return tuple(l)

#
# python2.3 urllib.basejoin does not remove current directory ./
# from path and this causes problems on subsequent basejoins.
#
项目:p2pool-cann    作者:ilsawa    | 项目源码 | 文件源码
def basejoin(base, url): 
        if url.startswith(token) is True:
            return urllib.basejoin(base,url[2:])
        return urllib.basejoin(base,url)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def appendURL(self, url, included=0):
        """Append packages from the database with the given URL.
        Only the first database should specify included=0, so the
        global information (maintainer, description) get stored."""

        if url in self._urllist:
            return
        self._urllist.append(url)
        fp = urllib2.urlopen(url).fp
        plistdata = plistlib.Plist.fromFile(fp)
        # Test here for Pimp version, etc
        if included:
            version = plistdata.get('Version')
            if version and version > self._version:
                sys.stderr.write("Warning: included database %s is for pimp version %s\n" %
                    (url, version))
        else:
            self._version = plistdata.get('Version')
            if not self._version:
                sys.stderr.write("Warning: database has no Version information\n")
            elif self._version > PIMP_VERSION:
                sys.stderr.write("Warning: database version %s newer than pimp version %s\n"
                    % (self._version, PIMP_VERSION))
            self._maintainer = plistdata.get('Maintainer', '')
            self._description = plistdata.get('Description', '').strip()
            self._url = url
        self._appendPackages(plistdata['Packages'], url)
        others = plistdata.get('Include', [])
        for o in others:
            o = urllib.basejoin(url, o)
            self.appendURL(o, included=1)
项目:py-script    作者:xiaoxiamin    | 项目源码 | 文件源码
def open(self, url, data=None, headers={}):
        """Opens the specified url."""
        url = urllib.basejoin(self.url, url)
        req = urllib2.Request(url, data, headers)
        return self.do_request(req)
项目:py-script    作者:xiaoxiamin    | 项目源码 | 文件源码
def open(self, url, data=None, headers={}):
        """Opens the specified url."""
        url = urllib.basejoin(self.url, url)
        req = urllib2.Request(url, data, headers)
        return self.do_request(req)
项目:cosa-nostra    作者:joxeankoret    | 项目源码 | 文件源码
def open(self, url, data=None, headers={}):
        """Opens the specified url."""
        url = urllib.basejoin(self.url, url)
        req = urllib2.Request(url, data, headers)
        return self.do_request(req)
项目:birdnet    作者:cyysu    | 项目源码 | 文件源码
def open(self, url, data=None, headers={}):
        """Opens the specified url."""
        url = urllib.basejoin(self.url, url)
        req = urllib2.Request(url, data, headers)
        return self.do_request(req)
项目:LinuxBashShellScriptForOps    作者:DingGuodong    | 项目源码 | 文件源码
def join_url(base, path):
    import urllib
    return urllib.basejoin(base, path)