Exemple #1
0
 def write(self, outfile, encoding):
     handler = SimplerXMLGenerator(outfile, encoding)
     handler.startDocument()
     handler.startElement(u'OpenSearchDescription', {u'xmlns': u"http://a9.com/-/spec/opensearch/1.1/" } )
     handler.characters("\n")
     handler.addQuickElement("ShortName",self.ShortName)
     handler.addQuickElement("Description",self.Description)
     for searchMethod in self.searchMethods:
         self.write_searchmethod(handler, searchMethod)
     for image in self.images:
         self.write_image(handler, image)
     handler.endElement(u'OpenSearchDescription')
Exemple #2
0
    def write(self, outfile, encoding):
        handler = SimplerXMLGenerator(outfile, encoding)
        handler.startDocument()
        feed_attrs = {u'xmlns': self.ns}
        if self.feed.get('extra_attrs'):
            feed_attrs.update(self.feed['extra_attrs'])
        handler.startElement(u'feed', feed_attrs)
        handler.characters("\n")
        handler.addQuickElement(u'id', self.feed['id'])
        self.write_text_construct(handler, u'title', self.feed['title'], tabs=1)
        if self.feed.get('subtitle'):
            self.write_text_construct(handler, u'subtitle', self.feed['subtitle'], tabs=1)
        if self.feed.get('icon'):
            handler.addQuickElement(u'icon', self.feed['icon'])
        if self.feed.get('logo'):
            handler.addQuickElement(u'logo', self.feed['logo'])
        if self.feed['updated']:
            handler.addQuickElement(u'updated', rfc3339_date(self.feed['updated']))
        else:
            handler.addQuickElement(u'updated', rfc3339_date(self.latest_updated()))
        if self.feed.get('openSearch_totalResults'):
            handler.addQuickElement(u'opensearch:totalResults', str(self.feed['openSearch_totalResults']) )
        if self.feed.get('openSearch_itemsPerPage'):
            handler.addQuickElement(u'opensearch:itemsPerPage', str(self.feed['openSearch_itemsPerPage']) )
        for category in self.feed['categories']:
            self.write_category_construct(handler, category)
        for link in self.feed['links']:
            self.write_link_construct(handler, link)
        for author in self.feed['authors']:
            self.write_person_construct(handler, u'author', author)
        for contributor in self.feed['contributors']:
            self.write_person_construct(handler, u'contributor', contributor)
        if self.feed.get('rights'):
            self.write_text_construct(handler, u'rights', self.feed['rights'])
        if not self.feed.get('hide_generator'):
            handler.addQuickElement(u'generator', GENERATOR_TEXT, GENERATOR_ATTR, tabs=2)


        self.write_items(handler)

        handler.endElement(u'feed')