[tryton-debian-vcs] relatorio branch debian updated. debian/0.6.1-4-3-g07d6876
Mathias Behrle
tryton-debian-vcs at alioth.debian.org
Mon Sep 21 11:47:19 UTC 2015
The following commit has been merged in the debian branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/relatorio.git;a=commitdiff;h=debian/0.6.1-4-3-g07d6876
commit 07d687634204c17a103bc05a34acf65c01699c61
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Mon Sep 21 13:36:05 2015 +0200
Releasing debian version 0.6.2-1.
Signed-off-by: Mathias Behrle <mathiasb at m9s.biz>
diff --git a/debian/changelog b/debian/changelog
index 6be0f6d..92a7d48 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+relatorio (0.6.2-1) unstable; urgency=medium
+
+ * Merging upstream version 0.6.2.
+ * Updating d/copyright for relatorio/tests/__init__.py.
+
+ -- Mathias Behrle <mathiasb at m9s.biz> Mon, 21 Sep 2015 13:35:44 +0200
+
relatorio (0.6.1-4) unstable; urgency=medium
* Adapting section naming in gbp.conf to current git-buildpackage.
commit 63aa7c2f324b0e9f7eb617e15826ba31c29e4340
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Mon Sep 21 13:11:11 2015 +0200
Updating d/copyright for relatorio/tests/__init__.py.
diff --git a/debian/copyright b/debian/copyright
index c647a88..e2480dd 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -19,6 +19,10 @@ Copyright: 2007-2008 OpenHex SPRL <http://www.openhex.com/>
2014 Cedric Krier
License: GPL-3+
+Files: relatorio/tests/__init__.py
+Copyright: 2015 Cedric Krier
+License: GPL-3+
+
Files: relatorio/tests/test_api.py
Copyright: 2007-2008 OpenHex SPRL <http://www.openhex.com/>
2014 Cedric Krier
commit 6a4c2fb4ebd320db9db1162d34fa2aa95ef5b519
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Mon Sep 21 13:00:07 2015 +0200
Merging upstream version 0.6.2.
diff --git a/CHANGES b/CHANGES
index e1b9edd..7f92948 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+0.6.2 - 20150919
+* Add name argument for "image:" in odf
+* Remove table:end-cell-address from draw:frame as the address could be wrong
+* Remove nose
+* Add directives: attrs, content, replace and strip
+
0.6.1 - 20140909
* Use io module instead of StringIO
* Explicitly close ZipFile
diff --git a/MANIFEST.in b/MANIFEST.in
index 9f38fae..b3b67e6 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,6 +1,7 @@
include AUTHORS
include CHANGES
include LICENSE
+include doc/*
include relatorio/tests/*.jpg
include relatorio/tests/*.odt
include relatorio/tests/*.png
diff --git a/PKG-INFO b/PKG-INFO
index e1723a7..5469835 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,22 +1,37 @@
Metadata-Version: 1.1
Name: relatorio
-Version: 0.6.1
+Version: 0.6.2
Summary: A templating library able to output odt and pdf files
-Home-page: http://code.google.com/p/python-relatorio/
+Home-page: http://relatorio.tryton.org/
Author: Cedric Krier
Author-email: cedric.krier at b2ck.com
License: GPL License
-Description:
- relatorio
+Description: Relatorio
=========
- A templating library which provides a way to easily output all kind of
- different files (odt, ods, png, svg, ...). Adding support for more filetype is
- easy: you just have to create a plugin for this.
+ Relatorio is a templating library which provides a way to easily output several
+ kinds of files (odt, ods, png, svg, ...). Support for more filetypes can
+ be easily added by creating plugins for them.
+
+ Relatorio also provides a report repository allowing you to link python objects
+ and report together, find reports by mimetype/name/python object.
+
+ Documenation
+ ============
+
+ The documenation is provided at http://relatorio.readthedocs.org/
+
+ Note on PyCha
+ =============
+
+ Since the 0.4.0 release, pycha upstream author included most of our patches. So
+ it is not necessary anymore to use our friendly fork of the project.
+
+ For SVG support, you need PyCha 0.4.2 or later.
+
+ http://www.lorenzogil.com/projects/pycha/
+
- relatorio also provides a report repository allowing you to link python objects
- and report together, find reports by mimetypes/name/python objects.
-
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
diff --git a/README b/README
index 73c54f8..104a8b0 100644
--- a/README
+++ b/README
@@ -8,6 +8,11 @@ be easily added by creating plugins for them.
Relatorio also provides a report repository allowing you to link python objects
and report together, find reports by mimetype/name/python object.
+Documenation
+============
+
+The documenation is provided at http://relatorio.readthedocs.org/
+
Note on PyCha
=============
diff --git a/doc/Makefile b/doc/Makefile
new file mode 100644
index 0000000..c9d63e1
--- /dev/null
+++ b/doc/Makefile
@@ -0,0 +1,153 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " texinfo to make Texinfo files"
+ @echo " info to make Texinfo files and run them through makeinfo"
+ @echo " gettext to make PO message catalogs"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ -rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/relatorio.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/relatorio.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/relatorio"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/relatorio"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo
+ @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+ @echo "Run \`make' in that directory to run these through makeinfo" \
+ "(use \`make info' here to do that automatically)."
+
+info:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo "Running Texinfo files through makeinfo..."
+ make -C $(BUILDDIR)/texinfo info
+ @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+ $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+ @echo
+ @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/doc/basic.png b/doc/basic.png
new file mode 100644
index 0000000..cf9cf06
Binary files /dev/null and b/doc/basic.png differ
diff --git a/doc/basic_generated.png b/doc/basic_generated.png
new file mode 100644
index 0000000..8e95d30
Binary files /dev/null and b/doc/basic_generated.png differ
diff --git a/doc/bonham_basic.png b/doc/bonham_basic.png
new file mode 100644
index 0000000..4632b3c
Binary files /dev/null and b/doc/bonham_basic.png differ
diff --git a/doc/complicated.png b/doc/complicated.png
new file mode 100644
index 0000000..f023147
Binary files /dev/null and b/doc/complicated.png differ
diff --git a/doc/complicated_rendered.png b/doc/complicated_rendered.png
new file mode 100644
index 0000000..d923fe0
Binary files /dev/null and b/doc/complicated_rendered.png differ
diff --git a/doc/conf.py b/doc/conf.py
new file mode 100644
index 0000000..4174d25
--- /dev/null
+++ b/doc/conf.py
@@ -0,0 +1,242 @@
+# -*- coding: utf-8 -*-
+#
+# relatorio documentation build configuration file, created by
+# sphinx-quickstart on Wed Jun 24 12:26:14 2015.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.todo']
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'relatorio'
+copyright = u'2015, Nicolas Évrard, CGaëtan de Menten, Cédric Krier'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.6'
+# The full version, including alpha/beta/rc tags.
+release = '0.6.2'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'relatoriodoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+ ('index', 'relatorio.tex', u'relatorio Documentation',
+ u'Nicolas Évrard, CGaëtan de Menten, Cédric Krier', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ ('index', 'relatorio', u'relatorio Documentation',
+ [u'Nicolas Évrard, CGaëtan de Menten, Cédric Krier'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ ('index', 'relatorio', u'relatorio Documentation',
+ u'Nicolas Évrard, CGaëtan de Menten, Cédric Krier', 'relatorio', 'One line description of project.',
+ 'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
diff --git a/doc/frame.png b/doc/frame.png
new file mode 100644
index 0000000..bb84109
Binary files /dev/null and b/doc/frame.png differ
diff --git a/doc/hyperlink.png b/doc/hyperlink.png
new file mode 100644
index 0000000..822e532
Binary files /dev/null and b/doc/hyperlink.png differ
diff --git a/doc/indepthexample.rst b/doc/indepthexample.rst
new file mode 100644
index 0000000..b426456
--- /dev/null
+++ b/doc/indepthexample.rst
@@ -0,0 +1,137 @@
+Indepth Example
+===============
+
+In this page I will detail the way I created the reports that can be found in
+the `examples directory`_.
+
+.. _examples directory: http://hg.tryton.org/relatorio/file/tip/examples
+
+Let's start with the content of :file:`common.py`, this file stores the
+definition of an invoice that will be used to create the different reports. The
+invoice is a simple python dictionary with some methods added for the sake of
+simplicity:
+
+.. include:: ../examples/common.py
+ :literal:
+
+Create a simple OpenOffice Writer template
+------------------------------------------
+
+Let's start with the simple template defined in :file:`basic.odt`.
+
+.. image:: basic.png
+
+This report will be created and rendered with the following three line of code::
+
+
+ from relatorio.templates.opendocument import Template
+ basic = Template(source=None, filepath='basic.odt')
+ file('bonham_basic.odt', 'wb').write(basic.generate(o=inv).render().getvalue())
+
+Notice that the dictionary passed to `generate` is used to bind names to make
+them accessible to the report. So you can access the data of the invoice with a
+Text Placeholder_ containing `o.customer.name`. This is where you can see our
+Genshi_ heritage. In fact, all reports using relatorio are subclasses of
+Genshi's Template. Thus you can use most of the goodies provided by Genshi.
+
+.. _Placeholder: http://wiki.services.openoffice.org/wiki/Documentation/OOoAuthors_User_Manual/Writer_Guide/Using_placeholder_fields
+.. _Genshi: http://genshi.edgewall.org/
+
+To iterate over a list you must use an hyperlink (created through
+'Insert > Hyperlink') and encode as the target the Genshi expression to use.
+The URL-scheme used *must* be `relatorio`. You can use whatever text you want
+as the link text, but we find it way more explicit to display the Genshi code
+used. Here is the example of the for loop.
+
+.. image:: hyperlink.png
+
+And thus here is our invoice, generated through relatorio:
+
+.. image:: basic_generated.png
+
+One step further: OpenOffice Calc and OpenOffice Impress templates
+------------------------------------------------------------------
+
+Just like we defined a Writer template it is just as easy to define a
+Calc/Impress template. Let's take a look at :file:`pivot.ods`.
+
+.. image:: pivot.png
+
+As usual you can see here the different way to make a reference to the content
+of the invoice object:
+
+ * through the Text Placeholder interpolation of Genshi
+ * or through the hyperlink specification I explained earlier.
+
+Note that there is another tab in this Calc file used to make some data
+aggregation thanks to the `data pilot`_ possibilities of OpenOffice.
+
+.. _data pilot: http://www.learnopenoffice.org/CalcTutorial33.htm
+
+And so here is our rendered template:
+
+.. image:: pivot_rendered.png
+
+Note that the type of data is correctly set even though we did not have
+anything to do.
+
+Everybody loves charts
+----------------------
+
+Now we would like to make our basic report a bit more colorful, so let's add a
+little chart. We are using PyCha_ to generate them from our :file:`pie_chart`
+template:
+
+.. include:: ../examples/pie_chart
+ :literal:
+
+.. _PyCha: http://www.lorenzogil.com/projects/pycha/
+
+Once again we are using the same syntax as Genshi but this time this is a
+TextTemplate_. This file follow the YAML_ format thus we can render it into a
+data structure that will be sent to PyCha:
+
+ * the options dictionary will be sent to PyCha as-is
+ * the dataset in the chart dictionary is sent to PyCha through its
+ `.addDataset` method.
+
+.. _TextTemplate: http://genshi.edgewall.org/wiki/Documentation/text-templates.html
+.. _YAML: http://www.yaml.org/
+
+If you need more information about those go to the `pycha website`_.
+
+.. _pycha website: http://www.lorenzogil.com/projects/pycha/
+
+And here is the result:
+
+.. image:: pie.png
+
+A (not-so) real example
+-----------------------
+
+Now that we have everything to start working on our complicated template
+:file:`invoice.odt`, we will go through it one step at a time.
+
+.. image:: complicated.png
+
+In this example, you can see that not only the openoffice plugin supports the
+`for directive`, it also supports the `if directive` and the `choose directive`
+that way you can choose to render or not some elements.
+
+The next step is to add images programmatically, all you need to do is to
+create frame ('Insert > Frame') and name it `image: expression` just like in
+the following example:
+
+.. image:: frame.png
+
+The expression when evaluated must return a couple whose first element is a
+file object containing the image and second element is its mimetype. Note that
+if the first element of the couple is an instance of `relatorio report`_ then
+this report is rendered (using the same arguments as the originating template)
+and used as a the source for the file definition.
+
+.. _relatorio report: http://hg.tryton.org/relatorio/file/tip/relatorio/reporting#l108
+
+This kind of setup gives us a nice report like that:
+
+.. image:: complicated_rendered.png
diff --git a/doc/index.rst b/doc/index.rst
new file mode 100644
index 0000000..8463555
--- /dev/null
+++ b/doc/index.rst
@@ -0,0 +1,15 @@
+.. relatorio documentation master file, created by
+ sphinx-quickstart on Wed Jun 24 12:26:14 2015.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Welcome to relatorio's documentation!
+=====================================
+
+Contents:
+
+.. toctree::
+ :maxdepth: 2
+
+ quickexample
+ indepthexample
diff --git a/doc/make.bat b/doc/make.bat
new file mode 100644
index 0000000..762ca8c
--- /dev/null
+++ b/doc/make.bat
@@ -0,0 +1,190 @@
+ at ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+ set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+set I18NSPHINXOPTS=%SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+ set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+ set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+ :help
+ echo.Please use `make ^<target^>` where ^<target^> is one of
+ echo. html to make standalone HTML files
+ echo. dirhtml to make HTML files named index.html in directories
+ echo. singlehtml to make a single large HTML file
+ echo. pickle to make pickle files
+ echo. json to make JSON files
+ echo. htmlhelp to make HTML files and a HTML help project
+ echo. qthelp to make HTML files and a qthelp project
+ echo. devhelp to make HTML files and a Devhelp project
+ echo. epub to make an epub
+ echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+ echo. text to make text files
+ echo. man to make manual pages
+ echo. texinfo to make Texinfo files
+ echo. gettext to make PO message catalogs
+ echo. changes to make an overview over all changed/added/deprecated items
+ echo. linkcheck to check all external links for integrity
+ echo. doctest to run all doctests embedded in the documentation if enabled
+ goto end
+)
+
+if "%1" == "clean" (
+ for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+ del /q /s %BUILDDIR%\*
+ goto end
+)
+
+if "%1" == "html" (
+ %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+ goto end
+)
+
+if "%1" == "dirhtml" (
+ %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+ goto end
+)
+
+if "%1" == "singlehtml" (
+ %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+ goto end
+)
+
+if "%1" == "pickle" (
+ %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can process the pickle files.
+ goto end
+)
+
+if "%1" == "json" (
+ %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can process the JSON files.
+ goto end
+)
+
+if "%1" == "htmlhelp" (
+ %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+ goto end
+)
+
+if "%1" == "qthelp" (
+ %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+ echo.^> qcollectiongenerator %BUILDDIR%\qthelp\relatorio.qhcp
+ echo.To view the help file:
+ echo.^> assistant -collectionFile %BUILDDIR%\qthelp\relatorio.ghc
+ goto end
+)
+
+if "%1" == "devhelp" (
+ %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished.
+ goto end
+)
+
+if "%1" == "epub" (
+ %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The epub file is in %BUILDDIR%/epub.
+ goto end
+)
+
+if "%1" == "latex" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+ goto end
+)
+
+if "%1" == "text" (
+ %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The text files are in %BUILDDIR%/text.
+ goto end
+)
+
+if "%1" == "man" (
+ %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The manual pages are in %BUILDDIR%/man.
+ goto end
+)
+
+if "%1" == "texinfo" (
+ %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
+ goto end
+)
+
+if "%1" == "gettext" (
+ %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
+ goto end
+)
+
+if "%1" == "changes" (
+ %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.The overview file is in %BUILDDIR%/changes.
+ goto end
+)
+
+if "%1" == "linkcheck" (
+ %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+ goto end
+)
+
+if "%1" == "doctest" (
+ %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+ goto end
+)
+
+:end
diff --git a/doc/pie.png b/doc/pie.png
new file mode 100644
index 0000000..331e995
Binary files /dev/null and b/doc/pie.png differ
diff --git a/doc/pivot.png b/doc/pivot.png
new file mode 100644
index 0000000..40e6036
Binary files /dev/null and b/doc/pivot.png differ
diff --git a/doc/pivot_rendered.png b/doc/pivot_rendered.png
new file mode 100644
index 0000000..e7b9d8d
Binary files /dev/null and b/doc/pivot_rendered.png differ
diff --git a/doc/quickexample.rst b/doc/quickexample.rst
new file mode 100644
index 0000000..ae61473
--- /dev/null
+++ b/doc/quickexample.rst
@@ -0,0 +1,59 @@
+Quick Example
+=============
+
+In this page we will show you how you can create OpenOffice documents using Relatorio.
+
+Data
+-----
+
+We need some data objects to work on, so let's first create a fake invoice
+object. Please create a file named :file:`data.py` in your favorite text
+editor, and copy the following content:
+
+.. include:: ../examples/common.py
+ :literal:
+
+So we created the data for an invoice for the famous Led Zeppelin's drummer and
+his favorite addiction.
+
+Template
+--------
+
+The next thing to do is to create a template for invoices. We will use the one
+displayed below. To create the Genshi directives, you need to create a
+text-type placeholder field, and fill it with the expression you want to use.
+
+.. image:: relatorio_basic.png
+
+Generate the final documents
+----------------------------
+
+Now that we have both a template and some data, we can now start to use
+Relatorio to create John Bonham's particular invoice. So fire up your favorite
+python interpreter (we suggest using IPython_) and type (or copy-paste) the
+following commands::
+
+ from relatorio.templates.opendocument import Template
+ from data import bonham_invoice
+ basic = Template(source=None, filepath='basic.odt')
+ basic_generated = basic.generate(o=bonham_invoice).render()
+ file('bonham_basic.odt', 'wb').write(basic_generated.getvalue())
+
+.. _IPython: http://ipython.scipy.org/
+
+On the first line we import the opendocument Template engine. This class has
+the same signature as the one from Genshi but uses only the filepath argument.
+On the fourth line, we generate the final document from the template and the
+data. Note how we pass `o=bonham_invoice` as argument to generate. This is the
+same "o" variable as was used in the O dt template we just created. render()
+returns us a StringIO object, which is then used to pipe the result to a file.
+
+.. image:: bonham_basic.png
+
+And so here is our invoice with all the fields completed according to the
+Invoice object we created earlier. Notice how the style we set in the template
+are also applied in the resulting invoice.
+
+In this example, we only used the `py:for` directive, but Relatorio also
+supports other Genshi directives: `py:if`, `py:choose` / `py:when` /
+`py:otherwise` and `py:with`.
diff --git a/doc/relatorio_basic.png b/doc/relatorio_basic.png
new file mode 100644
index 0000000..2786357
Binary files /dev/null and b/doc/relatorio_basic.png differ
diff --git a/relatorio.egg-info/PKG-INFO b/relatorio.egg-info/PKG-INFO
index e1723a7..5469835 100644
--- a/relatorio.egg-info/PKG-INFO
+++ b/relatorio.egg-info/PKG-INFO
@@ -1,22 +1,37 @@
Metadata-Version: 1.1
Name: relatorio
-Version: 0.6.1
+Version: 0.6.2
Summary: A templating library able to output odt and pdf files
-Home-page: http://code.google.com/p/python-relatorio/
+Home-page: http://relatorio.tryton.org/
Author: Cedric Krier
Author-email: cedric.krier at b2ck.com
License: GPL License
-Description:
- relatorio
+Description: Relatorio
=========
- A templating library which provides a way to easily output all kind of
- different files (odt, ods, png, svg, ...). Adding support for more filetype is
- easy: you just have to create a plugin for this.
+ Relatorio is a templating library which provides a way to easily output several
+ kinds of files (odt, ods, png, svg, ...). Support for more filetypes can
+ be easily added by creating plugins for them.
+
+ Relatorio also provides a report repository allowing you to link python objects
+ and report together, find reports by mimetype/name/python object.
+
+ Documenation
+ ============
+
+ The documenation is provided at http://relatorio.readthedocs.org/
+
+ Note on PyCha
+ =============
+
+ Since the 0.4.0 release, pycha upstream author included most of our patches. So
+ it is not necessary anymore to use our friendly fork of the project.
+
+ For SVG support, you need PyCha 0.4.2 or later.
+
+ http://www.lorenzogil.com/projects/pycha/
+
- relatorio also provides a report repository allowing you to link python objects
- and report together, find reports by mimetypes/name/python objects.
-
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
diff --git a/relatorio.egg-info/SOURCES.txt b/relatorio.egg-info/SOURCES.txt
index 017f677..49a7943 100644
--- a/relatorio.egg-info/SOURCES.txt
+++ b/relatorio.egg-info/SOURCES.txt
@@ -5,6 +5,23 @@ MANIFEST.in
README
setup.cfg
setup.py
+doc/Makefile
+doc/basic.png
+doc/basic_generated.png
+doc/bonham_basic.png
+doc/complicated.png
+doc/complicated_rendered.png
+doc/conf.py
+doc/frame.png
+doc/hyperlink.png
+doc/indepthexample.rst
+doc/index.rst
+doc/make.bat
+doc/pie.png
+doc/pivot.png
+doc/pivot_rendered.png
+doc/quickexample.rst
+doc/relatorio_basic.png
relatorio/__init__.py
relatorio/reporting.py
relatorio.egg-info/PKG-INFO
diff --git a/relatorio/__init__.py b/relatorio/__init__.py
index 34f35d1..91f89f1 100644
--- a/relatorio/__init__.py
+++ b/relatorio/__init__.py
@@ -12,5 +12,5 @@ and report together, find reports by mimetypes/name/python objects.
from .reporting import MIMETemplateLoader, ReportRepository, Report
from . import templates
-__version__ = '0.6.1'
+__version__ = '0.6.2'
__all__ = ['MIMETemplateLoader', 'ReportRepository', 'Report', 'templates']
diff --git a/relatorio/templates/opendocument.py b/relatorio/templates/opendocument.py
index 01e9778..4e6c252 100644
--- a/relatorio/templates/opendocument.py
+++ b/relatorio/templates/opendocument.py
@@ -59,12 +59,20 @@ except ImportError:
GENSHI_EXPR = re.compile(r'''
(/)? # is this a closing tag?
- (for|if|choose|when|otherwise|with) # tag directive
+ (for|if|choose|when|otherwise|with|
+ attrs|content|replace|strip) # tag directive
\s*
- (?:\s(\w+)=["'](.*)["']|$) # match a single attr & its value
+ (?:\s([\w:-]+)=["'](.*)["']|$) # match a single attr & its value
|
.* # or anything else
''', re.VERBOSE)
+GENSHI_CLOSING_DIRECTIVE = ['for',
+ 'if',
+ 'choose',
+ 'when',
+ 'otherwise',
+ 'with',
+ ]
EXTENSIONS = {'image/png': 'png',
'image/jpeg': 'jpg',
@@ -74,7 +82,7 @@ EXTENSIONS = {'image/png': 'png',
'image/xbm': 'xbm',
}
-RELATORIO_URI = 'http://relatorio.openhex.org/'
+RELATORIO_URI = 'relatorio'
GENSHI_URI = 'http://genshi.edgewall.org/'
MANIFEST = 'META-INF/manifest.xml'
META = 'meta.xml'
@@ -147,8 +155,9 @@ class ImageDimension:
def __call__(self, expr, width, height):
# expr could be (bitstream, mimetype)
# or (bitstreamm mimetype, width, height)
- if len(expr) == 4:
- width, height = expr[2:]
+ if len(expr) >= 4:
+ width, height = (
+ i or j for i, j in zip(expr[2:4], [width, height]))
attrs = {}
if width:
attrs['{%s}width' % self.namespaces['svg']] = width
@@ -375,7 +384,7 @@ class Template(MarkupTemplate):
% opened_tags[-1].text
warnings.warn(warn_msg)
- if directive is not None:
+ if directive in GENSHI_CLOSING_DIRECTIVE:
# map closing tags with their opening tag
if is_opening:
opened_tags.append(statement)
@@ -410,7 +419,7 @@ class Template(MarkupTemplate):
expr, directive, attr, a_val = parsed
# If the node is a genshi directive statement:
- if directive is not None:
+ if directive in GENSHI_CLOSING_DIRECTIVE:
opening = r_node
closing = closing_tags[id(r_node)]
@@ -462,6 +471,21 @@ class Template(MarkupTemplate):
# - we delete the closing statement (and its ancestors)
wrap_nodes_between(outermost_o_ancestor, outermost_c_ancestor,
genshi_node)
+ elif directive:
+ # find the first parent with the same tag name as the attribute
+ parent = r_node
+ namespace, name = attr.split(':')
+ attr = '{%s}%s' % (self.namespaces[namespace], name)
+ while parent is not None and parent.tag != attr:
+ parent = parent.getparent()
+ assert parent is not None, "Parent not found"
+
+ # add the py:attribute to the parent
+ py_attr = '{%s}%s' % (GENSHI_URI, directive)
+ parent.attrib[py_attr] = a_val
+
+ # remove the directive node
+ r_node.getparent().remove(r_node)
else:
# It's not a genshi statement it's a python expression
parent = r_node.getparent().getparent()
@@ -662,6 +686,7 @@ class Template(MarkupTemplate):
draw_name = '{%s}name' % draw_namespace
draw_image = '{%s}image' % draw_namespace
py_attrs = '{%s}attrs' % self.namespaces['py']
+ end_cell_address = '{%s}end-cell-address' % self.namespaces['table']
svg_namespace = self.namespaces['svg']
svg_width = '{%s}width' % svg_namespace
svg_height = '{%s}height' % svg_namespace
@@ -669,7 +694,6 @@ class Template(MarkupTemplate):
for draw in tree.xpath(xpath_expr, namespaces=self.namespaces):
cache_id = id(draw)
d_name = draw.attrib[draw_name][6:].strip()
- draw.attrib[draw_name] = '' # clean template code
attr_expr = ("__relatorio_make_href(__relatorio_get_cache(%s))" %
cache_id)
image_node = EtreeElement(draw_image,
@@ -683,6 +707,11 @@ class Template(MarkupTemplate):
"__relatorio_store_cache(%s, %s), '%s', '%s')" %
(cache_id, d_name, width, height))
draw.attrib[py_attrs] = attr_expr
+ draw.attrib.pop(draw_name)
+ dico = "{'%s': (__relatorio_get_cache(%s)[4:5] or [''])[0]}"
+ update_py_attrs(draw, dico % (draw_name, cache_id))
+ # remove end-cell-address as the address specified could be wrong
+ draw.attrib.pop(end_cell_address, '')
def _handle_innerdocs(self, tree):
"finds inner_docs and adds them to the processing stack."
diff --git a/relatorio/tests/__init__.py b/relatorio/tests/__init__.py
index e69de29..72d44a5 100644
--- a/relatorio/tests/__init__.py
+++ b/relatorio/tests/__init__.py
@@ -0,0 +1,48 @@
+###############################################################################
+#
+# Copyright (c) 2015 Cedric Krier.
+# All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+import sys
+import os
+import unittest
+
+here = os.path.dirname(__file__)
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ loader = unittest.TestLoader()
+ for fn in os.listdir(here):
+ if fn.startswith('test') and fn.endswith('.py'):
+ modname = 'relatorio.tests.' + fn[:-3]
+ __import__(modname)
+ module = sys.modules[modname]
+ suite.addTests(loader.loadTestsFromModule(module))
+ return suite
+
+
+def main():
+ suite = test_suite()
+ runner = unittest.TextTestRunner()
+ runner.run(suite)
+
+if __name__ == '__main__':
+ sys.path.insert(0, os.path.dirname(os.path.dirname(
+ os.path.dirname(os.path.abspath(__file__)))))
+ main()
diff --git a/relatorio/tests/test_api.py b/relatorio/tests/test_api.py
index 8f89762..5a78d16 100644
--- a/relatorio/tests/test_api.py
+++ b/relatorio/tests/test_api.py
@@ -21,7 +21,7 @@
import os
-from nose.tools import assert_true, eq_, assert_raises
+import unittest
from relatorio.reporting import (ReportRepository, Report, MIMETemplateLoader,
DefaultFactory, _absolute, _guess_type)
@@ -34,7 +34,7 @@ class StubObject(object):
setattr(self, key, val)
-class TestRepository(object):
+class TestRepository(unittest.TestCase):
def test_register(self):
"Testing the registration"
@@ -43,45 +43,47 @@ class TestRepository(object):
os.path.join('templates', 'test.tmpl'),
description='Test report')
- assert_true(StubObject in reporting.classes)
- assert_true('default' in reporting.classes[StubObject].ids)
- assert_true('text/plain' in reporting.classes[StubObject].mimetypes)
+ self.assertTrue(StubObject in reporting.classes)
+ self.assertTrue('default' in reporting.classes[StubObject].ids)
+ self.assertTrue(
+ 'text/plain' in reporting.classes[StubObject].mimetypes)
report, mime, desc = reporting.classes[StubObject].ids['default']
- eq_(mime, 'text/plain')
- eq_(desc, 'Test report')
- eq_(report.mimetype, 'text/plain')
- assert_true(report.fpath.endswith(os.path.join('templates',
+ self.assertEqual(mime, 'text/plain')
+ self.assertEqual(desc, 'Test report')
+ self.assertEqual(report.mimetype, 'text/plain')
+ self.assertTrue(report.fpath.endswith(os.path.join('templates',
'test.tmpl')))
report2, name = (reporting.classes[StubObject]
.mimetypes['text/plain'][0])
- eq_(name, 'default')
- eq_(report, report2)
+ self.assertEqual(name, 'default')
+ self.assertEqual(report, report2)
def test_mimeguesser(self):
- eq_(_guess_type('application/pdf'), 'pdf')
- eq_(_guess_type('text/plain'), 'text')
- eq_(_guess_type('text/xhtml'), 'markup')
- eq_(_guess_type('application/vnd.oasis.opendocument.text'), 'oo.org')
+ self.assertEqual(_guess_type('application/pdf'), 'pdf')
+ self.assertEqual(_guess_type('text/plain'), 'text')
+ self.assertEqual(_guess_type('text/xhtml'), 'markup')
+ self.assertEqual(
+ _guess_type('application/vnd.oasis.opendocument.text'), 'oo.org')
def abspath_helper(self, path):
return _absolute(path)
def test_absolute(self):
"Test the absolute path calculation"
- eq_("/home/nicoe/python/mock.py",
+ self.assertEqual("/home/nicoe/python/mock.py",
_absolute("/home/nicoe/python/mock.py"))
our_dir, _ = os.path.split(__file__)
# We use this because me go up by two frames
new_path = self.abspath_helper(os.path.join('brol', 'toto'))
- eq_(os.path.join(our_dir, 'brol', 'toto'), new_path)
+ self.assertEqual(os.path.join(our_dir, 'brol', 'toto'), new_path)
-class TestReport(object):
+class TestReport(unittest.TestCase):
- def setup(self):
+ def setUp(self):
self.loader = MIMETemplateLoader()
our_dir, _ = os.path.split(__file__)
self.report = Report(os.path.join(our_dir, 'templates', 'test.tmpl'),
@@ -90,7 +92,7 @@ class TestReport(object):
def test_report(self):
"Testing the report generation"
a = StubObject(name='OpenHex')
- eq_(self.report(o=a).render(), 'Hello OpenHex.\n')
+ self.assertEqual(self.report(o=a).render(), 'Hello OpenHex.\n')
def test_factory(self):
"Testing the data factory"
@@ -108,18 +110,18 @@ class TestReport(object):
'text/plain', MyFactory(), self.loader)
a = StubObject(name='Foo')
- eq_(report(o=a, time="One o'clock").render(),
+ self.assertEqual(report(o=a, time="One o'clock").render(),
"Hi Foo,\nIt's One o'clock to 2 !\n")
- eq_(report(o=a, time="One o'clock", y=4).render(),
+ self.assertEqual(report(o=a, time="One o'clock", y=4).render(),
"Hi Foo,\nIt's One o'clock to 5 !\n")
- assert_raises(TypeError, report, a)
+ self.assertRaises(TypeError, report, a)
-class TestReportInclude(object):
+class TestReportInclude(unittest.TestCase):
def test_include(self):
our_dir = os.path.dirname(__file__)
template_path = os.path.join(our_dir, 'templates')
relative_report = Report(os.path.join(template_path, 'include.tmpl'),
'text/plain')
- eq_(relative_report().render(), 'Another Hello.\n\n')
+ self.assertEqual(relative_report().render(), 'Another Hello.\n\n')
diff --git a/relatorio/tests/test_odt.py b/relatorio/tests/test_odt.py
index c665aad..275651b 100644
--- a/relatorio/tests/test_odt.py
+++ b/relatorio/tests/test_odt.py
@@ -22,10 +22,10 @@
import os
+import unittest
from io import StringIO
import lxml.etree
-from nose.tools import ok_, eq_, assert_raises
from genshi.filters import Translator
from genshi.core import PI
from genshi.template.eval import UndefinedError
@@ -54,9 +54,9 @@ def stream_to_string(stream):
return stream
-class TestOOTemplating(object):
+class TestOOTemplating(unittest.TestCase):
- def setup(self):
+ def setUp(self):
thisdir = os.path.dirname(__file__)
filepath = os.path.join(thisdir, 'test.odt')
self.oot = Template(open(filepath, mode='rb'))
@@ -70,17 +70,19 @@ class TestOOTemplating(object):
'hobbies': [u'Music', u'Dancing', u'DJing'],
'animals': [u'Felix da housecat', u'Dog eat Dog'],
'images': [(open(os.path.join(thisdir, 'one.jpg'), 'rb'),
- 'image/jpeg'),
+ 'image/jpeg', None, None, 'One'),
(open(os.path.join(thisdir, 'two.png'), 'rb'),
- 'image/png')],
+ 'image/png', '2cm', '2.2cm', 'Two')],
'oeuf': open(os.path.join(thisdir, 'egg.jpg'), 'rb'),
'footer': u'We sell stuff'}
def test_init(self):
"Testing the correct handling of the styles.xml and content.xml files"
- ok_(isinstance(self.oot.stream, list))
- eq_(self.oot.stream[0], (PI, ('relatorio', 'content.xml'), None))
- ok_((PI, ('relatorio', 'content.xml'), None) in self.oot.stream)
+ self.assertTrue(isinstance(self.oot.stream, list))
+ self.assertEqual(
+ self.oot.stream[0], (PI, ('relatorio', 'content.xml'), None))
+ self.assertTrue(
+ (PI, ('relatorio', 'content.xml'), None) in self.oot.stream)
def test_directives(self):
"Testing the directives interpolation"
@@ -90,7 +92,8 @@ class TestOOTemplating(object):
interpolated = self.oot.insert_directives(xml)
root_interpolated = lxml.etree.parse(interpolated).getroot()
child = root_interpolated[0]
- eq_(child.get('{http://genshi.edgewall.org/}replace'), 'foo')
+ self.assertEqual(
+ child.get('{http://genshi.edgewall.org/}replace'), 'foo')
def test_column_looping(self):
xml = b'''
@@ -198,25 +201,25 @@ class TestOOTemplating(object):
interpolated = self.oot.insert_directives(xml)
root = lxml.etree.parse(interpolated).getroot()
child2 = root[1]
- eq_(child2.tag, "{%s}repeat" % RELATORIO_URI)
- eq_(child2.get("closing"), "3")
- eq_(child2.get("opening"), "1")
- eq_(len(child2), 1)
+ self.assertEqual(child2.tag, "{%s}repeat" % RELATORIO_URI)
+ self.assertEqual(child2.get("closing"), "3")
+ self.assertEqual(child2.get("opening"), "1")
+ self.assertEqual(len(child2), 1)
child4 = root[3]
- eq_(child4.tag, "{%s}table-header-rows" % OO_TABLE_NS)
+ self.assertEqual(child4.tag, "{%s}table-header-rows" % OO_TABLE_NS)
row1 = child4[0]
- ok_(row1.get("{%s}attrs" % GENSHI_URI)
+ self.assertTrue(row1.get("{%s}attrs" % GENSHI_URI)
.startswith('__relatorio_reset_col_count'))
- eq_(len(row1), 4)
+ self.assertEqual(len(row1), 4)
loop = row1[1]
- eq_(loop.tag, "{%s}for" % GENSHI_URI)
+ self.assertEqual(loop.tag, "{%s}for" % GENSHI_URI)
cell = loop[0]
- ok_(cell.get("{%s}attrs" % GENSHI_URI)
+ self.assertTrue(cell.get("{%s}attrs" % GENSHI_URI)
.startswith('__relatorio_inc_col_count'))
last_row_node = row1[3]
- eq_(last_row_node.tag, "{%s}replace" % GENSHI_URI)
- ok_(last_row_node.get("value")
- .startswith('__relatorio_store_col_count'))
+ self.assertEqual(last_row_node.tag, "{%s}replace" % GENSHI_URI)
+ self.assertTrue(last_row_node.get("value")
+ .startswith('__relatorio_store_col_count'))
def test_text_outside_p(self):
"Testing that the tail text of a directive node is handled properly"
@@ -231,31 +234,31 @@ class TestOOTemplating(object):
interpolated = self.oot.insert_directives(xml)
root_interpolated = lxml.etree.parse(interpolated).getroot()
child = root_interpolated[0]
- eq_(child.tag, '{http://genshi.edgewall.org/}if')
- eq_(child.text.strip(), 'xxx')
- eq_(child.tail.strip(), 'aaa')
+ self.assertEqual(child.tag, '{http://genshi.edgewall.org/}if')
+ self.assertEqual(child.text.strip(), 'xxx')
+ self.assertEqual(child.tail.strip(), 'aaa')
def test_styles(self):
"Testing that styles get rendered"
stream = self.oot.generate(**self.data)
rendered = stream_to_string(stream.events.render(encoding='utf-8'))
- ok_('We sell stuff' in rendered)
+ self.assertTrue('We sell stuff' in rendered)
dico = self.data.copy()
del dico['footer']
stream = self.oot.generate(**dico)
- assert_raises(UndefinedError,
+ self.assertRaises(UndefinedError,
lambda: stream.events.render(encoding='utf-8'))
def test_generate(self):
"Testing that content get rendered"
stream = self.oot.generate(**self.data)
rendered = stream_to_string(stream.events.render(encoding='utf-8'))
- ok_('Bonjour,' in rendered)
- ok_('Trente' in rendered)
- ok_(u'Møller' in rendered)
- ok_('Dog eat Dog' in rendered)
- ok_('Felix da housecat' in rendered)
+ self.assertTrue('Bonjour,' in rendered)
+ self.assertTrue('Trente' in rendered)
+ self.assertTrue(u'Møller' in rendered)
+ self.assertTrue('Dog eat Dog' in rendered)
+ self.assertTrue('Felix da housecat' in rendered)
def test_filters(self):
"Testing the filters with the Translator filter"
@@ -263,12 +266,12 @@ class TestOOTemplating(object):
translated = stream.filter(Translator(pseudo_gettext))
translated_xml = stream_to_string(
translated.events.render(encoding='utf-8'))
- ok_("Hello," in translated_xml)
- ok_("I am an odt templating test" in translated_xml)
- ok_('Felix da housecat' not in translated_xml)
- ok_(u'Félix le chat de la maison' in translated_xml)
- ok_('We sell stuff' not in translated_xml)
- ok_('On vend des choses' in translated_xml)
+ self.assertTrue("Hello," in translated_xml)
+ self.assertTrue("I am an odt templating test" in translated_xml)
+ self.assertTrue('Felix da housecat' not in translated_xml)
+ self.assertTrue(u'Félix le chat de la maison' in translated_xml)
+ self.assertTrue('We sell stuff' not in translated_xml)
+ self.assertTrue('On vend des choses' in translated_xml)
def test_images(self):
"Testing the image replacement directive"
@@ -278,34 +281,40 @@ class TestOOTemplating(object):
tree = lxml.etree.parse(StringIO(rendered[25:styles_idx]))
root = tree.getroot()
images = root.xpath('//draw:frame', namespaces=self.oot.namespaces)
- eq_(len(images), 3)
- eq_(images[0].get('{%s}name' % self.oot.namespaces['draw']), "")
- eq_(images[1].get('{%s}name' % self.oot.namespaces['draw']), '')
- eq_(images[1].get('{%s}width' % self.oot.namespaces['svg']),
- '1.732cm')
- eq_(images[1].get('{%s}height' % self.oot.namespaces['svg']),
- '1.513cm')
- eq_(images[2].get('{%s}width' % self.oot.namespaces['svg']),
- '1.732cm')
- eq_(images[2].get('{%s}height' % self.oot.namespaces['svg']),
+ self.assertEqual(len(images), 3)
+ self.assertFalse(
+ images[0].get('{%s}name' % self.oot.namespaces['draw']))
+ self.assertEqual(
+ images[1].get('{%s}name' % self.oot.namespaces['draw']), 'One')
+ self.assertEqual(
+ images[2].get('{%s}name' % self.oot.namespaces['draw']), 'Two')
+ self.assertEqual(
+ images[1].get('{%s}width' % self.oot.namespaces['svg']), '1.732cm')
+ self.assertEqual(
+ images[1].get('{%s}height' % self.oot.namespaces['svg']),
'1.513cm')
+ self.assertEqual(
+ images[2].get('{%s}width' % self.oot.namespaces['svg']), '2cm')
+ self.assertEqual(
+ images[2].get('{%s}height' % self.oot.namespaces['svg']),
+ '2.2cm')
def test_regexp(self):
"Testing the regexp used to find relatorio tags"
# a valid expression
group = GENSHI_EXPR.match('for each="foo in bar"').groups()
- eq_(group, (None, 'for', 'each', 'foo in bar'))
+ self.assertEqual(group, (None, 'for', 'each', 'foo in bar'))
# invalid expr
group = GENSHI_EXPR.match('foreach="foo in bar"').groups()
- eq_(group, (None, None, None, None))
+ self.assertEqual(group, (None, None, None, None))
# valid closing tags
group = GENSHI_EXPR.match('/for').groups()
- eq_(group, ('/', 'for', None, None))
+ self.assertEqual(group, ('/', 'for', None, None))
group = GENSHI_EXPR.match('/for ').groups()
- eq_(group, ('/', 'for', None, None))
+ self.assertEqual(group, ('/', 'for', None, None))
# another non matching expr
group = GENSHI_EXPR.match('formatLang("en")').groups()
- eq_(group, (None, None, None, None))
+ self.assertEqual(group, (None, None, None, None))
diff --git a/setup.py b/setup.py
index a0052a6..412bff6 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,12 @@
import os
import re
+import codecs
from setuptools import setup, find_packages
+def read(fname):
+ return codecs.open(
+ os.path.join(os.path.dirname(__file__), fname), 'r', 'utf-8').read()
+
def get_version():
init = open(os.path.join(os.path.dirname(__file__), 'relatorio',
@@ -10,23 +15,13 @@ def get_version():
setup(
name="relatorio",
- url="http://code.google.com/p/python-relatorio/",
+ url="http://relatorio.tryton.org/",
author="Nicolas Evrard",
author_email="nicolas.evrard at b2ck.com",
maintainer="Cedric Krier",
maintainer_email="cedric.krier at b2ck.com",
description="A templating library able to output odt and pdf files",
- long_description="""
-relatorio
-=========
-
-A templating library which provides a way to easily output all kind of
-different files (odt, ods, png, svg, ...). Adding support for more filetype is
-easy: you just have to create a plugin for this.
-
-relatorio also provides a report repository allowing you to link python objects
-and report together, find reports by mimetypes/name/python objects.
- """,
+ long_description=read('README'),
license="GPL License",
version=get_version(),
packages=find_packages(exclude=['examples']),
@@ -47,8 +42,5 @@ and report together, find reports by mimetypes/name/python objects.
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing",
],
- test_suite="nose.collector",
- tests_require=[
- "nose",
- ],
+ test_suite="relatorio.tests",
use_2to3=True)
--
relatorio
More information about the tryton-debian-vcs
mailing list