def enabled_or_not(value): "Enabled status" if value: return image(media_url() + 'imgs/tick.png', _('Enabled'), class_="positio") return image(media_url() + 'imgs/minus.png', _('Disabled'), class_="positio")
def service_status(value): "Service status" if value: name = 'status_ok' else: name = 'caution' return image(url('img', name=name), alt='value')
def country_flag(value): "return country flag" value = value.strip() try: IP(value).version() cname, ccode = geoip_lookup(value) if not ccode: ccode = 'unknown' tag = media_url() + url('flag', country=ccode) return image(tag, cname, title=cname) except ValueError: return ''
def test_image(self): eq_('<img alt="Xml" src="/images/xml.png" />', image('/images/xml.png', "Xml")) eq_('<img alt="Xml" src="/images/xml.png" />', image('/images/xml.png', alt="Xml")) eq_('<img alt="" src="/images/xml.png" />', image('/images/xml.png', "")) eq_('<img alt="" src="/images/xml.png" />', image('/images/xml.png', None)) eq_('<img alt="rss syndication" src="/images/rss.png" />', image('/images/rss.png', 'rss syndication')) eq_('<img alt="Gold" height="70" src="gold.png" width="45" />', image('gold.png', "Gold", height=70, width=45)) eq_( '<img alt="Edit Entry" height="10" src="/images/icon.png" width="16" />', image("/images/icon.png", height=10, width=16, alt="Edit Entry")) eq_('<img alt="Icon" height="16" src="/icons/icon.gif" width="16" />', image("/icons/icon.gif", "Icon", height=16, width=16)) eq_('<img alt="Icon" src="/icons/icon.gif" width="16" />', image("/icons/icon.gif", "Icon", width=16))
def portable_img(name, alt, **kwargs): "image with media path" return image(media_url() + name, alt, **kwargs)
def random_img(): d = list_img() return image("/images/" + rnd.choice(d), "Św. Jan z Kronsztadu")
def render(self, **attrs): return image(self.url, self.alt, title=self.title, **attrs)
def p_image_tag(src, alt=None): if src not in [None, '']: return tags.image(src, alt) else: return ''