Exemplo n.º 1
0
    def export(self, query, format, *args):
        """
         Returns a unicode object containing the selected data
         in the specified format. Valid formats are:
         * docbook

         XXX: move formats to constants
        """
        doc = []
        if format == "docbook":
            doc.append(docbook.xmlHeader("bibliography"))
            doc.append("<bibliography>")
            self.select(query, "order by author, year")
            for r in self.rows:
                doc.append(r.asDocbook())
            doc.append("</bibliography>")
            return "\n".join(doc)

        else:
            raise NotImplementedError("Export in format %s not yet implemented" % format)
Exemplo n.º 2
0
  def export(self, query, format, *args):
    """
    Returns a unicode object containing the selected data
    in the specified format. Valid formats are:
    * docbook

    XXX: move formats to constants
    """
    doc = []
    if format == "docbook":
      doc.append(docbook.xmlHeader("appendix"))
      doc.append("<appendix><title>Lexicon</title>")
      self.select(query, "order by language, form, glosse")
      languagenr = -1
      section = -1
      for r in self.rows:
        if languagenr != r.languagenr:
          if languagenr != -1:
            doc.append('</glossdiv>')
            doc.append('</glossary>')
            doc.append('</section>')
            section = -1
          doc.append('<section id="lang_%i"><title>%s</title>\n<glossary>' %
                     (r.languagenr, r.language))
          languagenr = r.languagenr
        if section != r.form[:1]:
          if section != -1:
            doc.append('</glossdiv>')
          doc.append('<glossdiv id="lang_%i_%s"><title>%s</title>' %
                     (r.languagenr, r.form[:1], r.form[:1]))
          section = r.form[:1]
        doc.append(r.asDocbook())
      doc.append("</glossdiv>\n</glossary>")
      doc.append("</section>")
      doc.append("</appendix>")
      return u"\n".join(doc)

    else:
      raise NotImplementedError("Export in format %s not yet implemented" % format)