def runTest(self): href = kml.href.Href() href.SetUrl('http://foo.com/foo.kml') href.SetBasename('bar.jpeg') url = href.Href() assert url == 'http://foo.com/bar.jpeg' href = kml.href.Href() href.SetUrl('http://foo.com/dir/foo.kml') href.SetBasename('bar.jpeg') url = href.Href() assert url == 'http://foo.com/dir/bar.jpeg'
def runTest(self): parent_path = 'http://foo.com/able/baker/foo.kml' dotdot_path = '../charlie/goo.kml' want_path = 'http://foo.com/able/charlie/goo.kml' href = kml.href.Href() href.SetUrl(parent_path) href.SetBasename(dotdot_path) assert href.Href() == want_path, 'dot dot href failed'
def runTest(self): parent_path = 'http://foo.com/able/baker/foo.kml' link_path = 'charlie.kmz/delta/epsilon.dae' href = kml.href.Href() href.SetUrl(parent_path) (kmz_url, kmz_file) = kml.href.SplitKmzHref(href, link_path) assert kmz_url == 'http://foo.com/able/baker/charlie.kmz' assert kmz_file == 'delta/epsilon.dae'
def Walk(self, kmlfile, llab=None, lod=None, maxdepth=-1): """ NOTE: Errors with child links are not propagated to the return value. Args: kmlfile: pathname or URL to top of KML hierarchy llab: LatLonAltBox of parent lod: Lod of parent Returns: True: kmlfile and exists and parses False: kmlfile does not exist or fails to parse """ if maxdepth == 0: return True if maxdepth == -1: nmaxdepth = -1 else: nmaxdepth = maxdepth - 1 if self.__verbose: print kmlfile href = kml.href.Href() href.SetUrl(kmlfile) if os.path.isdir(kmlfile): kmldata = GetNetworkLinksFromTree(kmlfile) elif os.path.isfile(kmlfile) and kmlfile.endswith('.tgz'): kmldata = GetNetworkLinksFromTar(kmlfile, self.__encoding) elif kmlfile.endswith('.kmz'): kmz = kml.kmz.Kmz(kmlfile) if kmz: kmldata = kmz.ReadKml() else: if self.__verbose: print 'kmz failed:', kmlfile return False else: kmldata = kml.href.FetchUrl(href.Href()) doc = kml.kmlparse.ParseStringUsingCodec(kmldata, self.__encoding) if not doc: if self.__verbose: print kmlfile, 'load or parse error' return False if not self.__node_handler: return False self.__node_handler.HandleNode(href, doc, llab, lod) self._WalkNetworkLinks(kmlfile, doc, nmaxdepth) if self.__walk_style_urls: self._WalkStyleUrls(kmlfile, doc) return True
def runTest(self): href = kml.href.Href() href.SetUrl('foo/goo.kml') href.SetBasename('bar/baz.kml') assert href.Href() == 'foo/bar/baz.kml', 'relative file bad'
def runTest(self): href = kml.href.Href() href.SetUrl('/a/b/d/hi.kml') assert href.GetScheme() == None, 'scheme not none'
def runTest(self): href = kml.href.Href() href.SetUrl('http://foo.com/dir/foo/hi.kml') href.SetBasename('hello.kml') assert href.Href() == 'http://foo.com/dir/foo/hello.kml'