def __iter__(self): cur = gv.firstedge(self.parent.handle) while gv.ok(cur): yield (decode_page(gv.nameof(gv.tailof(cur))), decode_page(gv.nameof(gv.headof(cur)))), \ dict(self.graph._iterattrs(cur)) cur = gv.nextedge(self.parent.handle, cur)
def execute(macro, args): formatter = macro.formatter macro.request.page.formatter = formatter request = macro.request _ = request.getText if not args: args = request.page.page_name key = cache_key(request, (macro.name, args, latest_edit(request))) map_text = 'usemap="#%s" ' % (key) if not cache_exists(request, key): succ, data, mappi = draw_topology(request, args, key) if not succ: return mappi mappi = encode_page(mappi) cache.put(request, key, data, content_type='image/png') cache.put(request, key + '-map', mappi, content_type='text/html') else: mappifile = cache._get_datafile(request, key + '-map') mappi = mappifile.read() mappifile.close() div = u'<div class="ClarifiedTopology">\n' + \ u'<img %ssrc="%s" alt="%s">\n</div>\n' % \ (map_text, cache.url(request, key), _('topology')) map = u'<map id="%s" name="%s">\n' % (key, key) map += decode_page(mappi) map += u'</map>\n' return div + map
def __iter__(self): self.readlock() for key in self.db.keys(): if self.out.get(key, None) is self.UNDEFINED: continue yield decode_page(key)
def __iter__(self): """ Iterates over item attributes. """ attr = gv.firstattr(self.handle) while gv.ok(attr): yield gv.nameof(attr), \ decode_page(gv.getv(self.handle, attr)) attr = gv.nextattr(self.handle, attr)
def _iterattrs(self, handle=""): """ Iterate over the attributes of a graph item. If no handle attribute is given, iterates over the attributes of the root graph """ if not handle: handle = self.handle attr = gv.firstattr(handle) while gv.ok(attr): yield gv.nameof(attr), decode_page(gv.getv(handle, attr)) attr = gv.nextattr(handle, attr)
def __getattr__(self, name): """ Finds the named attribute, returns its value """ handle = self.__dict__['handle'] name = encode_page(name) retval = gv.getv(handle, gv.findattr(handle, name)) # Needed mainly for dict() for work, getattribute excepts # and so __iter__ is called. Non-gv attrs are not returned. if not retval: object.__getattribute__(self, name) return decode_page(retval)
def execute(macro, args): formatter = macro.formatter macro.request.page.formatter = formatter request = macro.request _ = request.getText if not args: args = request.page.page_name key = cache_key(request, (macro.name, args, latest_edit(request))) map_text = 'usemap="#%s" ' % (key) if not cache_exists(request, key): succ, data, mappi = draw_topology(request, args, key) if not succ: return mappi mappi = encode_page(mappi) cache.put(request, key, data, content_type="image/png") cache.put(request, key + "-map", mappi, content_type="text/html") else: mappifile = cache._get_datafile(request, key + "-map") mappi = mappifile.read() mappifile.close() div = u'<div class="ClarifiedTopology">\n' + u'<img %ssrc="%s" alt="%s">\n</div>\n' % ( map_text, cache.url(request, key), _("topology"), ) map = u'<map id="%s" name="%s">\n' % (key, key) map += decode_page(mappi) map += u"</map>\n" return div + map
def __str__(self): return "(u'" + decode_page(gv.nameof(gv.tailof(self.handle))) + \ "', u'" + decode_page(gv.nameof(gv.headof(self.handle))) + "')"
def __str__(self): """ Returns item name. """ return "u'" + decode_page(gv.nameof(self.handle)) + "'"