Python urllib.basejoin() Examples
The following are code examples for showing how to use urllib.basejoin(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.
Example 1
Project: oil Author: oilshell File: pimp.py (license) View Source Project | 6 votes |
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)
Example 2
Project: python2-tracer Author: extremecoders-re File: pimp.py (license) View Source Project | 6 votes |
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)
Example 3
Project: ndk-python Author: gittor File: pimp.py (license) View Source Project | 6 votes |
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)
Example 4
Project: vspheretools Author: devopshq File: Utility.py (license) View Source Project | 5 votes |
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. #
Example 5
Project: vspheretools Author: devopshq File: Utility.py (license) View Source Project | 5 votes |
def basejoin(base, url): if url.startswith(token) is True: return urllib.basejoin(base,url[2:]) return urllib.basejoin(base,url)
Example 6
Project: p2pool-bch Author: amarian12 File: Utility.py (license) View Source Project | 5 votes |
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. #
Example 7
Project: p2pool-bch Author: amarian12 File: Utility.py (license) View Source Project | 5 votes |
def basejoin(base, url): if url.startswith(token) is True: return urllib.basejoin(base,url[2:]) return urllib.basejoin(base,url)
Example 8
Project: p2pool-unitus Author: amarian12 File: Utility.py (license) View Source Project | 5 votes |
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. #
Example 9
Project: p2pool-unitus Author: amarian12 File: Utility.py (license) View Source Project | 5 votes |
def basejoin(base, url): if url.startswith(token) is True: return urllib.basejoin(base,url[2:]) return urllib.basejoin(base,url)
Example 10
Project: sahriswiki Author: prologic File: env.py (license) View Source Project | 5 votes |
def staticuri(self, url): base = self.config.get("static-baseurl", None) if base: return basejoin(base, url) else: return self.request.uri("/%s" % url)
Example 11
Project: p2pool-dgb-sha256 Author: ilsawa File: Utility.py (license) View Source Project | 5 votes |
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. #
Example 12
Project: p2pool-dgb-sha256 Author: ilsawa File: Utility.py (license) View Source Project | 5 votes |
def basejoin(base, url): if url.startswith(token) is True: return urllib.basejoin(base,url[2:]) return urllib.basejoin(base,url)
Example 13
Project: oil Author: oilshell File: pimp.py (license) View Source Project | 5 votes |
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)
Example 14
Project: python2-tracer Author: extremecoders-re File: pimp.py (license) View Source Project | 5 votes |
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)
Example 15
Project: bokken Author: thestr4ng3r File: browser.py (license) View Source Project | 5 votes |
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)
Example 16
Project: p2pool-ltc Author: ilsawa File: Utility.py (license) View Source Project | 5 votes |
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. #
Example 17
Project: p2pool-ltc Author: ilsawa File: Utility.py (license) View Source Project | 5 votes |
def basejoin(base, url): if url.startswith(token) is True: return urllib.basejoin(base,url[2:]) return urllib.basejoin(base,url)
Example 18
Project: p2pool-bsty Author: amarian12 File: Utility.py (license) View Source Project | 5 votes |
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. #
Example 19
Project: p2pool-bsty Author: amarian12 File: Utility.py (license) View Source Project | 5 votes |
def basejoin(base, url): if url.startswith(token) is True: return urllib.basejoin(base,url[2:]) return urllib.basejoin(base,url)
Example 20
Project: p2pool-cann Author: ilsawa File: Utility.py (license) View Source Project | 5 votes |
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. #
Example 21
Project: p2pool-cann Author: ilsawa File: Utility.py (license) View Source Project | 5 votes |
def basejoin(base, url): if url.startswith(token) is True: return urllib.basejoin(base,url[2:]) return urllib.basejoin(base,url)
Example 22
Project: ndk-python Author: gittor File: pimp.py (license) View Source Project | 5 votes |
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)
Example 23
Project: py-script Author: xiaoxiamin File: browser.py (license) View Source Project | 5 votes |
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)
Example 24
Project: py-script Author: xiaoxiamin File: browser.py (license) View Source Project | 5 votes |
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)
Example 25
Project: cosa-nostra Author: joxeankoret File: browser.py (license) View Source Project | 5 votes |
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)
Example 26
Project: birdnet Author: cyysu File: browser.py (license) View Source Project | 5 votes |
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)
Example 27
Project: LinuxBashShellScriptForOps Author: DingGuodong File: checkNginxLatestVersionByParseHtmlOnline.py (license) View Source Project | 5 votes |
def join_url(base, path): import urllib return urllib.basejoin(base, path)