def generate_markup(spots, filename=None): geomarkup = Markup() for spot in spots: geomarkup.add_spot(spot) if filename is not None: geomarkup.filename = filename geomarkup.save_kml_file() else: print geomarkup.generate_kml()
def test_Markup(self): markup = Markup() self.assertIs(markup, Markup) markup = Markup(title='NewYorkCity', filename=self.tmpfile.name) self.assertIs(markup, Markup) # add_spot self.assertRaises(ValueError, lambda: markup.add_spot( Search('New York City'))) # generate_kml markup.add_spot(Spot.from_search( Search('New York City'))) markup.generate_kml() # latitude, longitude, elevation markup.add_spot( Spot.from_search(Search('New York City', language='en'))) markup.generate_kml() # latitude, longitude # save_kml_file markup.save_kml_file() # title self.assertIs(markup.title, str) self.failUnlessRaises( AttributeError, setattr, markup, "title", "set not allowed") # spots self.assertIs(markup.spots, list) self.failUnlessRaises( AttributeError, setattr, markup, "spots", "set not allowed") # filename self.assertIs(markup.filename, str) markup.filename = 'filename' self.assertStrEqual(markup.filename, 'filename')