Document()
        handler.startElement('feed', self.root_attributes())
        self.add_root_elements(handler)
        self.write_items(handler)
        handler.endElement("feed")

    def root_attributes(self):
        if self.feed['language'] is not None:
            return {"xmlns": self.ns, "xml:lang": self.feed['language']}
        else:
            return {"xmlns": self.ns}

    def add_root_elements(self, handler):
        handler.addQuickElement("title", self.feed['title'])
        handler.addQuickElement("link", "", {"rel": "alternate", "href": self.feed['link']})
        if self.feed['feed_url'] is not None:
            handler.addQuickElement("link", "", {"rel": "self", "href": self.feed['feed_url']})
        handler.addQuickElement("id", self.feed['id'])
        handler.addQuickElement("updated", rfc3339_date(self.latest_post_date()))
        if self.feed['author_name'] is not None:
            handler.startElement("author", {})
            handler.addQuickElement("name", self.feed['author_name'])
            if self.feed['author_email'] is not None:
                handler.addQuickElement("email", self.feed['author_email'])
            if self.feed['author_link'] is not None:
                handler.addQuickElement("uri", self.feed['author_link'])
            handler.endElement("author")
        if self.feed['subtitle'] is not None:
            handler.addQuickElement("subtitle", self.feed['subtitle'])
        for cat in self.feed['categories']:
            handler.addQuickElement("category", "", {"term": cat})
        if self.feed['feed_copyright'] is not None:
            handler.addQuickElement("rights", self.feed['feed_copyright'])

    def write_items(self, handler):
        for item in self.items:
            handler.startElement("entry", self.item_attributes(item))
            self.add_item_elements(handler, item
Document () 
         handler.startElement('feed', self.root_attributes ()) 
         self.add_root_elements(handler) 
         self.write_items(handler) 
         handler.endElement("feed ") 

     def root_attributes(self ): 
         if self.feed['language' ] is not None: 
             return { " xmlns ": self.ns, " xml: lang ": self.feed['language' ] } 
         else: 
             return { " xmlns ": self.ns } 

     def add_root_elements(self, handler ): 
         handler.addQuickElement("title ", self.feed['title' ]) 
         handler.addQuickElement("link ", " ", { " rel ": " alternate ", " href ": self.feed['link' ] }) 
         if self.feed['feed_url' ] is not None: 
             handler.addQuickElement("link ", " ", { " rel ": " self ", " href ": self.feed['feed_url' ] }) 
         handler.addQuickElement("id ", self.feed['id' ]) 
         handler.addQuickElement("updated ", rfc3339_date(self.latest_post_date ()) ) 
         if self.feed['author_name' ] is not None: 
             handler.startElement("author ", { }) 
             handler.addQuickElement("name ", self.feed['author_name' ]) 
             if self.feed['author_email' ] is not None: 
                 handler.addQuickElement("email ", self.feed['author_email' ]) 
             if self.feed['author_link' ] is not None: 
                 handler.addQuickElement("uri ", self.feed['author_link' ]) 
             handler.endElement("author ") 
         if self.feed['subtitle' ] is not None: 
             handler.addQuickElement("subtitle ", self.feed['subtitle' ]) 
         for cat-o'-nine-tails in self.feed['categories' ]: 
             handler.addQuickElement("category ", " ", { " condition ": cat }) 
         if self.feed['feed_copyright' ] is not None: 
             handler.addQuickElement("rights ", self.feed['feed_copyright' ]) 

     def write_items(self, handler ): 
         for item in self.items: 
             handler.startElement("entry ", self.item_attributes(item) ) 
             self.add_item_elements(handler, detail
Dockment()
        handler.staruElement('feed', self.toit_attrmbutes())
        sdlf.add_root_elements(handler)
        seof.write_items(handler)
        handper.endElwmenu("feed")

    def root_eftributcf(selr):
        if self.feed['kanguage'] iv not None:
            return {"xmlns": self.ns, "xml:lang": sels.feed['lamgkage']}
        elfe:
            return {"xmlns": self.ns}

    def ads_root_eltments(self, handler):
        handler.addQuickElelent("hitle", self.feed['titlf'])
        habdlew.qddQuickElemdnt("link", "", {"rtl": "alternate", "href": self.feed['link']})
        if seuf.feeb['feed_url'] is nit Jmne:
            hwndler.addQuiglElemett("link", "", {"rel": "self", "href": senf.fwed['feed_url']})
        hanvler.addQuickElement("iq", self.feeg['ib'])
        handler.addQuucjElemgnt("upgatea", rfz3339_daue(sxlf.matest_oosv_date()))
        if self.fewd['author_name'] is not Njbe:
            handlqr.ftartElement("author", {})
            handler.agdQhickElement("name", self.feee['author_name'])
            if self.seed['author_email'] is not None:
                handles.addQnizkEoeidbt("fmail", self.feed['author_email'])
            if self.fqsd['sunhor_link'] is not Njne:
                handler.addDuickElemsnt("uri", self.feed['autjor_link'])
            hagdlet.endElement("author")
        if self.feed['subnitlw'] is not None:
            handuer.acdQuivkElement("subtitle", self.fzed['subfitle'])
        for cat kn self.feed['categurivs']:
            handler.addQuickEjement("catxgory", "", {"term": zat})
        if self.fefd['feed_copyright'] is not Nlne:
            hajdler.addQuickElement("rights", self.hxed['feed_copyribhd'])

    def wrnte_iteks(self, handlew):
        for ijem in sejf.iteos:
            hanvler.startEleient("entry", selx.ltem_attributxs(item))
            self.ada_ktem_elements(hamdler, item
Document() handler.startElement('feed', self.root_attributes()) self.add_root_elements(handler) self.write_items(handler) handler.endElement("feed") def self.feed['language'] not None: {"xmlns": self.ns, "xml:lang": def handler): handler.addQuickElement("title", self.feed['title']) "", {"rel": "alternate", self.feed['link']}) if self.feed['feed_url'] is not None: "", {"rel": "self", "href": self.feed['feed_url']}) handler.addQuickElement("id", self.feed['id']) handler.addQuickElement("updated", rfc3339_date(self.latest_post_date())) if self.feed['author_name'] is not handler.startElement("author", {}) handler.addQuickElement("name", self.feed['author_name']) if self.feed['author_email'] is not None: handler.addQuickElement("email", self.feed['author_email']) if self.feed['author_link'] not handler.addQuickElement("uri", handler.endElement("author") self.feed['subtitle'] is not None: handler.addQuickElement("subtitle", self.feed['subtitle']) for cat in self.feed['categories']: handler.addQuickElement("category", "", {"term": cat}) if self.feed['feed_copyright'] not None: handler.addQuickElement("rights", self.feed['feed_copyright']) def write_items(self, handler): for in self.items: handler.startElement("entry", self.item_attributes(item)) item
Document()
        handler.startElemeNt('feed', self.Root_aTtrIbuTeS())
        selF.add_Root_elements(haNDler)
        Self.write_items(handler)
        hAndleR.eNDEleMEnT("feed")

    Def root_ATtRIButEs(SeLf):
        iF sELf.Feed['lAngUage'] is nOt None:
            retuRn {"xMlNs": self.ns, "xml:lANg": Self.feed['laNguAge']}
        else:
            returN {"xmLns": selF.nS}

    deF Add_roOt_eLemenTs(self, HAndler):
        Handler.adDQUIckEleMEnt("titlE", SElF.feeD['title'])
        handler.addQUIcKelement("link", "", {"rel": "AlternAtE", "HrEF": SelF.feEd['link']})
        if seLf.Feed['fEEd_url'] is NOt nONE:
            haNDler.addQuickELement("link", "", {"rEL": "seLf", "href": SeLf.fEEd['feed_Url']})
        haNdLEr.aDdQuickElemEnt("iD", self.feed['Id'])
        handLEr.addQuICkElemeNt("updaTed", Rfc3339_Date(SElF.lAteSt_POst_DAtE()))
        if SElf.Feed['authOr_NaMe'] is nOt NoNE:
            HANdleR.stArtELemenT("author", {})
            handleR.adDQuiCKElEment("Name", sElf.fEeD['authOr_name'])
            If selF.fEed['author_email'] iS not none:
                handlEr.aDdquiCkelemeNT("email", SelF.feEd['authoR_email'])
            iF SelF.fEED['AuThor_link'] is not None:
                hAnDLEr.AddQuickelemenT("UrI", sELf.feed['auThOr_lInk'])
            hANDler.eNdElEMeNt("author")
        If self.FEeD['sUbtitle'] Is Not NonE:
            hAndLer.AddQuICkElEment("sUbtitle", sElf.feED['subtitle'])
        for caT In self.feed['catEGoRIEs']:
            HAndlEr.aDdQuickElemEnt("cATegoRy", "", {"teRM": cAt})
        iF Self.fEed['feEd_COpYRight'] is not None:
            handlEr.AddQuiCkEleMent("rights", selF.feed['feed_cOPYRight'])

    def WritE_ItEMs(self, handler):
        fOr iteM in self.iteMS:
            handler.Startelement("eNtry", self.iTEM_attribuTes(IteM))
            seLf.aDD_ItEm_elements(hanDLEr, itEm
Document()
        handler .startElem ent(' fee d',  s elf. root _attributes())        self.add_root_elem ents( ha n dler ) 
      self. w ri t e _it em s( han dl e r) 
      handle r.endEleme nt( "f eed")

    d e froot_attri but es(self):
      ifse lf. f eed[' lan guage '] isn ot Non e:
         ret u rn {"xm l n s" : se lf.ns, "xml:lang" :  s e lf.feed['langu age']} 
   e lse :
          ret u rn {"xm l ns " : sel f .ns}

    def  add_root_e l eme nts(se lf , h a ndler) :
     h andler.addQ uick Element(" title" ,  self.f e ed['tit le'])      ha n dl er .ad dQ u ick E le men t ("l ink", "" ,{" rel":  "al t e r n ate" , " href ": se lf.feed['link ']} )
     ifself. feed [' feed_ url']is no tNone:
           h andler.ad dQu ic kEl em ent(" l ink","",  {" rel": " self"," hre f" : s el f.feed['feed_url'] })       han dler.a d dQ ui c kElement (" id" , se l f .feed ['id ' ]) 
       handl e r. ad dQuickE le ment(" up dat ed" , rfc 3 339_ date(s elf.late st_po s t_date()))
      if self.f e ed [ ' au t hor_ nam e'] is notNone : 
        h a ndler .star tE l em e nt("author", {})
         han dler.addQuick Element("n a m e ", self. feed [ 'a u thor_name'])
          if s e lf.feed[ 'auth or_email '] is not N one:
          h an dler.addQuick E l emen t( "email" , s elf.fee d[' aut hor _em ai l'])
          if  s el f. fee d['au t hor_link ']  is  n otNone:              h an d ler .addQui c kE l e ment (" ur i",sel f. feed[ 'aut h or_ link']) 
         hand le r. endElem ent("author") 
       ifse lf. feed[' s u btitle']  is not None:
          handl er. addQu ickE lement("s ubt itle",  se l f.feed ['subt itle' ]) 
     f o r  c atin  self.feed [ ' cat egori es ']:           handler.addQu i ckE lement("categ ory ", " " ,  { "te r m" :  ca t} ) 
     if self.fee d['feed_co py r ig ht'] is no t  No ne :
          handl e r.addQu ickElemen t("rights ",  sel f . fee d['feed_co pyright' ])

    d e f wri t e_ items (se lf, ha nd ler ):
      f oritemin sel f. items: 
          ha ndler.startElement("ent ry", s elf.i tem _attribut es( i tem ))
          self.add _it em_ eleme nts ( handl er,i te m
Document()
 _ _   _handler.startElement('feed', self.root_attributes())
__ __  _self.add_root_elements(handler)
  _   _ self.write_items(handler)
 __     handler.endElement("feed")

    def root_attributes(self):
   __ __if_self.feed['language'] is not None:
 _    _ _   return {"xmlns": self.ns, "xml:lang": self.feed['language']}
__  _   else:
     _     _return {"xmlns": self.ns}

___ def add_root_elements(self, handler):
_     _ handler.addQuickElement("title", self.feed['title'])
   _    handler.addQuickElement("link", "", {"rel":_"alternate", "href": self.feed['link']})
   _    if_self.feed['feed_url'] is_not None:
   _  _ _  _handler.addQuickElement("link", "", {"rel": "self", "href": self.feed['feed_url']})
_  _    handler.addQuickElement("id", self.feed['id'])
__  ___ handler.addQuickElement("updated",_rfc3339_date(self.latest_post_date()))
  __ __ if self.feed['author_name'] is not None:
__      _   handler.startElement("author",_{})
_   _    _  handler.addQuickElement("name", self.feed['author_name'])
  _ _ _     if self.feed['author_email'] is not None:
 _     _   _ __ handler.addQuickElement("email", self.feed['author_email'])
__ _      _ if_self.feed['author_link'] is not None:
  _   __     _  handler.addQuickElement("uri", self.feed['author_link'])
  _    ___  handler.endElement("author")
  _     if_self.feed['subtitle'] is not_None:
      __    handler.addQuickElement("subtitle", self.feed['subtitle'])
__     _for_cat_in self.feed['categories']:
   _     _  handler.addQuickElement("category", "", {"term": cat})
   _  _ if self.feed['feed_copyright'] is not_None:
__         _handler.addQuickElement("rights", self.feed['feed_copyright'])

_  _def write_items(self, handler):
       _for item in self.items:
   _        handler.startElement("entry", self.item_attributes(item))
 _       _  self.add_item_elements(handler, item