Package amplee :: Package ext :: Package opensearch :: Module image
[hide private]
[frames] | no frames]

Source Code for Module amplee.ext.opensearch.image

 1  # -*- coding: utf-8 -*- 
 2   
 3  __docformat__ = 'epytext en' 
 4  __all__ = ['OpenSearchImage'] 
 5   
 6  from amplee.ext.opensearch import OPENSEARCH_NS, OPENSEARCH_PREFIX 
 7  from amplee.utils import qname 
 8   
9 -class OpenSearchImage(object):
10 - def __init__(self, href, mimetype=None, width=None, height=None):
11 self.height = height 12 self.width = width 13 self.mimetype = mimetype 14 self.href = href
15
16 - def add_to_element(self, parent):
17 if not self.href: 18 raise ValueError("Image href must be set") 19 20 attrs = {} 21 22 if self.mimetype: 23 attrs[u'type'] = self.mimetype 24 25 if self.width != None: 26 attrs[u'width'] = unicode(self.width) 27 28 if self.height != None: 29 attrs[u'height'] = unicode(self.height) 30 31 d = parent.ownerDocument 32 parent.xml_append(d.xml_create_element(qname(u"Image", OPENSEARCH_PREFIX), 33 ns=OPENSEARCH_NS, attributes=attrs, 34 content=self.href))
35