def bounds(self, bbox): attrs = { 'minlon': t(bbox[0]), 'minlat': t(bbox[1]), 'maxlon': t(bbox[2]), 'maxlat': t(bbox[3]) } self.xmlfile.characters("\n") self.xmlfile.startElement("bounds", attrs) self.xmlfile.endElement("bounds")
def process_methods(txt, kls, methods, lines, short=True): lines += prepare_lines(txt) for method_name in methods: # :class:`conu.apidefs.backend.Backend` class. if short: lines.append(t(" * :meth:`%s.%s`" % (kls.__name__, method_name))) else: lines.append( t(" * :meth:`%s.%s.%s`" % (kls.__module__, kls.__name__, method_name))) lines.append(t("")) # sphinx needs this
def node(self, id, lat, lon, tags=None, **metadata): tags = tags or {} self.xmlfile.characters("\n ") if tags == {}: attrs = {'id': t(id), 'lat': t(lat), 'lon': t(lon)} for key, value in metadata.items(): attrs[key] = t(value) self.xmlfile.startElement("node", attrs) self.xmlfile.endElement("node") else: attrs = {'id': t(id), 'lat': t(lat), 'lon': t(lon)} for key, value in metadata.items(): attrs[key] = t(value) self.xmlfile.startElement("node", attrs) for key, value in tags.items(): self.xmlfile.characters("\n ") self.xmlfile.startElement("tag", {'k': key, 'v': value}) self.xmlfile.endElement("tag") self.xmlfile.characters("\n ") self.xmlfile.endElement("node")
def relation(self, id, tags, members, **metadata): tags = tags or {} self.xmlfile.characters("\n ") attrs = {'id': t(id)} for key, value in metadata.items(): attrs[key] = t(value) self.xmlfile.startElement("relation", attrs) for member in members: attrs = {} if len(member) == 2: type, ref = member attrs = {'type': t(type), 'ref': t(ref)} else: type, ref, role = member attrs = {'type': t(type), 'ref': t(ref), 'role': t(role)} self.xmlfile.characters("\n ") self.xmlfile.startElement("member", attrs) self.xmlfile.endElement("member") for key, value in tags.items(): self.xmlfile.characters("\n ") self.xmlfile.startElement("tag", {'k': key, 'v': value}) self.xmlfile.endElement("tag") self.xmlfile.characters("\n ") self.xmlfile.endElement("relation")
def node(self, id, lat, lon, tags=None, **metadata): tags = tags or {} self.xmlfile.characters("\n ") attrs = {'id': t(id), 'lat': t(lat), 'lon': t(lon)} for key, value in metadata.items(): attrs[key] = t(value) self.xmlfile.startElement("node", attrs) for key, value in tags.items(): self.xmlfile.characters("\n ") self.xmlfile.startElement("tag", {'k': key, 'v': value}) self.xmlfile.endElement("tag") self.xmlfile.characters("\n ") self.xmlfile.endElement("node")
def way(self, id, tags, nodeids, **metadata): tags = tags or {} nodeids = nodeids or [] self.xmlfile.characters("\n ") attrs = {'id': t(id)} for key, value in metadata.items(): attrs[key] = t(value) self.xmlfile.startElement("way", attrs) for nodeid in nodeids: self.xmlfile.characters("\n ") self.xmlfile.startElement("nd", {'ref': t(nodeid)}) self.xmlfile.endElement("nd") for key, value in tags.items(): self.xmlfile.characters("\n ") self.xmlfile.startElement("tag", {'k': key, 'v': value}) self.xmlfile.endElement("tag") self.xmlfile.characters("\n ") self.xmlfile.endElement("way")
def prepare_lines(txt): """ Let's put some preface first -- the newline is required b/c of reST """ return [t(txt), t("")]