mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 15:00:19 +00:00
Compare commits
77 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b2ab6fae9 | |||
| 7a3d55daab | |||
| eec0595c5c | |||
| 0c7c248b96 | |||
| 0d14f7f2b9 | |||
| d5f713024d | |||
| 415bc819e7 | |||
| 974258094e | |||
| ab16f69be6 | |||
| 28d9af852a | |||
| 39c6ea6503 | |||
| 39b66ad8e9 | |||
| 004b3da680 | |||
| d4923533eb | |||
| 29e0b76910 | |||
| 4f54de2630 | |||
| 1f0d68ee79 | |||
| cae8fa1276 | |||
| 4c0a20a7b9 | |||
| 6c1fa87138 | |||
| 0e30255836 | |||
| 1156d5a220 | |||
| 83b71967b9 | |||
| 4dab48cd76 | |||
| 5324526329 | |||
| 1dfcd42233 | |||
| f162b19bd6 | |||
| 707164e459 | |||
| 42f0a285c3 | |||
| d111cc7cc7 | |||
| 25fe211a22 | |||
| 4b675494c4 | |||
| a196b9a5dd | |||
| 5ba56c2bb3 | |||
| 36fbdda492 | |||
| 273d2729ee | |||
| 3036bc9e52 | |||
| b9c74eacc8 | |||
| 805ccfae34 | |||
| fddc018394 | |||
| 2477100062 | |||
| 983b979fda | |||
| 3edb45bac7 | |||
| 29d626fa1f | |||
| 1f22fc7321 | |||
| 8631f60f8d | |||
| 65873b6112 | |||
| 56e44bd45c | |||
| 87e65fd3e7 | |||
| ffbc3b122d | |||
| 9d71603dad | |||
| cceb41af98 | |||
| 60ffa898fd | |||
| a4a211b5a6 | |||
| c9766a48b0 | |||
| 6975685b89 | |||
| e920244a1b | |||
| ea63779baf | |||
| d826f6d0ae | |||
| f6fa3f2abc | |||
| eed6df45e0 | |||
| cb4c67767a | |||
| 1e21fee70e | |||
| 420dd36ab8 | |||
| 9a05770899 | |||
| 8e055f1c57 | |||
| 239e33aaed | |||
| bf4fdea187 | |||
| 03086052ed | |||
| 2128473938 | |||
| 74c64d66a9 | |||
| a4e77f22c4 | |||
| 2e03046a07 | |||
| 06a7b4cd4e | |||
| 6a70b84166 | |||
| 77d9fe8b41 | |||
| 64cb547e0a |
+16
@@ -1,6 +1,22 @@
|
||||
History
|
||||
-------
|
||||
|
||||
0.9.9 (?)
|
||||
+++++++++
|
||||
|
||||
* Dataset API Changes
|
||||
* ``stack_rows`` => ``stack``, ``stack_columns`` => ``stack_cols``
|
||||
* column operations have their own methods now (``apend_col``, ``insert_col``)
|
||||
* List-style ``pop()``
|
||||
* Redis-style ``rpush``, ``lpush``, ``rpop``, ``lpop``, ``rpush_col``, and ``lpush_col``
|
||||
|
||||
0.9.8 (2011-05-22)
|
||||
++++++++++++++++++
|
||||
|
||||
* OpenDocument Spreadsheet support (.ods)
|
||||
* Full Unicode TSV support
|
||||
|
||||
|
||||
0.9.7 (2011-05-12)
|
||||
++++++++++++++++++
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2011 Kenneth Reitz.
|
||||
Copyright 2011 Kenneth Reitz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -60,40 +60,6 @@ SOFTWARE.
|
||||
|
||||
|
||||
|
||||
AnyJSON License
|
||||
==================
|
||||
|
||||
This software is licensed under the ``New BSD License``:
|
||||
|
||||
Copyright (c) 2009, by the authors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
Neither the name of the authors nor the names of its contributors may be used
|
||||
to endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
UnicodeCSV License
|
||||
==================
|
||||
|
||||
|
||||
+2
-10
@@ -28,10 +28,10 @@ Overview
|
||||
--------
|
||||
|
||||
`tablib.Dataset()`
|
||||
A Dataset is a table of tabular data. It may or may not have a header row. They can be build and manipulated as raw Python datatypes (Lists of tuples|dictionaries). Datasets can be imported from JSON, YAML, and CSV; they can be exported to Excel (XLS), JSON, YAML, and CSV.
|
||||
A Dataset is a table of tabular data. It may or may not have a header row. They can be build and manipulated as raw Python datatypes (Lists of tuples|dictionaries). Datasets can be imported from JSON, YAML, and CSV; they can be exported to XLSX, XLS, ODS, JSON, YAML, CSV, TSV, and HTML.
|
||||
|
||||
`tablib.Databook()`
|
||||
A Databook is a set of Datasets. The most common form of a Databook is an Excel file with multiple spreadsheets. Databooks can be imported from JSON and YAML; they can be exported to Excel (XLS), JSON, and YAML.
|
||||
A Databook is a set of Datasets. The most common form of a Databook is an Excel file with multiple spreadsheets. Databooks can be imported from JSON and YAML; they can be exported to XLSX, XLS, ODS, JSON, and YAML.
|
||||
|
||||
Usage
|
||||
-----
|
||||
@@ -141,14 +141,6 @@ changes to the **develop** branch (or branch off of it), and send a pull
|
||||
request. Make sure you add yourself to AUTHORS_.
|
||||
|
||||
|
||||
Roadmap
|
||||
-------
|
||||
|
||||
v1.0.0:
|
||||
- Add hooks system
|
||||
- Tablib.ext namespace
|
||||
- Better 2.x/3.x handling (currently internal codebase fork)
|
||||
- Width detection on XLS out
|
||||
|
||||
|
||||
.. _`the repository`: http://github.com/kennethreitz/tablib
|
||||
|
||||
@@ -3,7 +3,5 @@
|
||||
- pre/post-import
|
||||
- pre/post-export
|
||||
* Add Tablib.ext namespace
|
||||
* Fix 2.x/3.x handling (currently internal codebase fork)
|
||||
* Make CSV write more customizable.
|
||||
* Width detection for XLS output
|
||||
* Documentation Improvements
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
<h3><a href="http://tablib.org">About Tablib</a></h3>
|
||||
<p>
|
||||
Tablib is an MIT Licensed format-agnostic tabular dataset library, written in Python. It allows you to import, export, and manipulate tabular data sets. Advanced features include, segregation, dynamic columns, tags & filtering, and seamless format import & export.
|
||||
</p>
|
||||
|
||||
<h3>Feedback</h3>
|
||||
<p>
|
||||
Feedback is greatly appreciated. If you have any questions, comments,
|
||||
random praise, or anonymous threats, <a href="mailto:me@kennethreitz.com">
|
||||
shoot me an email</a>.
|
||||
</p>
|
||||
|
||||
|
||||
<h3>Useful Links</h3>
|
||||
<ul>
|
||||
<li><a href="http://tablib.org/">The Tablib Website</a></li>
|
||||
<li><a href="http://pypi.python.org/pypi/tablib">Tablib @ PyPI</a></li>
|
||||
<li><a href="http://github.com/kennethreitz/tablib">Tablib @ GitHub</a></li>
|
||||
<li><a href="http://github.com/kennethreitz/tablib/issues">Issue Tracker</a></li>
|
||||
</ul>
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
<h3><a href="http://tablib.org">About Tablib</a></h3>
|
||||
<p>
|
||||
Tablib is an MIT Licensed format-agnostic tabular dataset library, written in Python. It allows you to import, export, and manipulate tabular data sets. Advanced features include, segregation, dynamic columns, tags & filtering, and seamless format import & export.
|
||||
</p>
|
||||
Vendored
+19
-2
@@ -9,10 +9,12 @@
|
||||
{% endblock %}
|
||||
{%- block relbar2 %}{% endblock %}
|
||||
{%- block footer %}
|
||||
<div class="footer">
|
||||
<div class="footer">
|
||||
© Copyright {{ copyright }}.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
|
||||
</div>
|
||||
<a href="https://github.com/kennethreitz/tablib">
|
||||
<img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" />
|
||||
</a>
|
||||
<script type="text/javascript">
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
@@ -28,4 +30,19 @@
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var t = document.createElement('script');
|
||||
t.type = 'text/javascript';
|
||||
t.async = true;
|
||||
t.id = 'gauges-tracker';
|
||||
t.setAttribute('data-site-id',
|
||||
'4ddc284f613f5d2f1a000001');
|
||||
t.src = '//secure.gaug.es/track.js';
|
||||
var s = document.getElementsByTagName('script')[0];
|
||||
s.parentNode.insertBefore(t, s);
|
||||
})();
|
||||
</script>
|
||||
|
||||
{%- endblock %}
|
||||
|
||||
Vendored
+62
-28
@@ -8,11 +8,11 @@
|
||||
|
||||
{% set page_width = '940px' %}
|
||||
{% set sidebar_width = '220px' %}
|
||||
|
||||
|
||||
@import url("basic.css");
|
||||
|
||||
|
||||
/* -- page layout ----------------------------------------------------------- */
|
||||
|
||||
|
||||
body {
|
||||
font-family: 'goudy old style', 'minion pro', 'bell mt', Georgia, 'Hiragino Mincho Pro';
|
||||
font-size: 17px;
|
||||
@@ -43,7 +43,7 @@ div.sphinxsidebar {
|
||||
hr {
|
||||
border: 1px solid #B1B4B6;
|
||||
}
|
||||
|
||||
|
||||
div.body {
|
||||
background-color: #ffffff;
|
||||
color: #3E4349;
|
||||
@@ -54,7 +54,7 @@ img.floatingflask {
|
||||
padding: 0 0 10px 10px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
|
||||
div.footer {
|
||||
width: {{ page_width }};
|
||||
margin: 20px auto 30px auto;
|
||||
@@ -70,7 +70,7 @@ div.footer a {
|
||||
div.related {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
div.sphinxsidebar a {
|
||||
color: #444;
|
||||
text-decoration: none;
|
||||
@@ -80,7 +80,7 @@ div.sphinxsidebar a {
|
||||
div.sphinxsidebar a:hover {
|
||||
border-bottom: 1px solid #999;
|
||||
}
|
||||
|
||||
|
||||
div.sphinxsidebar {
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
@@ -95,7 +95,7 @@ div.sphinxsidebarwrapper p.logo {
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
div.sphinxsidebar h3,
|
||||
div.sphinxsidebar h4 {
|
||||
font-family: 'Garamond', 'Georgia', serif;
|
||||
@@ -109,7 +109,7 @@ div.sphinxsidebar h4 {
|
||||
div.sphinxsidebar h4 {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
|
||||
div.sphinxsidebar h3 a {
|
||||
color: #444;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ div.sphinxsidebar p.logo a:hover,
|
||||
div.sphinxsidebar h3 a:hover {
|
||||
border: none;
|
||||
}
|
||||
|
||||
|
||||
div.sphinxsidebar p {
|
||||
color: #555;
|
||||
margin: 10px 0;
|
||||
@@ -131,25 +131,25 @@ div.sphinxsidebar ul {
|
||||
padding: 0;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
|
||||
div.sphinxsidebar input {
|
||||
border: 1px solid #ccc;
|
||||
font-family: 'Georgia', serif;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
|
||||
/* -- body styles ----------------------------------------------------------- */
|
||||
|
||||
|
||||
a {
|
||||
color: #004B6B;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
a:hover {
|
||||
color: #6D4100;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
div.body h1,
|
||||
div.body h2,
|
||||
div.body h3,
|
||||
@@ -161,25 +161,25 @@ div.body h6 {
|
||||
margin: 30px 0px 10px 0px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
div.body h1 { margin-top: 0; padding-top: 0; font-size: 240%; }
|
||||
div.body h2 { font-size: 180%; }
|
||||
div.body h3 { font-size: 150%; }
|
||||
div.body h4 { font-size: 130%; }
|
||||
div.body h5 { font-size: 100%; }
|
||||
div.body h6 { font-size: 100%; }
|
||||
|
||||
|
||||
a.headerlink {
|
||||
color: #ddd;
|
||||
padding: 0 4px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
||||
a.headerlink:hover {
|
||||
color: #444;
|
||||
background: #eaeaea;
|
||||
}
|
||||
|
||||
|
||||
div.body p, div.body dd, div.body li {
|
||||
line-height: 1.4em;
|
||||
}
|
||||
@@ -226,20 +226,20 @@ div.note {
|
||||
background-color: #eee;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
|
||||
div.seealso {
|
||||
background-color: #ffc;
|
||||
border: 1px solid #ff6;
|
||||
}
|
||||
|
||||
|
||||
div.topic {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
|
||||
p.admonition-title {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
|
||||
p.admonition-title:after {
|
||||
content: ":";
|
||||
}
|
||||
@@ -333,7 +333,7 @@ ul, ol {
|
||||
margin: 10px 0 10px 30px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
pre {
|
||||
background: #eee;
|
||||
padding: 7px 30px;
|
||||
@@ -350,7 +350,7 @@ dl dl pre {
|
||||
margin-left: -90px;
|
||||
padding-left: 90px;
|
||||
}
|
||||
|
||||
|
||||
tt {
|
||||
background-color: #ecf0f3;
|
||||
color: #222;
|
||||
@@ -388,7 +388,7 @@ a:hover tt {
|
||||
|
||||
|
||||
@media screen and (max-width: 600px) {
|
||||
|
||||
|
||||
div.sphinxsidebar {
|
||||
display: none;
|
||||
}
|
||||
@@ -423,8 +423,42 @@ a:hover tt {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* scrollbars */
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-button:start:decrement,
|
||||
::-webkit-scrollbar-button:end:increment {
|
||||
display: block;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-button:vertical:increment {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track-piece {
|
||||
background-color: #eee;
|
||||
-webkit-border-radius: 3px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:vertical {
|
||||
height: 50px;
|
||||
background-color: #ccc;
|
||||
-webkit-border-radius: 3px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:horizontal {
|
||||
width: 50px;
|
||||
background-color: #ccc;
|
||||
-webkit-border-radius: 3px;
|
||||
}
|
||||
|
||||
+7
-3
@@ -41,14 +41,14 @@ master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'Tablib'
|
||||
copyright = u'2011, Kenneth Reitz. Styles (modified) © Armin Ronacher'
|
||||
copyright = u'2011. A <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a> Project'
|
||||
|
||||
# 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.9.7'
|
||||
version = tablib.__version__
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = version
|
||||
|
||||
@@ -131,7 +131,11 @@ html_static_path = ['static']
|
||||
html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
html_sidebars = {
|
||||
'index': ['sidebarintro.html', 'sourcelink.html', 'searchbox.html'],
|
||||
'**': ['sidebarlogo.html', 'localtoc.html', 'relations.html',
|
||||
'sourcelink.html', 'searchbox.html']
|
||||
}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
|
||||
+29
-29
@@ -5,7 +5,8 @@ Development
|
||||
|
||||
Tablib is under active development, and contributors are welcome.
|
||||
|
||||
If you have a feature request, suggestion, or bug report, please open a new issue on GitHub_. To submit patches, please send a pull request on GitHub_.
|
||||
If you have a feature request, suggestion, or bug report, please open a new
|
||||
issue on GitHub_. To submit patches, please send a pull request on GitHub_.
|
||||
|
||||
If you'd like to contribute, there's plenty to do. Here's a short todo list.
|
||||
|
||||
@@ -42,19 +43,18 @@ Source Control
|
||||
--------------
|
||||
|
||||
|
||||
Tablib source is controlled with Git_, the lean, mean, distributed source control machine.
|
||||
Tablib source is controlled with Git_, the lean, mean, distributed source
|
||||
control machine.
|
||||
|
||||
The repository is publicly accessable.
|
||||
|
||||
``git clone git://github.com/kennethreitz/tablib.git``
|
||||
|
||||
The project is hosted both on **GitHub** and **git.kennethreitz.com**.
|
||||
|
||||
|
||||
GitHub:
|
||||
|
||||
The project is hosted on **GitHub**.
|
||||
|
||||
|
||||
GitHub:
|
||||
http://github.com/kennethreitz/tablib
|
||||
"Mirror":
|
||||
http://git.kennethreitz.com/projects/tablib
|
||||
|
||||
|
||||
Git Branch Structure
|
||||
@@ -100,27 +100,27 @@ Tablib features a micro-framework for adding format support. The easiest way to
|
||||
1. Write a new format interface.
|
||||
|
||||
:class:`tablib.core` follows a simple pattern for automatically utilizing your format throughout Tablib. Function names are crucial.
|
||||
|
||||
|
||||
Example **tablib/formats/_xxx.py**: ::
|
||||
|
||||
title = 'xxx'
|
||||
|
||||
|
||||
def export_set(dset):
|
||||
....
|
||||
# returns string representation of given dataset
|
||||
|
||||
|
||||
def export_book(dbook):
|
||||
....
|
||||
# returns string representation of given databook
|
||||
|
||||
|
||||
def import_set(dset, in_stream):
|
||||
...
|
||||
# populates given Dataset with given datastream
|
||||
|
||||
|
||||
def import_book(dbook, in_stream):
|
||||
...
|
||||
# returns Databook instance
|
||||
|
||||
|
||||
def detect(stream):
|
||||
...
|
||||
# returns True if given stream is parsable as xxx
|
||||
@@ -130,7 +130,7 @@ Tablib features a micro-framework for adding format support. The easiest way to
|
||||
|
||||
If the format excludes support for an import/export mechanism (*eg.* :class:`csv <tablib.Dataset.csv>` excludes :class:`Databook <tablib.Databook>` support), simply don't define the respective functions. Appropriate errors will be raised.
|
||||
|
||||
2.
|
||||
2.
|
||||
|
||||
Add your new format module to the :class:`tablib.formats.avalable` tuple.
|
||||
|
||||
@@ -152,7 +152,7 @@ When developing a feature for Tablib, the easiest way to test your changes for p
|
||||
$ ./test_tablib.py
|
||||
|
||||
|
||||
`Hudson CI`_, amongst other tools, supports Java's xUnit testing report format. Nose_ allows us to generate our own xUnit reports.
|
||||
`Jenkins CI`_, amongst other tools, supports Java's xUnit testing report format. Nose_ allows us to generate our own xUnit reports.
|
||||
|
||||
Installing nose is simple. ::
|
||||
|
||||
@@ -168,25 +168,25 @@ This will generate a **nosetests.xml** file, which can then be analyzed.
|
||||
|
||||
|
||||
|
||||
.. _hudson:
|
||||
.. _jenkins:
|
||||
|
||||
----------------------
|
||||
Continuous Integration
|
||||
----------------------
|
||||
|
||||
Every commit made to the **develop** branch is automatically tested and inspected upon receipt with `Hudson CI`_. If you have access to the main repository and broke the build, you will receive an email accordingly.
|
||||
Every commit made to the **develop** branch is automatically tested and inspected upon receipt with `Jenkins CI`_. If you have access to the main repository and broke the build, you will receive an email accordingly.
|
||||
|
||||
Anyone may view the build status and history at any time.
|
||||
|
||||
http://ci.kennethreitz.com/
|
||||
|
||||
|
||||
If you are trustworthy and plan to contribute to tablib on a regular basis, please contact `Kenneth Reitz`_ to get an account on the Hudson Server.
|
||||
If you are trustworthy and plan to contribute to tablib on a regular basis, please contact `Kenneth Reitz`_ to get an account on the Jenkins Server.
|
||||
|
||||
|
||||
Additional reports will also be included here in the future, including :pep:`8` checks and stress reports for extremely large datasets.
|
||||
|
||||
.. _`Hudson CI`: http://hudson.dev.java.net
|
||||
.. _`Jenkins CI`: http://jenkins-ci.org/
|
||||
.. _`Kenneth Reitz`: http://kennethreitz.com/contact-me/
|
||||
|
||||
|
||||
@@ -196,17 +196,17 @@ Additional reports will also be included here in the future, including :pep:`8`
|
||||
Building the Docs
|
||||
-----------------
|
||||
|
||||
Documentation is written in the powerful, flexible, and standard Python documentation format, `reStructured Text`_.
|
||||
Documentation is written in the powerful, flexible, and standard Python documentation format, `reStructured Text`_.
|
||||
Documentation builds are powered by the powerful Pocoo project, Sphinx_. The :ref:`API Documentation <api>` is mostly documented inline throughout the module.
|
||||
|
||||
The Docs live in ``tablib/docs``. In order to build them, you will first need to install Sphinx. ::
|
||||
|
||||
$ pip install sphinx
|
||||
|
||||
|
||||
|
||||
Then, to build an HTML version of the docs, simply run the following from the **docs** directory: ::
|
||||
|
||||
$ make html
|
||||
$ make html
|
||||
|
||||
Your ``docs/_build/html`` directory will then contain an HTML representation of the documentation, ready for publication on most web servers.
|
||||
|
||||
@@ -214,10 +214,10 @@ You can also generate the documentation in **ebpub**, **latex**, **json**, *&c*
|
||||
|
||||
.. admonition:: GitHub Pages
|
||||
|
||||
To push the documentation up to `GitHub Pages`_, you will first need to run `sphinx-to-github`_ against your ``docs/_build/html`` directory.
|
||||
|
||||
To push the documentation up to `GitHub Pages`_, you will first need to run `sphinx-to-github`_ against your ``docs/_build/html`` directory.
|
||||
|
||||
GitHub Pages are powered by an HTML generation system called Jeckyl_, which is configured to ignore files and folders that begin with "``_``" (*ie.* **_static**).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -232,8 +232,8 @@ You can also generate the documentation in **ebpub**, **latex**, **json**, *&c*
|
||||
Running it against the docs is even simpler. ::
|
||||
|
||||
$ sphinx-to-github _build/html
|
||||
|
||||
Move the resulting files to the **gh-pages** branch of your repository, and push it up to GitHub.
|
||||
|
||||
Move the resulting files to the **gh-pages** branch of your repository, and push it up to GitHub.
|
||||
|
||||
.. _`reStructured Text`: http://docutils.sourceforge.net/rst.html
|
||||
.. _Sphinx: http://sphinx.pocoo.org
|
||||
|
||||
+44
-6
@@ -3,20 +3,20 @@
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Tablib: Pythonic Tabular Datasets
|
||||
Tablib: Pythonic Tabular Datasets
|
||||
=================================
|
||||
|
||||
Release |version|.
|
||||
Release v\ |version|. (:ref:`Installation <install>`)
|
||||
|
||||
.. Contents:
|
||||
..
|
||||
..
|
||||
.. .. toctree::
|
||||
.. :maxdepth: 2
|
||||
..
|
||||
..
|
||||
|
||||
.. Indices and tables
|
||||
.. ==================
|
||||
..
|
||||
..
|
||||
.. * :ref:`genindex`
|
||||
.. * :ref:`modindex`
|
||||
.. * :ref:`search`
|
||||
@@ -24,7 +24,45 @@ Release |version|.
|
||||
|
||||
Tablib is an :ref:`MIT Licensed <mit>` format-agnostic tabular dataset library, written in Python. It allows you to import, export, and manipulate tabular data sets. Advanced features include, segregation, dynamic columns, tags & filtering, and seamless format import & export.
|
||||
|
||||
I recommend you start with :ref:`Installation <install>`.
|
||||
::
|
||||
|
||||
>>> data = tablib.Dataset(headers=['First Name', 'Last Name', 'Age'])
|
||||
>>> map(data.append, [('Kenneth', 'Reitz', 22), ('Bessie', 'Monke', 21)])
|
||||
|
||||
>>> data.json
|
||||
[{"Last Name": "Reitz", "First Name": "Kenneth", "Age": 22}, {"Last Name": "Monke", "First Name": "Bessie", "Age": 21}]
|
||||
|
||||
>>> data.yaml
|
||||
- {Age: 22, First Name: Kenneth, Last Name: Reitz}
|
||||
- {Age: 21, First Name: Bessie, Last Name: Monke}
|
||||
|
||||
>>> data.xlsx
|
||||
<censored binary data>
|
||||
|
||||
|
||||
Testimonials
|
||||
------------
|
||||
|
||||
`National Geographic <http://www.nationalgeographic.com/>`_,
|
||||
`Digg, Inc <http://digg.com/>`_,
|
||||
`Northrop Grumman <http://www.northropgrumman.com/>`_,
|
||||
`Discovery Channel <http://dsc.discovery.com/>`_,
|
||||
and `The Sunlight Foundation <http://sunlightfoundation.com/>`_ use Tablib internally.
|
||||
|
||||
|
||||
|
||||
**Greg Thorton**
|
||||
Tablib by @kennethreitz saved my life. I had to consolidate like 5 huge poorly maintained lists of domains and data. It was a breeze!
|
||||
|
||||
**Dave Coutts**
|
||||
It's turning into one of my most used modules of 2010. You really hit a sweat spot for managing tabular data with a minimal amount of code and effort.
|
||||
|
||||
**Joshua Ourisman**
|
||||
Tablib has made it so much easier to deal with the inevitable 'I want an Excel file!' requests from clients...
|
||||
|
||||
**Brad Montgomery**
|
||||
I think you nailed the "Python Zen" with tablib. Thanks again for an awesome lib!
|
||||
|
||||
|
||||
User's Guide
|
||||
------------
|
||||
|
||||
+26
-12
@@ -11,15 +11,29 @@ This part of the documentation covers the installation of Tablib. The first step
|
||||
Installing Tablib
|
||||
-----------------
|
||||
|
||||
To install Tablib, it only takes one simple command. ::
|
||||
Distribute & Pip
|
||||
----------------
|
||||
|
||||
$ pip install tablib
|
||||
Installing Tablib is simple with `pip <http://www.pip-installer.org/>`_::
|
||||
|
||||
$ pip install tablib
|
||||
|
||||
or, with `easy_install <http://pypi.python.org/pypi/setuptools>`_::
|
||||
|
||||
$ easy_install tablib
|
||||
|
||||
But, you really `shouldn't do that <http://www.pip-installer.org/en/latest/index.html#pip-compared-to-easy-install>`_.
|
||||
|
||||
|
||||
|
||||
Cheeseshop Mirror
|
||||
-----------------
|
||||
|
||||
If the Cheeseshop is down, you can also install Requests from Kenneth Reitz's personal `Cheeseshop mirror <pip.kreitz.co/>`_::
|
||||
|
||||
$ pip install -i http://pip.kreitz.co/simple tablib
|
||||
|
||||
Or, if you must: ::
|
||||
|
||||
$ easy_install tablib
|
||||
|
||||
But, you really shouldn't do that.
|
||||
|
||||
|
||||
-------------------
|
||||
@@ -49,15 +63,15 @@ Speed Extentions
|
||||
|
||||
.. versionadded:: 0.8.5
|
||||
|
||||
Tablib is partially dependent on the **pyyaml**, **simplejson**, and **xlwt** modules. To reduce installation issues, fully integrated versions of all required libraries are included in Tablib.
|
||||
Tablib is partially dependent on the **pyyaml**, **simplejson**, and **xlwt** modules. To reduce installation issues, fully integrated versions of all required libraries are included in Tablib.
|
||||
|
||||
However, if performance is important to you (and it should be), you can install **pyyaml** with C extentions from PyPi. ::
|
||||
|
||||
$ pip install PyYAML
|
||||
$ pip install PyYAML
|
||||
|
||||
If you're using Python 2.5, you should also install the **simplejson** module (pip will do this for you). If you're using Python 2.6+, the built-in **json** module is already optimized and in use. ::
|
||||
|
||||
$ pip install simplejson
|
||||
$ pip install simplejson
|
||||
|
||||
|
||||
|
||||
@@ -65,14 +79,14 @@ If you're using Python 2.5, you should also install the **simplejson** module (p
|
||||
Staying Updated
|
||||
---------------
|
||||
|
||||
The latest version of Tablib will always be available here:
|
||||
The latest version of Tablib will always be available here:
|
||||
|
||||
* PyPi: http://pypi.python.org/pypi/tablib/
|
||||
* GitHub: http://github.com/kennethreitz/tablib/
|
||||
|
||||
When a new version is available, upgrading is simple. ::
|
||||
When a new version is available, upgrading is simple::
|
||||
|
||||
$ pip install tablib --upgrade
|
||||
$ pip install tablib --upgrade
|
||||
|
||||
|
||||
Now, go get a :ref:`Quick Start <quickstart>`.
|
||||
+16
-7
@@ -3,8 +3,11 @@
|
||||
Introduction
|
||||
============
|
||||
|
||||
This part of the documentation covers all the interfaces of Tablib.
|
||||
Tablib is a format-agnostic tabular dataset library, written in Python. It allows you to Pythonically import, export, and manipulate tabular data sets. Advanced features include, segregation, dynamic columns, tags / filtering, and seamless format import/export.
|
||||
This part of the documentation covers all the interfaces of Tablib.
|
||||
Tablib is a format-agnostic tabular dataset library, written in Python.
|
||||
It allows you to Pythonically import, export, and manipulate tabular data sets.
|
||||
Advanced features include, segregation, dynamic columns, tags / filtering, and
|
||||
seamless format import/export.
|
||||
|
||||
|
||||
Philosphy
|
||||
@@ -21,14 +24,19 @@ Tablib was developed with a few :pep:`20` idioms in mind.
|
||||
|
||||
All contributions to Tablib should keep these important rules in mind.
|
||||
|
||||
.. _mit:
|
||||
.. mit:
|
||||
|
||||
MIT License
|
||||
-----------
|
||||
|
||||
A large number of open source projects you find today are `GPL Licensed`_. While the GPL has its time and place, it should most certainly not be your go-to license for your next open source project.
|
||||
A large number of open source projects you find today are `GPL Licensed`_.
|
||||
While the GPL has its time and place, it should most certainly not be your
|
||||
go-to license for your next open source project.
|
||||
|
||||
A project that is released as GPL cannot be used in any commercial product without the product itself also being offered as open source. The MIT and BSD licenses are great alternatives to the GPL that allow your open-source software to be used in proprietary, closed-source software.
|
||||
A project that is released as GPL cannot be used in any commercial product
|
||||
without the product itself also being offered as open source. The MIT, BSD, and
|
||||
ISC licenses are great alternatives to the GPL that allow your open-source
|
||||
software to be used in proprietary, closed-source software.
|
||||
|
||||
Tablib is released under terms of `The MIT License`_.
|
||||
|
||||
@@ -41,7 +49,7 @@ Tablib is released under terms of `The MIT License`_.
|
||||
Tablib License
|
||||
--------------
|
||||
|
||||
Copyright (c) 2011 Kenneth Reitz.
|
||||
Copyright 2011 Kenneth Reitz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -67,7 +75,7 @@ THE SOFTWARE.
|
||||
Pythons Supported
|
||||
-----------------
|
||||
|
||||
At this time, the following Python platforms are officially supported:
|
||||
At this time, the following Python platforms are officially supported:
|
||||
|
||||
* cPython 2.5
|
||||
* cPython 2.6
|
||||
@@ -75,6 +83,7 @@ At this time, the following Python platforms are officially supported:
|
||||
* cPython 3.1
|
||||
* cPython 3.2
|
||||
* PyPy-c 1.4
|
||||
* PyPy-c 1.5
|
||||
|
||||
Support for other Pythons will be rolled out soon.
|
||||
|
||||
|
||||
+7
-7
@@ -87,7 +87,7 @@ Adding Columns
|
||||
|
||||
Now that we have a basic :class:`Dataset` in place, let's add a column of **ages** to it. ::
|
||||
|
||||
data.append(col=[22, 20], header='Age')
|
||||
data.append_col([22, 20], header='Age')
|
||||
|
||||
Let's view the data now. ::
|
||||
|
||||
@@ -158,7 +158,7 @@ Let's find the average age. ::
|
||||
Removing Rows & Columns
|
||||
-----------------------
|
||||
|
||||
It's easier than you could imagine. ::
|
||||
It's easier than you could imagine::
|
||||
|
||||
>>> del data['Col Name']
|
||||
|
||||
@@ -195,7 +195,7 @@ Let's add a dynamic column to our :class:`Dataset` object. In this example, we h
|
||||
"""Returns a random integer for entry."""
|
||||
return (random.randint(60,100)/100.0)
|
||||
|
||||
data.append(col=[random_grade], header='Grade')
|
||||
data.append_col(random_grade, header='Grade')
|
||||
|
||||
Let's have a look at our data. ::
|
||||
|
||||
@@ -253,13 +253,13 @@ Let's tag some students. ::
|
||||
|
||||
students.headers = ['first', 'last']
|
||||
|
||||
students.append(['Kenneth', 'Reitz'], tags=['male', 'technical'])
|
||||
students.append(['Bessie', 'Monke'], tags=['female', 'creative'])
|
||||
students.rpush(['Kenneth', 'Reitz'], tags=['male', 'technical'])
|
||||
students.rpush(['Bessie', 'Monke'], tags=['female', 'creative'])
|
||||
|
||||
Now that we have extra meta-data on our rows, we can use easily filter our :class:`Dataset`. Let's just see Male students. ::
|
||||
|
||||
|
||||
>>> data.filter(['male']).yaml
|
||||
>>> students.filter(['male']).yaml
|
||||
- {first: Kenneth, Last: Reitz}
|
||||
|
||||
It's that simple. The original :class:`Dataset` is untouched.
|
||||
@@ -273,7 +273,7 @@ When dealing with a large number of :class:`Datasets <Dataset>` in spreadsheet f
|
||||
|
||||
Let's say we have 3 different :class:`Datasets <Dataset>`. All we have to do is add then to a :class:`Databook` object... ::
|
||||
|
||||
book = tablib.Databook([data1, data2, data3])
|
||||
book = tablib.Databook((data1, data2, data3))
|
||||
|
||||
... and export to Excel just like :class:`Datasets <Dataset>`. ::
|
||||
|
||||
|
||||
@@ -4,40 +4,48 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from distutils.core import setup
|
||||
import tablib
|
||||
|
||||
try:
|
||||
from setuptools import setup, find_packages
|
||||
except ImportError:
|
||||
from distutils.core import setup, find_packages
|
||||
|
||||
|
||||
def publish():
|
||||
"""Publish to PyPi"""
|
||||
if sys.argv[-1] == 'publish':
|
||||
os.system("python setup.py sdist upload")
|
||||
|
||||
if sys.argv[-1] == "publish":
|
||||
publish()
|
||||
sys.exit()
|
||||
|
||||
required = []
|
||||
if sys.argv[-1] == 'speedups':
|
||||
try:
|
||||
__import__('pip')
|
||||
except ImportError:
|
||||
print('Pip required.')
|
||||
sys.exit(1)
|
||||
|
||||
if sys.version_info[:2] < (2,6):
|
||||
required.append('simplejson')
|
||||
os.system('pip install ujson pyyaml')
|
||||
sys.exit()
|
||||
|
||||
if sys.argv[-1] == 'test':
|
||||
try:
|
||||
__import__('py')
|
||||
except ImportError:
|
||||
print('py.test required.')
|
||||
sys.exit(1)
|
||||
|
||||
os.system('pytest test_tablib.py')
|
||||
sys.exit()
|
||||
|
||||
setup(
|
||||
name='tablib',
|
||||
version='0.9.7',
|
||||
version=tablib.__version__,
|
||||
description='Format agnostic tabular data library (XLS, JSON, YAML, CSV)',
|
||||
long_description=open('README.rst').read() + '\n\n' +
|
||||
open('HISTORY.rst').read(),
|
||||
long_description=(open('README.rst').read() + '\n\n' +
|
||||
open('HISTORY.rst').read()),
|
||||
author='Kenneth Reitz',
|
||||
author_email='me@kennethreitz.com',
|
||||
url='http://tablib.org',
|
||||
packages= [
|
||||
'tablib', 'tablib.formats',
|
||||
'tablib.packages',
|
||||
'tablib.packages.xlwt',
|
||||
'tablib.packages.openpyxl',
|
||||
'tablib.packages.yaml',
|
||||
'tablib.packages.unicodecsv'
|
||||
],
|
||||
install_requires=required,
|
||||
packages=find_packages(exclude=('docs',)),
|
||||
license='MIT',
|
||||
classifiers=(
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@
|
||||
|
||||
from tablib.core import (
|
||||
Databook, Dataset, detect, import_set,
|
||||
InvalidDatasetType, InvalidDimensions, UnsupportedFormat
|
||||
InvalidDatasetType, InvalidDimensions, UnsupportedFormat,
|
||||
__version__
|
||||
)
|
||||
|
||||
|
||||
+8
-8
@@ -25,25 +25,25 @@ if is_py3:
|
||||
import tablib.packages.xlwt3 as xlwt
|
||||
from tablib.packages import markup3 as markup
|
||||
from tablib.packages import openpyxl3 as openpyxl
|
||||
from tablib.packages.odf3 import opendocument, style, text, table
|
||||
|
||||
import csv
|
||||
from io import StringIO
|
||||
# py3 mappings
|
||||
ifilter = filter
|
||||
xrange = range
|
||||
|
||||
unicode = str
|
||||
bytes = bytes
|
||||
basestring = str
|
||||
|
||||
else:
|
||||
from cStringIO import StringIO as BytesIO
|
||||
from cStringIO import StringIO
|
||||
import tablib.packages.xlwt as xlwt
|
||||
from tablib.packages import markup
|
||||
from itertools import ifilter
|
||||
from tablib.packages import openpyxl
|
||||
from tablib.packages.odf import opendocument, style, text, table
|
||||
|
||||
# py2 mappings
|
||||
xrange = xrange
|
||||
unicode = unicode
|
||||
bytes = str
|
||||
basestring = basestring
|
||||
|
||||
from tablib.packages import unicodecsv as csv
|
||||
|
||||
unicode = unicode
|
||||
+273
-134
@@ -14,13 +14,12 @@ from operator import itemgetter
|
||||
|
||||
from tablib import formats
|
||||
|
||||
|
||||
from tablib.compat import OrderedDict
|
||||
|
||||
|
||||
__title__ = 'tablib'
|
||||
__version__ = '0.9.7'
|
||||
__build__ = 0x000907
|
||||
__version__ = '0.9.9'
|
||||
__build__ = 0x000909
|
||||
__author__ = 'Kenneth Reitz'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright 2011 Kenneth Reitz'
|
||||
@@ -58,13 +57,19 @@ class Row(object):
|
||||
del self._row[i]
|
||||
|
||||
def __getstate__(self):
|
||||
return {slot: [getattr(self, slot) for slot in self.__slots__]}
|
||||
return {'slot': [getattr(self, slot) for slot in self.__slots__]}
|
||||
|
||||
def __setstate__(self, state):
|
||||
for (k, v) in list(state.items()): setattr(self, k, v)
|
||||
|
||||
def rpush(self, value):
|
||||
self.insert(0, value)
|
||||
|
||||
def lpush(self, value):
|
||||
self.insert(len(value), value)
|
||||
|
||||
def append(self, value):
|
||||
self._row.append(value)
|
||||
self.rpush(value)
|
||||
|
||||
def insert(self, index, value):
|
||||
self._row.insert(index, value)
|
||||
@@ -74,12 +79,12 @@ class Row(object):
|
||||
|
||||
@property
|
||||
def tuple(self):
|
||||
'''Tuple representation of :class:`Row`.'''
|
||||
"""Tuple representation of :class:`Row`."""
|
||||
return tuple(self._row)
|
||||
|
||||
@property
|
||||
def list(self):
|
||||
'''List representation of :class:`Row`.'''
|
||||
"""List representation of :class:`Row`."""
|
||||
return list(self._row)
|
||||
|
||||
def has_tag(self, tag):
|
||||
@@ -201,6 +206,10 @@ class Dataset(object):
|
||||
return '<dataset object>'
|
||||
|
||||
|
||||
# ---------
|
||||
# Internals
|
||||
# ---------
|
||||
|
||||
@classmethod
|
||||
def _register_formats(cls):
|
||||
"""Adds format properties."""
|
||||
@@ -235,11 +244,17 @@ class Dataset(object):
|
||||
return False
|
||||
|
||||
|
||||
def _package(self, dicts=True):
|
||||
def _package(self, dicts=True, ordered=True):
|
||||
"""Packages Dataset into lists of dictionaries for transmission."""
|
||||
# TODO: Dicts default to false?
|
||||
|
||||
_data = list(self._data)
|
||||
|
||||
if ordered:
|
||||
dict_pack = OrderedDict
|
||||
else:
|
||||
dict_pack = dict
|
||||
|
||||
# Execute formatters
|
||||
if self._formatters:
|
||||
for row_i, row in enumerate(_data):
|
||||
@@ -256,7 +271,7 @@ class Dataset(object):
|
||||
|
||||
if self.headers:
|
||||
if dicts:
|
||||
data = [OrderedDict(list(zip(self.headers, data_row))) for data_row in _data]
|
||||
data = [dict_pack(list(zip(self.headers, data_row))) for data_row in _data]
|
||||
else:
|
||||
data = [list(self.headers)] + list(_data)
|
||||
else:
|
||||
@@ -265,46 +280,6 @@ class Dataset(object):
|
||||
return data
|
||||
|
||||
|
||||
def _clean_col(self, col):
|
||||
"""Prepares the given column for insert/append."""
|
||||
|
||||
col = list(col)
|
||||
|
||||
if self.headers:
|
||||
header = [col.pop(0)]
|
||||
else:
|
||||
header = []
|
||||
|
||||
if len(col) == 1 and hasattr(col[0], '__call__'):
|
||||
|
||||
col = list(map(col[0], self._data))
|
||||
col = tuple(header + col)
|
||||
|
||||
return col
|
||||
|
||||
|
||||
@property
|
||||
def height(self):
|
||||
"""The number of rows currently in the :class:`Dataset`.
|
||||
Cannot be directly modified.
|
||||
"""
|
||||
return len(self._data)
|
||||
|
||||
|
||||
@property
|
||||
def width(self):
|
||||
"""The number of columns currently in the :class:`Dataset`.
|
||||
Cannot be directly modified.
|
||||
"""
|
||||
|
||||
try:
|
||||
return len(self._data[0])
|
||||
except IndexError:
|
||||
try:
|
||||
return len(self.headers)
|
||||
except TypeError:
|
||||
return 0
|
||||
|
||||
|
||||
def _get_headers(self):
|
||||
"""An *optional* list of strings to be used for header rows and attribute names.
|
||||
@@ -328,6 +303,7 @@ class Dataset(object):
|
||||
|
||||
headers = property(_get_headers, _set_headers)
|
||||
|
||||
|
||||
def _get_dict(self):
|
||||
"""A native Python representation of the :class:`Dataset` object. If headers have
|
||||
been set, a list of Python dictionaries will be returned. If no headers have been set,
|
||||
@@ -375,9 +351,59 @@ class Dataset(object):
|
||||
dict = property(_get_dict, _set_dict)
|
||||
|
||||
|
||||
def _clean_col(self, col):
|
||||
"""Prepares the given column for insert/append."""
|
||||
|
||||
col = list(col)
|
||||
|
||||
if self.headers:
|
||||
header = [col.pop(0)]
|
||||
else:
|
||||
header = []
|
||||
|
||||
if len(col) == 1 and hasattr(col[0], '__call__'):
|
||||
|
||||
col = list(map(col[0], self._data))
|
||||
col = tuple(header + col)
|
||||
|
||||
return col
|
||||
|
||||
|
||||
@property
|
||||
def height(self):
|
||||
"""The number of rows currently in the :class:`Dataset`.
|
||||
Cannot be directly modified.
|
||||
"""
|
||||
return len(self._data)
|
||||
|
||||
|
||||
@property
|
||||
def width(self):
|
||||
"""The number of columns currently in the :class:`Dataset`.
|
||||
Cannot be directly modified.
|
||||
"""
|
||||
|
||||
try:
|
||||
return len(self._data[0])
|
||||
except IndexError:
|
||||
try:
|
||||
return len(self.headers)
|
||||
except TypeError:
|
||||
return 0
|
||||
|
||||
|
||||
# -------
|
||||
# Formats
|
||||
# -------
|
||||
|
||||
|
||||
@property
|
||||
def xls():
|
||||
"""An Excel Spreadsheet representation of the :class:`Dataset` object, with :ref:`separators`. Cannot be set.
|
||||
"""A Legacy Excel Spreadsheet representation of the :class:`Dataset` object, with :ref:`separators`. Cannot be set.
|
||||
|
||||
.. note::
|
||||
|
||||
XLS files are limited to a maximum of 65,000 rows. Use :class:`Dataset.xlsx` to avoid this limitation.
|
||||
|
||||
.. admonition:: Binary Warning
|
||||
|
||||
@@ -390,7 +416,7 @@ class Dataset(object):
|
||||
|
||||
@property
|
||||
def xlsx():
|
||||
"""An Excel Spreadsheet representation of the :class:`Dataset` object, with :ref:`separators`. Cannot be set.
|
||||
"""An Excel '07+ Spreadsheet representation of the :class:`Dataset` object, with :ref:`separators`. Cannot be set.
|
||||
|
||||
.. admonition:: Binary Warning
|
||||
|
||||
@@ -401,6 +427,18 @@ class Dataset(object):
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def ods():
|
||||
"""An OpenDocument Spreadsheet representation of the :class:`Dataset` object, with :ref:`separators`. Cannot be set.
|
||||
|
||||
.. admonition:: Binary Warning
|
||||
|
||||
:class:`Dataset.xlsx` contains binary data, so make sure to write in binary mode::
|
||||
|
||||
with open('output.ods', 'wb') as f:
|
||||
f.write(data.ods)'
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def csv():
|
||||
@@ -431,6 +469,7 @@ class Dataset(object):
|
||||
|
||||
Import assumes (for now) that headers exist.
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def yaml():
|
||||
@@ -472,61 +511,12 @@ class Dataset(object):
|
||||
pass
|
||||
|
||||
|
||||
def append(self, row=None, col=None, header=None, tags=list()):
|
||||
"""Adds a row or column to the :class:`Dataset`.
|
||||
Usage is :class:`Dataset.insert` for documentation.
|
||||
"""
|
||||
# ----
|
||||
# Rows
|
||||
# ----
|
||||
|
||||
if row is not None:
|
||||
self.insert(self.height, row=row, tags=tags)
|
||||
elif col is not None:
|
||||
self.insert(self.width, col=col, header=header)
|
||||
|
||||
|
||||
def insert_separator(self, index, text='-'):
|
||||
"""Adds a separator to :class:`Dataset` at given index."""
|
||||
|
||||
sep = (index, text)
|
||||
self._separators.append(sep)
|
||||
|
||||
|
||||
def append_separator(self, text='-'):
|
||||
"""Adds a :ref:`separator <separators>` to the :class:`Dataset`."""
|
||||
|
||||
# change offsets if headers are or aren't defined
|
||||
if not self.headers:
|
||||
index = self.height if self.height else 0
|
||||
else:
|
||||
index = (self.height + 1) if self.height else 1
|
||||
|
||||
self.insert_separator(index, text)
|
||||
|
||||
|
||||
def add_formatter(self, col, handler):
|
||||
"""Adds a :ref:`formatter` to the :class:`Dataset`.
|
||||
|
||||
.. versionadded:: 0.9.5
|
||||
:param col: column to. Accepts index int or header str.
|
||||
:param handler: reference to callback function to execute
|
||||
against each cell value.
|
||||
"""
|
||||
|
||||
if isinstance(col, str):
|
||||
if col in self.headers:
|
||||
col = self.headers.index(col) # get 'key' index from each data
|
||||
else:
|
||||
raise KeyError
|
||||
|
||||
if not col > self.width:
|
||||
self._formatters.append((col, handler))
|
||||
else:
|
||||
raise InvalidDatasetIndex
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def insert(self, index, row=None, col=None, header=None, tags=list()):
|
||||
"""Inserts a row or column to the :class:`Dataset` at the given index.
|
||||
def insert(self, index, row, tags=list()):
|
||||
"""Inserts a row to the :class:`Dataset` at the given index.
|
||||
|
||||
Rows and columns inserted must be the correct size (height or width).
|
||||
|
||||
@@ -551,35 +541,176 @@ class Dataset(object):
|
||||
If inserting a row, you can add :ref:`tags <tags>` to the row you are inserting.
|
||||
This gives you the ability to :class:`filter <Dataset.filter>` your
|
||||
:class:`Dataset` later.
|
||||
|
||||
"""
|
||||
if row:
|
||||
self._validate(row)
|
||||
self._data.insert(index, Row(row, tags=tags))
|
||||
elif col:
|
||||
col = list(col)
|
||||
|
||||
# Callable Columns...
|
||||
if len(col) == 1 and hasattr(col[0], '__call__'):
|
||||
col = list(map(col[0], self._data))
|
||||
self._validate(row)
|
||||
self._data.insert(index, Row(row, tags=tags))
|
||||
|
||||
col = self._clean_col(col)
|
||||
self._validate(col=col)
|
||||
|
||||
if self.headers:
|
||||
# pop the first item off, add to headers
|
||||
if not header:
|
||||
raise HeadersNeeded()
|
||||
self.headers.insert(index, header)
|
||||
def rpush(self, row, tags=list()):
|
||||
"""Adds a row to the end of the :class:`Dataset`.
|
||||
See :class:`Dataset.insert` for additional documentation.
|
||||
"""
|
||||
|
||||
if self.height and self.width:
|
||||
self.insert(self.height, row=row, tags=tags)
|
||||
|
||||
for i, row in enumerate(self._data):
|
||||
|
||||
row.insert(index, col[i])
|
||||
self._data[i] = row
|
||||
def lpush(self, row, tags=list()):
|
||||
"""Adds a row to the top of the :class:`Dataset`.
|
||||
See :class:`Dataset.insert` for additional documentation.
|
||||
"""
|
||||
|
||||
self.insert(0, row=row, tags=tags)
|
||||
|
||||
|
||||
def append(self, row, tags=list()):
|
||||
"""Adds a row to the :class:`Dataset`.
|
||||
See :class:`Dataset.insert` for additional documentation.
|
||||
"""
|
||||
|
||||
self.rpush(row, tags)
|
||||
|
||||
|
||||
def lpop(self):
|
||||
"""Removes and returns the first row of the :class:`Dataset`."""
|
||||
|
||||
cache = self[0]
|
||||
del self[0]
|
||||
|
||||
return cache
|
||||
|
||||
|
||||
def rpop(self):
|
||||
"""Removes and returns the last row of the :class:`Dataset`."""
|
||||
|
||||
cache = self[-1]
|
||||
del self[-1]
|
||||
|
||||
return cache
|
||||
|
||||
|
||||
def pop(self):
|
||||
"""Removes and returns the last row of the :class:`Dataset`."""
|
||||
|
||||
return self.rpop()
|
||||
|
||||
|
||||
# -------
|
||||
# Columns
|
||||
# -------
|
||||
|
||||
def insert_col(self, index, col=None, header=None):
|
||||
"""Inserts a column to the :class:`Dataset` at the given index.
|
||||
|
||||
Columns inserted must be the correct height.
|
||||
|
||||
You can also insert a column of a single callable object, which will
|
||||
add a new column with the return values of the callable each as an
|
||||
item in the column. ::
|
||||
|
||||
data.append_col(col=random.randint)
|
||||
|
||||
If inserting a column, and :class:`Dataset.headers` is set, the
|
||||
header attribute must be set, and will be considered the header for
|
||||
that row.
|
||||
|
||||
See :ref:`dyncols` for an in-depth example.
|
||||
"""
|
||||
|
||||
col = list(col)
|
||||
|
||||
# Callable Columns...
|
||||
if len(col) == 1 and hasattr(col[0], '__call__'):
|
||||
col = list(map(col[0], self._data))
|
||||
|
||||
col = self._clean_col(col)
|
||||
self._validate(col=col)
|
||||
|
||||
if self.headers:
|
||||
# pop the first item off, add to headers
|
||||
if not header:
|
||||
raise HeadersNeeded()
|
||||
self.headers.insert(index, header)
|
||||
|
||||
if self.height and self.width:
|
||||
|
||||
for i, row in enumerate(self._data):
|
||||
|
||||
row.insert(index, col[i])
|
||||
self._data[i] = row
|
||||
else:
|
||||
self._data = [Row([row]) for row in col]
|
||||
|
||||
|
||||
|
||||
def rpush_col(self, col, header=None):
|
||||
"""Adds a column to the end of the :class:`Dataset`.
|
||||
See :class:`Dataset.insert` for additional documentation.
|
||||
"""
|
||||
|
||||
self.insert_col(self.width, col, header=header)
|
||||
|
||||
|
||||
def lpush_col(self, col, header=None):
|
||||
"""Adds a column to the top of the :class:`Dataset`.
|
||||
See :class:`Dataset.insert` for additional documentation.
|
||||
"""
|
||||
|
||||
self.insert_col(0, col, header=header)
|
||||
|
||||
|
||||
def insert_separator(self, index, text='-'):
|
||||
"""Adds a separator to :class:`Dataset` at given index."""
|
||||
|
||||
sep = (index, text)
|
||||
self._separators.append(sep)
|
||||
|
||||
|
||||
def append_separator(self, text='-'):
|
||||
"""Adds a :ref:`separator <separators>` to the :class:`Dataset`."""
|
||||
|
||||
# change offsets if headers are or aren't defined
|
||||
if not self.headers:
|
||||
index = self.height if self.height else 0
|
||||
else:
|
||||
index = (self.height + 1) if self.height else 1
|
||||
|
||||
self.insert_separator(index, text)
|
||||
|
||||
|
||||
def append_col(self, col, header=None):
|
||||
"""Adds a column to the :class:`Dataset`.
|
||||
See :class:`Dataset.insert_col` for additional documentation.
|
||||
"""
|
||||
|
||||
self.rpush_col(col, header)
|
||||
|
||||
|
||||
# ----
|
||||
# Misc
|
||||
# ----
|
||||
|
||||
def add_formatter(self, col, handler):
|
||||
"""Adds a :ref:`formatter` to the :class:`Dataset`.
|
||||
|
||||
.. versionadded:: 0.9.5
|
||||
:param col: column to. Accepts index int or header str.
|
||||
:param handler: reference to callback function to execute
|
||||
against each cell value.
|
||||
"""
|
||||
|
||||
if isinstance(col, str):
|
||||
if col in self.headers:
|
||||
col = self.headers.index(col) # get 'key' index from each data
|
||||
else:
|
||||
self._data = [Row([row]) for row in col]
|
||||
raise KeyError
|
||||
|
||||
if not col > self.width:
|
||||
self._formatters.append((col, handler))
|
||||
else:
|
||||
raise InvalidDatasetIndex
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def filter(self, tag):
|
||||
@@ -596,8 +727,10 @@ class Dataset(object):
|
||||
"""Sort a :class:`Dataset` by a specific column, given string (for
|
||||
header) or integer (for column index). The order can be reversed by
|
||||
setting ``reverse`` to ``True``.
|
||||
|
||||
Returns a new :class:`Dataset` instance where columns have been
|
||||
sorted."""
|
||||
sorted.
|
||||
"""
|
||||
|
||||
if isinstance(col, str):
|
||||
|
||||
@@ -658,7 +791,7 @@ class Dataset(object):
|
||||
return _dset
|
||||
|
||||
|
||||
def stack_rows(self, other):
|
||||
def stack(self, other):
|
||||
"""Stack two :class:`Dataset` instances together by
|
||||
joining at the row level, and return new combined
|
||||
``Dataset`` instance."""
|
||||
@@ -681,7 +814,7 @@ class Dataset(object):
|
||||
return _dset
|
||||
|
||||
|
||||
def stack_columns(self, other):
|
||||
def stack_cols(self, other):
|
||||
"""Stack two :class:`Dataset` instances together by
|
||||
joining at the column level, and return a new
|
||||
combined ``Dataset`` instance. If either ``Dataset``
|
||||
@@ -705,10 +838,10 @@ class Dataset(object):
|
||||
_dset = Dataset()
|
||||
|
||||
for column in self.headers:
|
||||
_dset.append(col=self[column])
|
||||
_dset.append_col(col=self[column])
|
||||
|
||||
for column in other.headers:
|
||||
_dset.append(col=other[column])
|
||||
_dset.append_col(col=other[column])
|
||||
|
||||
_dset.headers = new_headers
|
||||
|
||||
@@ -769,13 +902,19 @@ class Databook(object):
|
||||
raise InvalidDatasetType
|
||||
|
||||
|
||||
def _package(self):
|
||||
def _package(self, ordered=True):
|
||||
"""Packages :class:`Databook` for delivery."""
|
||||
collector = []
|
||||
|
||||
if ordered:
|
||||
dict_pack = OrderedDict
|
||||
else:
|
||||
dict_pack = dict
|
||||
|
||||
for dset in self._datasets:
|
||||
collector.append(OrderedDict(
|
||||
collector.append(dict_pack(
|
||||
title = dset.title,
|
||||
data = dset.dict
|
||||
data = dset._package(ordered=ordered)
|
||||
))
|
||||
return collector
|
||||
|
||||
|
||||
@@ -10,5 +10,6 @@ from . import _yaml as yaml
|
||||
from . import _tsv as tsv
|
||||
from . import _html as html
|
||||
from . import _xlsx as xlsx
|
||||
from . import _ods as ods
|
||||
|
||||
available = (json, xls, yaml, csv, tsv, html, xlsx)
|
||||
available = (json, xls, yaml, csv, tsv, html, xlsx, ods)
|
||||
|
||||
+2
-17
@@ -3,22 +3,7 @@
|
||||
""" Tablib - CSV Support.
|
||||
"""
|
||||
|
||||
import sys
|
||||
if sys.version_info[0] > 2:
|
||||
is_py3 = True
|
||||
|
||||
from io import StringIO
|
||||
import csv
|
||||
else:
|
||||
is_py3 = False
|
||||
from cStringIO import StringIO
|
||||
import tablib.packages.unicodecsv as csv
|
||||
|
||||
|
||||
|
||||
import os
|
||||
|
||||
import tablib
|
||||
from tablib.compat import is_py3, csv, StringIO
|
||||
|
||||
|
||||
title = 'csv'
|
||||
@@ -64,7 +49,7 @@ def import_set(dset, in_stream, headers=True):
|
||||
def detect(stream):
|
||||
"""Returns True if given stream is valid CSV."""
|
||||
try:
|
||||
rows = dialect = csv.Sniffer().sniff(stream)
|
||||
csv.Sniffer().sniff(stream)
|
||||
return True
|
||||
except csv.Error:
|
||||
return False
|
||||
+6
-10
@@ -6,11 +6,7 @@
|
||||
import tablib
|
||||
|
||||
import sys
|
||||
if sys.version_info[:2] > (2, 5):
|
||||
from tablib.packages import anyjson
|
||||
else:
|
||||
from tablib.packages import anyjson25 as anyjson
|
||||
|
||||
from tablib.packages import omnijson as json
|
||||
|
||||
|
||||
title = 'json'
|
||||
@@ -19,26 +15,26 @@ extentions = ('json', 'jsn')
|
||||
|
||||
def export_set(dataset):
|
||||
"""Returns JSON representation of Dataset."""
|
||||
return anyjson.serialize(dataset.dict)
|
||||
return json.dumps(dataset.dict)
|
||||
|
||||
|
||||
def export_book(databook):
|
||||
"""Returns JSON representation of Databook."""
|
||||
return anyjson.serialize(databook._package())
|
||||
return json.dumps(databook._package())
|
||||
|
||||
|
||||
def import_set(dset, in_stream):
|
||||
"""Returns dataset from JSON stream."""
|
||||
|
||||
dset.wipe()
|
||||
dset.dict = anyjson.deserialize(in_stream)
|
||||
dset.dict = json.loads(in_stream)
|
||||
|
||||
|
||||
def import_book(dbook, in_stream):
|
||||
"""Returns databook from JSON stream."""
|
||||
|
||||
dbook.wipe()
|
||||
for sheet in anyjson.deserialize(in_stream):
|
||||
for sheet in json.loads(in_stream):
|
||||
data = tablib.Dataset()
|
||||
data.title = sheet['title']
|
||||
data.dict = sheet['data']
|
||||
@@ -48,7 +44,7 @@ def import_book(dbook, in_stream):
|
||||
def detect(stream):
|
||||
"""Returns True if given stream is valid JSON."""
|
||||
try:
|
||||
anyjson.deserialize(stream)
|
||||
json.loads(stream)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Tablib - ODF Support.
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
if sys.version_info[0] > 2:
|
||||
from io import BytesIO
|
||||
else:
|
||||
from cStringIO import StringIO as BytesIO
|
||||
|
||||
from tablib.compat import opendocument, style, table, text, unicode
|
||||
|
||||
title = 'ods'
|
||||
extentions = ('ods',)
|
||||
|
||||
bold = style.Style(name="bold", family="paragraph")
|
||||
bold.addElement(style.TextProperties(fontweight="bold", fontweightasian="bold", fontweightcomplex="bold"))
|
||||
|
||||
def export_set(dataset):
|
||||
"""Returns ODF representation of Dataset."""
|
||||
|
||||
wb = opendocument.OpenDocumentSpreadsheet()
|
||||
wb.automaticstyles.addElement(bold)
|
||||
|
||||
ws = table.Table(name=dataset.title if dataset.title else 'Tablib Dataset')
|
||||
wb.spreadsheet.addElement(ws)
|
||||
dset_sheet(dataset, ws)
|
||||
|
||||
stream = BytesIO()
|
||||
wb.save(stream)
|
||||
return stream.getvalue()
|
||||
|
||||
|
||||
def export_book(databook):
|
||||
"""Returns ODF representation of DataBook."""
|
||||
|
||||
wb = opendocument.OpenDocumentSpreadsheet()
|
||||
wb.automaticstyles.addElement(bold)
|
||||
|
||||
for i, dset in enumerate(databook._datasets):
|
||||
ws = table.Table(name=dset.title if dset.title else 'Sheet%s' % (i))
|
||||
wb.spreadsheet.addElement(ws)
|
||||
dset_sheet(dset, ws)
|
||||
|
||||
|
||||
stream = BytesIO()
|
||||
wb.save(stream)
|
||||
return stream.getvalue()
|
||||
|
||||
|
||||
def dset_sheet(dataset, ws):
|
||||
"""Completes given worksheet from given Dataset."""
|
||||
_package = dataset._package(dicts=False)
|
||||
|
||||
for i, sep in enumerate(dataset._separators):
|
||||
_offset = i
|
||||
_package.insert((sep[0] + _offset), (sep[1],))
|
||||
|
||||
for i, row in enumerate(_package):
|
||||
row_number = i + 1
|
||||
odf_row = table.TableRow(stylename=bold, defaultcellstylename='bold')
|
||||
for j, col in enumerate(row):
|
||||
try:
|
||||
col = unicode(col, errors='ignore')
|
||||
except TypeError:
|
||||
## col is already unicode
|
||||
pass
|
||||
ws.addElement(table.TableColumn())
|
||||
|
||||
# bold headers
|
||||
if (row_number == 1) and dataset.headers:
|
||||
odf_row.setAttribute('stylename', bold)
|
||||
ws.addElement(odf_row)
|
||||
cell = table.TableCell()
|
||||
p = text.P()
|
||||
p.addElement(text.Span(text=col, stylename=bold))
|
||||
cell.addElement(p)
|
||||
odf_row.addElement(cell)
|
||||
|
||||
# wrap the rest
|
||||
else:
|
||||
try:
|
||||
if '\n' in col:
|
||||
ws.addElement(odf_row)
|
||||
cell = table.TableCell()
|
||||
cell.addElement(text.P(text=col))
|
||||
odf_row.addElement(cell)
|
||||
else:
|
||||
ws.addElement(odf_row)
|
||||
cell = table.TableCell()
|
||||
cell.addElement(text.P(text=col))
|
||||
odf_row.addElement(cell)
|
||||
except TypeError:
|
||||
ws.addElement(odf_row)
|
||||
cell = table.TableCell()
|
||||
cell.addElement(text.P(text=col))
|
||||
odf_row.addElement(cell)
|
||||
+16
-13
@@ -3,27 +3,24 @@
|
||||
""" Tablib - TSV (Tab Separated Values) Support.
|
||||
"""
|
||||
|
||||
import sys
|
||||
if sys.version_info[0] > 2:
|
||||
from io import StringIO
|
||||
else:
|
||||
from cStringIO import StringIO
|
||||
|
||||
import csv
|
||||
import os
|
||||
from tablib.compat import is_py3, csv, StringIO
|
||||
|
||||
import tablib
|
||||
|
||||
|
||||
title = 'tsv'
|
||||
extentions = ('tsv',)
|
||||
|
||||
|
||||
DEFAULT_ENCODING = 'utf-8'
|
||||
|
||||
def export_set(dataset):
|
||||
"""Returns a TSV representation of Dataset."""
|
||||
|
||||
stream = StringIO()
|
||||
_tsv = csv.writer(stream, delimiter='\t')
|
||||
|
||||
if is_py3:
|
||||
_tsv = csv.writer(stream, delimiter='\t')
|
||||
else:
|
||||
_tsv = csv.writer(stream, encoding=DEFAULT_ENCODING, delimiter='\t')
|
||||
|
||||
for row in dataset._package(dicts=False):
|
||||
_tsv.writerow(row)
|
||||
@@ -33,9 +30,15 @@ def export_set(dataset):
|
||||
|
||||
def import_set(dset, in_stream, headers=True):
|
||||
"""Returns dataset from TSV stream."""
|
||||
|
||||
dset.wipe()
|
||||
|
||||
rows = csv.reader(in_stream.split('\r\n'), delimiter='\t')
|
||||
if is_py3:
|
||||
rows = csv.reader(in_stream.split('\r\n'), delimiter='\t')
|
||||
else:
|
||||
rows = csv.reader(in_stream.split('\r\n'), delimiter='\t',
|
||||
encoding=DEFAULT_ENCODING)
|
||||
|
||||
for i, row in enumerate(rows):
|
||||
# Skip empty rows
|
||||
if not row:
|
||||
@@ -50,7 +53,7 @@ def import_set(dset, in_stream, headers=True):
|
||||
def detect(stream):
|
||||
"""Returns True if given stream is valid TSV."""
|
||||
try:
|
||||
rows = dialect = csv.Sniffer().sniff(stream, delimiters='\t')
|
||||
csv.Sniffer().sniff(stream, delimiters='\t')
|
||||
return True
|
||||
except csv.Error:
|
||||
return False
|
||||
|
||||
@@ -12,7 +12,7 @@ except ImportError:
|
||||
import tablib.packages.yaml3 as yaml
|
||||
else:
|
||||
import tablib.packages.yaml as yaml
|
||||
|
||||
|
||||
|
||||
import tablib
|
||||
|
||||
@@ -25,7 +25,8 @@ extentions = ('yaml', 'yml')
|
||||
|
||||
def export_set(dataset):
|
||||
"""Returns YAML representation of Dataset."""
|
||||
return yaml.dump(dataset.dict)
|
||||
|
||||
return yaml.dump(dataset._package(ordered=False))
|
||||
|
||||
|
||||
def export_book(databook):
|
||||
@@ -50,7 +51,7 @@ def import_book(dbook, in_stream):
|
||||
data.title = sheet['title']
|
||||
data.dict = sheet['data']
|
||||
dbook.add_sheet(data)
|
||||
|
||||
|
||||
def detect(stream):
|
||||
"""Returns True if given stream is valid YAML."""
|
||||
try:
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
"""
|
||||
Wraps the best available JSON implementation available in a common interface
|
||||
"""
|
||||
|
||||
__version__ = "0.2.0"
|
||||
__author__ = "Rune Halvorsen <runefh@gmail.com>"
|
||||
__homepage__ = "http://bitbucket.org/runeh/anyjson/"
|
||||
__docformat__ = "restructuredtext"
|
||||
|
||||
"""
|
||||
|
||||
.. function:: serialize(obj)
|
||||
|
||||
Serialize the object to JSON.
|
||||
|
||||
.. function:: deserialize(str)
|
||||
|
||||
Deserialize JSON-encoded object to a Python object.
|
||||
|
||||
.. function:: force_implementation(name)
|
||||
|
||||
Load a specific json module. This is useful for testing and not much else
|
||||
|
||||
.. attribute:: implementation
|
||||
|
||||
The json implementation object. This is probably not useful to you,
|
||||
except to get the name of the implementation in use. The name is
|
||||
available through `implementation.name`.
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
implementation = None
|
||||
|
||||
"""
|
||||
.. data:: _modules
|
||||
|
||||
List of known json modules, and the names of their serialize/unserialize
|
||||
methods, as well as the exception they throw. Exception can be either
|
||||
an exception class or a string.
|
||||
"""
|
||||
_modules = [("cjson", "encode", "EncodeError", "decode", "DecodeError"),
|
||||
("jsonlib2", "write", "WriteError", "read", "ReadError"),
|
||||
("jsonlib", "write", "WriteError", "read", "ReadError"),
|
||||
("simplejson", "dumps", TypeError, "loads", ValueError),
|
||||
("json", "dumps", TypeError, "loads", ValueError),
|
||||
("django.utils.simplejson", "dumps", TypeError, "loads",
|
||||
ValueError)]
|
||||
_fields = ("modname", "encoder", "encerror", "decoder", "decerror")
|
||||
|
||||
|
||||
class _JsonImplementation(object):
|
||||
"""Incapsulates a JSON implementation"""
|
||||
|
||||
def __init__(self, modspec):
|
||||
modinfo = dict(list(zip(_fields, modspec)))
|
||||
|
||||
# No try block. We want importerror to end up at caller
|
||||
module = self._attempt_load(modinfo["modname"])
|
||||
|
||||
self.implementation = modinfo["modname"]
|
||||
self._encode = getattr(module, modinfo["encoder"])
|
||||
self._decode = getattr(module, modinfo["decoder"])
|
||||
self._encode_error = modinfo["encerror"]
|
||||
self._decode_error = modinfo["decerror"]
|
||||
|
||||
if isinstance(modinfo["encerror"], str):
|
||||
self._encode_error = getattr(module, modinfo["encerror"])
|
||||
if isinstance(modinfo["decerror"], str):
|
||||
self._decode_error = getattr(module, modinfo["decerror"])
|
||||
|
||||
self.name = modinfo["modname"]
|
||||
|
||||
def _attempt_load(self, modname):
|
||||
"""Attempt to load module name modname, returning it on success,
|
||||
throwing ImportError if module couldn't be imported"""
|
||||
__import__(modname)
|
||||
return sys.modules[modname]
|
||||
|
||||
def serialize(self, data):
|
||||
"""Serialize the datastructure to json. Returns a string. Raises
|
||||
TypeError if the object could not be serialized."""
|
||||
try:
|
||||
return self._encode(data)
|
||||
except self._encode_error as exc:
|
||||
raise TypeError(*exc.args)
|
||||
|
||||
def deserialize(self, s):
|
||||
"""deserialize the string to python data types. Raises
|
||||
ValueError if the string vould not be parsed."""
|
||||
try:
|
||||
return self._decode(s)
|
||||
except self._decode_error as exc:
|
||||
raise ValueError(*exc.args)
|
||||
|
||||
|
||||
def force_implementation(modname):
|
||||
"""Forces anyjson to use a specific json module if it's available"""
|
||||
global implementation
|
||||
for name, spec in [(e[0], e) for e in _modules]:
|
||||
if name == modname:
|
||||
implementation = _JsonImplementation(spec)
|
||||
return
|
||||
raise ImportError("No module named: %s" % modname)
|
||||
|
||||
|
||||
for modspec in _modules:
|
||||
try:
|
||||
implementation = _JsonImplementation(modspec)
|
||||
break
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
raise ImportError("No supported JSON module found")
|
||||
|
||||
serialize = lambda value: implementation.serialize(value)
|
||||
deserialize = lambda value: implementation.deserialize(value)
|
||||
@@ -1,118 +0,0 @@
|
||||
u"""
|
||||
Wraps the best available JSON implementation available in a common interface
|
||||
"""
|
||||
|
||||
__version__ = u"0.2.0"
|
||||
__author__ = u"Rune Halvorsen <runefh@gmail.com>"
|
||||
__homepage__ = u"http://bitbucket.org/runeh/anyjson/"
|
||||
__docformat__ = u"restructuredtext"
|
||||
|
||||
u"""
|
||||
|
||||
.. function:: serialize(obj)
|
||||
|
||||
Serialize the object to JSON.
|
||||
|
||||
.. function:: deserialize(str)
|
||||
|
||||
Deserialize JSON-encoded object to a Python object.
|
||||
|
||||
.. function:: force_implementation(name)
|
||||
|
||||
Load a specific json module. This is useful for testing and not much else
|
||||
|
||||
.. attribute:: implementation
|
||||
|
||||
The json implementation object. This is probably not useful to you,
|
||||
except to get the name of the implementation in use. The name is
|
||||
available through `implementation.name`.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from itertools import izip
|
||||
|
||||
implementation = None
|
||||
|
||||
u"""
|
||||
.. data:: _modules
|
||||
|
||||
List of known json modules, and the names of their serialize/unserialize
|
||||
methods, as well as the exception they throw. Exception can be either
|
||||
an exception class or a string.
|
||||
"""
|
||||
_modules = [(u"cjson", u"encode", u"EncodeError", u"decode", u"DecodeError"),
|
||||
(u"jsonlib2", u"write", u"WriteError", u"read", u"ReadError"),
|
||||
(u"jsonlib", u"write", u"WriteError", u"read", u"ReadError"),
|
||||
(u"simplejson", u"dumps", TypeError, u"loads", ValueError),
|
||||
(u"json", u"dumps", TypeError, u"loads", ValueError),
|
||||
(u"django.utils.simplejson", u"dumps", TypeError, u"loads",
|
||||
ValueError)]
|
||||
_fields = (u"modname", u"encoder", u"encerror", u"decoder", u"decerror")
|
||||
|
||||
|
||||
class _JsonImplementation(object):
|
||||
u"""Incapsulates a JSON implementation"""
|
||||
|
||||
def __init__(self, modspec):
|
||||
modinfo = dict(list(izip(_fields, modspec)))
|
||||
|
||||
# No try block. We want importerror to end up at caller
|
||||
module = self._attempt_load(modinfo[u"modname"])
|
||||
|
||||
self.implementation = modinfo[u"modname"]
|
||||
self._encode = getattr(module, modinfo[u"encoder"])
|
||||
self._decode = getattr(module, modinfo[u"decoder"])
|
||||
self._encode_error = modinfo[u"encerror"]
|
||||
self._decode_error = modinfo[u"decerror"]
|
||||
|
||||
if isinstance(modinfo[u"encerror"], unicode):
|
||||
self._encode_error = getattr(module, modinfo[u"encerror"])
|
||||
if isinstance(modinfo[u"decerror"], unicode):
|
||||
self._decode_error = getattr(module, modinfo[u"decerror"])
|
||||
|
||||
self.name = modinfo[u"modname"]
|
||||
|
||||
def _attempt_load(self, modname):
|
||||
u"""Attempt to load module name modname, returning it on success,
|
||||
throwing ImportError if module couldn't be imported"""
|
||||
__import__(modname)
|
||||
return sys.modules[modname]
|
||||
|
||||
def serialize(self, data):
|
||||
u"""Serialize the datastructure to json. Returns a string. Raises
|
||||
TypeError if the object could not be serialized."""
|
||||
try:
|
||||
return self._encode(data)
|
||||
except self._encode_error, exc:
|
||||
raise TypeError(*exc.args)
|
||||
|
||||
def deserialize(self, s):
|
||||
u"""deserialize the string to python data types. Raises
|
||||
ValueError if the string vould not be parsed."""
|
||||
try:
|
||||
return self._decode(s)
|
||||
except self._decode_error, exc:
|
||||
raise ValueError(*exc.args)
|
||||
|
||||
|
||||
def force_implementation(modname):
|
||||
u"""Forces anyjson to use a specific json module if it's available"""
|
||||
global implementation
|
||||
for name, spec in [(e[0], e) for e in _modules]:
|
||||
if name == modname:
|
||||
implementation = _JsonImplementation(spec)
|
||||
return
|
||||
raise ImportError(u"No module named: %s" % modname)
|
||||
|
||||
|
||||
for modspec in _modules:
|
||||
try:
|
||||
implementation = _JsonImplementation(modspec)
|
||||
break
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
raise ImportError(u"No supported JSON module found")
|
||||
|
||||
serialize = lambda value: implementation.serialize(value)
|
||||
deserialize = lambda value: implementation.deserialize(value)
|
||||
@@ -0,0 +1,61 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import ANIMNS
|
||||
from element import Element
|
||||
|
||||
|
||||
# Autogenerated
|
||||
def Animate(**args):
|
||||
return Element(qname = (ANIMNS,'animate'), **args)
|
||||
|
||||
def Animatecolor(**args):
|
||||
return Element(qname = (ANIMNS,'animateColor'), **args)
|
||||
|
||||
def Animatemotion(**args):
|
||||
return Element(qname = (ANIMNS,'animateMotion'), **args)
|
||||
|
||||
def Animatetransform(**args):
|
||||
return Element(qname = (ANIMNS,'animateTransform'), **args)
|
||||
|
||||
def Audio(**args):
|
||||
return Element(qname = (ANIMNS,'audio'), **args)
|
||||
|
||||
def Command(**args):
|
||||
return Element(qname = (ANIMNS,'command'), **args)
|
||||
|
||||
def Iterate(**args):
|
||||
return Element(qname = (ANIMNS,'iterate'), **args)
|
||||
|
||||
def Par(**args):
|
||||
return Element(qname = (ANIMNS,'par'), **args)
|
||||
|
||||
def Param(**args):
|
||||
return Element(qname = (ANIMNS,'param'), **args)
|
||||
|
||||
def Seq(**args):
|
||||
return Element(qname = (ANIMNS,'seq'), **args)
|
||||
|
||||
def Set(**args):
|
||||
return Element(qname = (ANIMNS,'set'), **args)
|
||||
|
||||
def Transitionfilter(**args):
|
||||
return Element(qname = (ANIMNS,'transitionFilter'), **args)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,87 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import CHARTNS
|
||||
from element import Element
|
||||
|
||||
# Autogenerated
|
||||
def Axis(**args):
|
||||
return Element(qname = (CHARTNS,'axis'), **args)
|
||||
|
||||
def Categories(**args):
|
||||
return Element(qname = (CHARTNS,'categories'), **args)
|
||||
|
||||
def Chart(**args):
|
||||
return Element(qname = (CHARTNS,'chart'), **args)
|
||||
|
||||
def DataPoint(**args):
|
||||
return Element(qname = (CHARTNS,'data-point'), **args)
|
||||
|
||||
def Domain(**args):
|
||||
return Element(qname = (CHARTNS,'domain'), **args)
|
||||
|
||||
def ErrorIndicator(**args):
|
||||
return Element(qname = (CHARTNS,'error-indicator'), **args)
|
||||
|
||||
def Floor(**args):
|
||||
return Element(qname = (CHARTNS,'floor'), **args)
|
||||
|
||||
def Footer(**args):
|
||||
return Element(qname = (CHARTNS,'footer'), **args)
|
||||
|
||||
def Grid(**args):
|
||||
return Element(qname = (CHARTNS,'grid'), **args)
|
||||
|
||||
def Legend(**args):
|
||||
return Element(qname = (CHARTNS,'legend'), **args)
|
||||
|
||||
def MeanValue(**args):
|
||||
return Element(qname = (CHARTNS,'mean-value'), **args)
|
||||
|
||||
def PlotArea(**args):
|
||||
return Element(qname = (CHARTNS,'plot-area'), **args)
|
||||
|
||||
def RegressionCurve(**args):
|
||||
return Element(qname = (CHARTNS,'regression-curve'), **args)
|
||||
|
||||
def Series(**args):
|
||||
return Element(qname = (CHARTNS,'series'), **args)
|
||||
|
||||
def StockGainMarker(**args):
|
||||
return Element(qname = (CHARTNS,'stock-gain-marker'), **args)
|
||||
|
||||
def StockLossMarker(**args):
|
||||
return Element(qname = (CHARTNS,'stock-loss-marker'), **args)
|
||||
|
||||
def StockRangeLine(**args):
|
||||
return Element(qname = (CHARTNS,'stock-range-line'), **args)
|
||||
|
||||
def Subtitle(**args):
|
||||
return Element(qname = (CHARTNS,'subtitle'), **args)
|
||||
|
||||
def SymbolImage(**args):
|
||||
return Element(qname = (CHARTNS,'symbol-image'), **args)
|
||||
|
||||
def Title(**args):
|
||||
return Element(qname = (CHARTNS,'title'), **args)
|
||||
|
||||
def Wall(**args):
|
||||
return Element(qname = (CHARTNS,'wall'), **args)
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import CONFIGNS
|
||||
from element import Element
|
||||
|
||||
# Autogenerated
|
||||
def ConfigItem(**args):
|
||||
return Element(qname = (CONFIGNS, 'config-item'), **args)
|
||||
|
||||
def ConfigItemMapEntry(**args):
|
||||
return Element(qname = (CONFIGNS,'config-item-map-entry'), **args)
|
||||
|
||||
def ConfigItemMapIndexed(**args):
|
||||
return Element(qname = (CONFIGNS,'config-item-map-indexed'), **args)
|
||||
|
||||
def ConfigItemMapNamed(**args):
|
||||
return Element(qname = (CONFIGNS,'config-item-map-named'), **args)
|
||||
|
||||
def ConfigItemSet(**args):
|
||||
return Element(qname = (CONFIGNS, 'config-item-set'), **args)
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import DCNS
|
||||
from element import Element
|
||||
|
||||
# Autogenerated
|
||||
def Creator(**args):
|
||||
return Element(qname = (DCNS,'creator'), **args)
|
||||
|
||||
def Date(**args):
|
||||
return Element(qname = (DCNS,'date'), **args)
|
||||
|
||||
def Description(**args):
|
||||
return Element(qname = (DCNS,'description'), **args)
|
||||
|
||||
def Language(**args):
|
||||
return Element(qname = (DCNS,'language'), **args)
|
||||
|
||||
def Subject(**args):
|
||||
return Element(qname = (DCNS,'subject'), **args)
|
||||
|
||||
def Title(**args):
|
||||
return Element(qname = (DCNS,'title'), **args)
|
||||
|
||||
# The following complete the Dublin Core elements, but there is no
|
||||
# guarantee a compliant implementation of OpenDocument will preserve
|
||||
# these elements
|
||||
|
||||
#def Contributor(**args):
|
||||
# return Element(qname = (DCNS,'contributor'), **args)
|
||||
|
||||
#def Coverage(**args):
|
||||
# return Element(qname = (DCNS,'coverage'), **args)
|
||||
|
||||
#def Format(**args):
|
||||
# return Element(qname = (DCNS,'format'), **args)
|
||||
|
||||
#def Identifier(**args):
|
||||
# return Element(qname = (DCNS,'identifier'), **args)
|
||||
|
||||
#def Publisher(**args):
|
||||
# return Element(qname = (DCNS,'publisher'), **args)
|
||||
|
||||
#def Relation(**args):
|
||||
# return Element(qname = (DCNS,'relation'), **args)
|
||||
|
||||
#def Rights(**args):
|
||||
# return Element(qname = (DCNS,'rights'), **args)
|
||||
|
||||
#def Source(**args):
|
||||
# return Element(qname = (DCNS,'source'), **args)
|
||||
|
||||
#def Type(**args):
|
||||
# return Element(qname = (DCNS,'type'), **args)
|
||||
@@ -0,0 +1,43 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import DR3DNS
|
||||
from element import Element
|
||||
from draw import StyleRefElement
|
||||
|
||||
# Autogenerated
|
||||
def Cube(**args):
|
||||
return StyleRefElement(qname = (DR3DNS,'cube'), **args)
|
||||
|
||||
def Extrude(**args):
|
||||
return StyleRefElement(qname = (DR3DNS,'extrude'), **args)
|
||||
|
||||
def Light(Element):
|
||||
return StyleRefElement(qname = (DR3DNS,'light'), **args)
|
||||
|
||||
def Rotate(**args):
|
||||
return StyleRefElement(qname = (DR3DNS,'rotate'), **args)
|
||||
|
||||
def Scene(**args):
|
||||
return StyleRefElement(qname = (DR3DNS,'scene'), **args)
|
||||
|
||||
def Sphere(**args):
|
||||
return StyleRefElement(qname = (DR3DNS,'sphere'), **args)
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import DRAWNS, STYLENS, PRESENTATIONNS
|
||||
from element import Element
|
||||
|
||||
def StyleRefElement(stylename=None, classnames=None, **args):
|
||||
qattrs = {}
|
||||
if stylename is not None:
|
||||
f = stylename.getAttrNS(STYLENS, 'family')
|
||||
if f == 'graphic':
|
||||
qattrs[(DRAWNS,u'style-name')]= stylename
|
||||
elif f == 'presentation':
|
||||
qattrs[(PRESENTATIONNS,u'style-name')]= stylename
|
||||
else:
|
||||
raise ValueError, "Style's family must be either 'graphic' or 'presentation'"
|
||||
if classnames is not None:
|
||||
f = classnames[0].getAttrNS(STYLENS, 'family')
|
||||
if f == 'graphic':
|
||||
qattrs[(DRAWNS,u'class-names')]= classnames
|
||||
elif f == 'presentation':
|
||||
qattrs[(PRESENTATIONNS,u'class-names')]= classnames
|
||||
else:
|
||||
raise ValueError, "Style's family must be either 'graphic' or 'presentation'"
|
||||
return Element(qattributes=qattrs, **args)
|
||||
|
||||
def DrawElement(name=None, **args):
|
||||
e = Element(name=name, **args)
|
||||
if not args.has_key('displayname'):
|
||||
e.setAttrNS(DRAWNS,'display-name', name)
|
||||
return e
|
||||
|
||||
# Autogenerated
|
||||
def A(**args):
|
||||
return Element(qname = (DRAWNS,'a'), **args)
|
||||
|
||||
def Applet(**args):
|
||||
return Element(qname = (DRAWNS,'applet'), **args)
|
||||
|
||||
def AreaCircle(**args):
|
||||
return Element(qname = (DRAWNS,'area-circle'), **args)
|
||||
|
||||
def AreaPolygon(**args):
|
||||
return Element(qname = (DRAWNS,'area-polygon'), **args)
|
||||
|
||||
def AreaRectangle(**args):
|
||||
return Element(qname = (DRAWNS,'area-rectangle'), **args)
|
||||
|
||||
def Caption(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'caption'), **args)
|
||||
|
||||
def Circle(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'circle'), **args)
|
||||
|
||||
def Connector(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'connector'), **args)
|
||||
|
||||
def ContourPath(**args):
|
||||
return Element(qname = (DRAWNS,'contour-path'), **args)
|
||||
|
||||
def ContourPolygon(**args):
|
||||
return Element(qname = (DRAWNS,'contour-polygon'), **args)
|
||||
|
||||
def Control(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'control'), **args)
|
||||
|
||||
def CustomShape(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'custom-shape'), **args)
|
||||
|
||||
def Ellipse(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'ellipse'), **args)
|
||||
|
||||
def EnhancedGeometry(**args):
|
||||
return Element(qname = (DRAWNS,'enhanced-geometry'), **args)
|
||||
|
||||
def Equation(**args):
|
||||
return Element(qname = (DRAWNS,'equation'), **args)
|
||||
|
||||
def FillImage(**args):
|
||||
return DrawElement(qname = (DRAWNS,'fill-image'), **args)
|
||||
|
||||
def FloatingFrame(**args):
|
||||
return Element(qname = (DRAWNS,'floating-frame'), **args)
|
||||
|
||||
def Frame(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'frame'), **args)
|
||||
|
||||
def G(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'g'), **args)
|
||||
|
||||
def GluePoint(**args):
|
||||
return Element(qname = (DRAWNS,'glue-point'), **args)
|
||||
|
||||
def Gradient(**args):
|
||||
return DrawElement(qname = (DRAWNS,'gradient'), **args)
|
||||
|
||||
def Handle(**args):
|
||||
return Element(qname = (DRAWNS,'handle'), **args)
|
||||
|
||||
def Hatch(**args):
|
||||
return DrawElement(qname = (DRAWNS,'hatch'), **args)
|
||||
|
||||
def Image(**args):
|
||||
return Element(qname = (DRAWNS,'image'), **args)
|
||||
|
||||
def ImageMap(**args):
|
||||
return Element(qname = (DRAWNS,'image-map'), **args)
|
||||
|
||||
def Layer(**args):
|
||||
return Element(qname = (DRAWNS,'layer'), **args)
|
||||
|
||||
def LayerSet(**args):
|
||||
return Element(qname = (DRAWNS,'layer-set'), **args)
|
||||
|
||||
def Line(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'line'), **args)
|
||||
|
||||
def Marker(**args):
|
||||
return DrawElement(qname = (DRAWNS,'marker'), **args)
|
||||
|
||||
def Measure(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'measure'), **args)
|
||||
|
||||
def Object(**args):
|
||||
return Element(qname = (DRAWNS,'object'), **args)
|
||||
|
||||
def ObjectOle(**args):
|
||||
return Element(qname = (DRAWNS,'object-ole'), **args)
|
||||
|
||||
def Opacity(**args):
|
||||
return DrawElement(qname = (DRAWNS,'opacity'), **args)
|
||||
|
||||
def Page(**args):
|
||||
return Element(qname = (DRAWNS,'page'), **args)
|
||||
|
||||
def PageThumbnail(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'page-thumbnail'), **args)
|
||||
|
||||
def Param(**args):
|
||||
return Element(qname = (DRAWNS,'param'), **args)
|
||||
|
||||
def Path(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'path'), **args)
|
||||
|
||||
def Plugin(**args):
|
||||
return Element(qname = (DRAWNS,'plugin'), **args)
|
||||
|
||||
def Polygon(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'polygon'), **args)
|
||||
|
||||
def Polyline(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'polyline'), **args)
|
||||
|
||||
def Rect(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'rect'), **args)
|
||||
|
||||
def RegularPolygon(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'regular-polygon'), **args)
|
||||
|
||||
def StrokeDash(**args):
|
||||
return DrawElement(qname = (DRAWNS,'stroke-dash'), **args)
|
||||
|
||||
def TextBox(**args):
|
||||
return Element(qname = (DRAWNS,'text-box'), **args)
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Create a <text:list-style> element from a text string.
|
||||
# Copyright (C) 2008 J. David Eisenberg
|
||||
#
|
||||
# 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 2 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, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
import re
|
||||
from style import Style, TextProperties, ListLevelProperties
|
||||
from text import ListStyle,ListLevelStyleNumber,ListLevelStyleBullet
|
||||
|
||||
"""
|
||||
Create a <text:list-style> element from a string or array.
|
||||
|
||||
List styles require a lot of code to create one level at a time.
|
||||
These routines take a string and delimiter, or a list of
|
||||
strings, and creates a <text:list-style> element for you.
|
||||
Each item in the string (or array) represents a list level
|
||||
* style for levels 1-10.</p>
|
||||
*
|
||||
* <p>If an item contains <code>1</code>, <code>I</code>,
|
||||
* <code>i</code>, <code>A</code>, or <code>a</code>, then it is presumed
|
||||
* to be a numbering style; otherwise it is a bulleted style.</p>
|
||||
"""
|
||||
|
||||
_MAX_LIST_LEVEL = 10
|
||||
SHOW_ALL_LEVELS = True
|
||||
SHOW_ONE_LEVEL = False
|
||||
|
||||
def styleFromString(name, specifiers, delim, spacing, showAllLevels):
|
||||
specArray = specifiers.split(delim)
|
||||
return styleFromList( name, specArray, spacing, showAllLevels )
|
||||
|
||||
def styleFromList( styleName, specArray, spacing, showAllLevels):
|
||||
bullet = ""
|
||||
numPrefix = ""
|
||||
numSuffix = ""
|
||||
numberFormat = ""
|
||||
cssLengthNum = 0
|
||||
cssLengthUnits = ""
|
||||
numbered = False
|
||||
displayLevels = 0
|
||||
listStyle = ListStyle(name=styleName)
|
||||
numFormatPattern = re.compile("([1IiAa])")
|
||||
cssLengthPattern = re.compile("([^a-z]+)\\s*([a-z]+)?")
|
||||
m = cssLengthPattern.search( spacing )
|
||||
if (m != None):
|
||||
cssLengthNum = float(m.group(1))
|
||||
if (m.lastindex == 2):
|
||||
cssLengthUnits = m.group(2)
|
||||
i = 0
|
||||
while i < len(specArray):
|
||||
specification = specArray[i]
|
||||
m = numFormatPattern.search(specification)
|
||||
if (m != None):
|
||||
numberFormat = m.group(1)
|
||||
numPrefix = specification[0:m.start(1)]
|
||||
numSuffix = specification[m.end(1):]
|
||||
bullet = ""
|
||||
numbered = True
|
||||
if (showAllLevels):
|
||||
displayLevels = i + 1
|
||||
else:
|
||||
displayLevels = 1
|
||||
else: # it's a bullet style
|
||||
bullet = specification
|
||||
numPrefix = ""
|
||||
numSuffix = ""
|
||||
numberFormat = ""
|
||||
displayLevels = 1
|
||||
numbered = False
|
||||
if (numbered):
|
||||
lls = ListLevelStyleNumber(level=(i+1))
|
||||
if (numPrefix != ''):
|
||||
lls.setAttribute('numprefix', numPrefix)
|
||||
if (numSuffix != ''):
|
||||
lls.setAttribute('numsuffix', numSuffix)
|
||||
lls.setAttribute('displaylevels', displayLevels)
|
||||
else:
|
||||
lls = ListLevelStyleBullet(level=(i+1),bulletchar=bullet[0])
|
||||
llp = ListLevelProperties()
|
||||
llp.setAttribute('spacebefore', str(cssLengthNum * (i+1)) + cssLengthUnits)
|
||||
llp.setAttribute('minlabelwidth', str(cssLengthNum) + cssLengthUnits)
|
||||
lls.addElement( llp )
|
||||
listStyle.addElement(lls)
|
||||
i += 1
|
||||
return listStyle
|
||||
|
||||
# vim: set expandtab sw=4 :
|
||||
@@ -0,0 +1,513 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2007-2010 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
# Note: This script has copied a lot of text from xml.dom.minidom.
|
||||
# Whatever license applies to that file also applies to this file.
|
||||
#
|
||||
import xml.dom
|
||||
from xml.dom.minicompat import *
|
||||
from namespaces import nsdict
|
||||
import grammar
|
||||
from attrconverters import AttrConverters
|
||||
|
||||
# The following code is pasted form xml.sax.saxutils
|
||||
# Tt makes it possible to run the code without the xml sax package installed
|
||||
# To make it possible to have <rubbish> in your text elements, it is necessary to escape the texts
|
||||
def _escape(data, entities={}):
|
||||
""" Escape &, <, and > in a string of data.
|
||||
|
||||
You can escape other strings of data by passing a dictionary as
|
||||
the optional entities parameter. The keys and values must all be
|
||||
strings; each key will be replaced with its corresponding value.
|
||||
"""
|
||||
data = data.replace("&", "&")
|
||||
data = data.replace("<", "<")
|
||||
data = data.replace(">", ">")
|
||||
for chars, entity in entities.items():
|
||||
data = data.replace(chars, entity)
|
||||
return data
|
||||
|
||||
def _quoteattr(data, entities={}):
|
||||
""" Escape and quote an attribute value.
|
||||
|
||||
Escape &, <, and > in a string of data, then quote it for use as
|
||||
an attribute value. The \" character will be escaped as well, if
|
||||
necessary.
|
||||
|
||||
You can escape other strings of data by passing a dictionary as
|
||||
the optional entities parameter. The keys and values must all be
|
||||
strings; each key will be replaced with its corresponding value.
|
||||
"""
|
||||
entities['\n']=' '
|
||||
entities['\r']=''
|
||||
data = _escape(data, entities)
|
||||
if '"' in data:
|
||||
if "'" in data:
|
||||
data = '"%s"' % data.replace('"', """)
|
||||
else:
|
||||
data = "'%s'" % data
|
||||
else:
|
||||
data = '"%s"' % data
|
||||
return data
|
||||
|
||||
def _nssplit(qualifiedName):
|
||||
""" Split a qualified name into namespace part and local part. """
|
||||
fields = qualifiedName.split(':', 1)
|
||||
if len(fields) == 2:
|
||||
return fields
|
||||
else:
|
||||
return (None, fields[0])
|
||||
|
||||
def _nsassign(namespace):
|
||||
return nsdict.setdefault(namespace,"ns" + str(len(nsdict)))
|
||||
|
||||
# Exceptions
|
||||
class IllegalChild(StandardError):
|
||||
""" Complains if you add an element to a parent where it is not allowed """
|
||||
class IllegalText(StandardError):
|
||||
""" Complains if you add text or cdata to an element where it is not allowed """
|
||||
|
||||
class Node(xml.dom.Node):
|
||||
""" super class for more specific nodes """
|
||||
parentNode = None
|
||||
nextSibling = None
|
||||
previousSibling = None
|
||||
|
||||
def hasChildNodes(self):
|
||||
""" Tells whether this element has any children; text nodes,
|
||||
subelements, whatever.
|
||||
"""
|
||||
if self.childNodes:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def _get_childNodes(self):
|
||||
return self.childNodes
|
||||
|
||||
def _get_firstChild(self):
|
||||
if self.childNodes:
|
||||
return self.childNodes[0]
|
||||
|
||||
def _get_lastChild(self):
|
||||
if self.childNodes:
|
||||
return self.childNodes[-1]
|
||||
|
||||
def insertBefore(self, newChild, refChild):
|
||||
""" Inserts the node newChild before the existing child node refChild.
|
||||
If refChild is null, insert newChild at the end of the list of children.
|
||||
"""
|
||||
if newChild.nodeType not in self._child_node_types:
|
||||
raise IllegalChild, "%s cannot be child of %s" % (newChild.tagName, self.tagName)
|
||||
if newChild.parentNode is not None:
|
||||
newChild.parentNode.removeChild(newChild)
|
||||
if refChild is None:
|
||||
self.appendChild(newChild)
|
||||
else:
|
||||
try:
|
||||
index = self.childNodes.index(refChild)
|
||||
except ValueError:
|
||||
raise xml.dom.NotFoundErr()
|
||||
self.childNodes.insert(index, newChild)
|
||||
newChild.nextSibling = refChild
|
||||
refChild.previousSibling = newChild
|
||||
if index:
|
||||
node = self.childNodes[index-1]
|
||||
node.nextSibling = newChild
|
||||
newChild.previousSibling = node
|
||||
else:
|
||||
newChild.previousSibling = None
|
||||
newChild.parentNode = self
|
||||
return newChild
|
||||
|
||||
def appendChild(self, newChild):
|
||||
""" Adds the node newChild to the end of the list of children of this node.
|
||||
If the newChild is already in the tree, it is first removed.
|
||||
"""
|
||||
if newChild.nodeType == self.DOCUMENT_FRAGMENT_NODE:
|
||||
for c in tuple(newChild.childNodes):
|
||||
self.appendChild(c)
|
||||
### The DOM does not clearly specify what to return in this case
|
||||
return newChild
|
||||
if newChild.nodeType not in self._child_node_types:
|
||||
raise IllegalChild, "<%s> is not allowed in %s" % ( newChild.tagName, self.tagName)
|
||||
if newChild.parentNode is not None:
|
||||
newChild.parentNode.removeChild(newChild)
|
||||
_append_child(self, newChild)
|
||||
newChild.nextSibling = None
|
||||
return newChild
|
||||
|
||||
def removeChild(self, oldChild):
|
||||
""" Removes the child node indicated by oldChild from the list of children, and returns it.
|
||||
"""
|
||||
#FIXME: update ownerDocument.element_dict or find other solution
|
||||
try:
|
||||
self.childNodes.remove(oldChild)
|
||||
except ValueError:
|
||||
raise xml.dom.NotFoundErr()
|
||||
if oldChild.nextSibling is not None:
|
||||
oldChild.nextSibling.previousSibling = oldChild.previousSibling
|
||||
if oldChild.previousSibling is not None:
|
||||
oldChild.previousSibling.nextSibling = oldChild.nextSibling
|
||||
oldChild.nextSibling = oldChild.previousSibling = None
|
||||
if self.ownerDocument:
|
||||
self.ownerDocument.clear_caches()
|
||||
oldChild.parentNode = None
|
||||
return oldChild
|
||||
|
||||
def __str__(self):
|
||||
val = []
|
||||
for c in self.childNodes:
|
||||
val.append(str(c))
|
||||
return ''.join(val)
|
||||
|
||||
def __unicode__(self):
|
||||
val = []
|
||||
for c in self.childNodes:
|
||||
val.append(unicode(c))
|
||||
return u''.join(val)
|
||||
|
||||
defproperty(Node, "firstChild", doc="First child node, or None.")
|
||||
defproperty(Node, "lastChild", doc="Last child node, or None.")
|
||||
|
||||
def _append_child(self, node):
|
||||
# fast path with less checks; usable by DOM builders if careful
|
||||
childNodes = self.childNodes
|
||||
if childNodes:
|
||||
last = childNodes[-1]
|
||||
node.__dict__["previousSibling"] = last
|
||||
last.__dict__["nextSibling"] = node
|
||||
childNodes.append(node)
|
||||
node.__dict__["parentNode"] = self
|
||||
|
||||
class Childless:
|
||||
""" Mixin that makes childless-ness easy to implement and avoids
|
||||
the complexity of the Node methods that deal with children.
|
||||
"""
|
||||
|
||||
attributes = None
|
||||
childNodes = EmptyNodeList()
|
||||
firstChild = None
|
||||
lastChild = None
|
||||
|
||||
def _get_firstChild(self):
|
||||
return None
|
||||
|
||||
def _get_lastChild(self):
|
||||
return None
|
||||
|
||||
def appendChild(self, node):
|
||||
""" Raises an error """
|
||||
raise xml.dom.HierarchyRequestErr(
|
||||
self.tagName + " nodes cannot have children")
|
||||
|
||||
def hasChildNodes(self):
|
||||
return False
|
||||
|
||||
def insertBefore(self, newChild, refChild):
|
||||
""" Raises an error """
|
||||
raise xml.dom.HierarchyRequestErr(
|
||||
self.tagName + " nodes do not have children")
|
||||
|
||||
def removeChild(self, oldChild):
|
||||
""" Raises an error """
|
||||
raise xml.dom.NotFoundErr(
|
||||
self.tagName + " nodes do not have children")
|
||||
|
||||
def replaceChild(self, newChild, oldChild):
|
||||
""" Raises an error """
|
||||
raise xml.dom.HierarchyRequestErr(
|
||||
self.tagName + " nodes do not have children")
|
||||
|
||||
class Text(Childless, Node):
|
||||
nodeType = Node.TEXT_NODE
|
||||
tagName = "Text"
|
||||
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
def __str__(self):
|
||||
return self.data.encode()
|
||||
|
||||
def __unicode__(self):
|
||||
return self.data
|
||||
|
||||
def toXml(self,level,f):
|
||||
""" Write XML in UTF-8 """
|
||||
if self.data:
|
||||
f.write(_escape(unicode(self.data).encode('utf-8')))
|
||||
|
||||
class CDATASection(Childless, Text):
|
||||
nodeType = Node.CDATA_SECTION_NODE
|
||||
|
||||
def toXml(self,level,f):
|
||||
""" Generate XML output of the node. If the text contains "]]>", then
|
||||
escape it by going out of CDATA mode (]]>), then write the string
|
||||
and then go into CDATA mode again. (<![CDATA[)
|
||||
"""
|
||||
if self.data:
|
||||
f.write('<![CDATA[%s]]>' % self.data.replace(']]>',']]>]]><![CDATA['))
|
||||
|
||||
class Element(Node):
|
||||
""" Creates a arbitrary element and is intended to be subclassed not used on its own.
|
||||
This element is the base of every element it defines a class which resembles
|
||||
a xml-element. The main advantage of this kind of implementation is that you don't
|
||||
have to create a toXML method for every different object. Every element
|
||||
consists of an attribute, optional subelements, optional text and optional cdata.
|
||||
"""
|
||||
|
||||
nodeType = Node.ELEMENT_NODE
|
||||
namespaces = {} # Due to shallow copy this is a static variable
|
||||
|
||||
_child_node_types = (Node.ELEMENT_NODE,
|
||||
Node.PROCESSING_INSTRUCTION_NODE,
|
||||
Node.COMMENT_NODE,
|
||||
Node.TEXT_NODE,
|
||||
Node.CDATA_SECTION_NODE,
|
||||
Node.ENTITY_REFERENCE_NODE)
|
||||
|
||||
def __init__(self, attributes=None, text=None, cdata=None, qname=None, qattributes=None, check_grammar=True, **args):
|
||||
if qname is not None:
|
||||
self.qname = qname
|
||||
assert(hasattr(self, 'qname'))
|
||||
self.ownerDocument = None
|
||||
self.childNodes=[]
|
||||
self.allowed_children = grammar.allowed_children.get(self.qname)
|
||||
prefix = self.get_nsprefix(self.qname[0])
|
||||
self.tagName = prefix + ":" + self.qname[1]
|
||||
if text is not None:
|
||||
self.addText(text)
|
||||
if cdata is not None:
|
||||
self.addCDATA(cdata)
|
||||
|
||||
allowed_attrs = self.allowed_attributes()
|
||||
if allowed_attrs is not None:
|
||||
allowed_args = [ a[1].lower().replace('-','') for a in allowed_attrs]
|
||||
self.attributes={}
|
||||
# Load the attributes from the 'attributes' argument
|
||||
if attributes:
|
||||
for attr, value in attributes.items():
|
||||
self.setAttribute(attr, value)
|
||||
# Load the qualified attributes
|
||||
if qattributes:
|
||||
for attr, value in qattributes.items():
|
||||
self.setAttrNS(attr[0], attr[1], value)
|
||||
if allowed_attrs is not None:
|
||||
# Load the attributes from the 'args' argument
|
||||
for arg in args.keys():
|
||||
self.setAttribute(arg, args[arg])
|
||||
else:
|
||||
for arg in args.keys(): # If any attribute is allowed
|
||||
self.attributes[arg]=args[arg]
|
||||
if not check_grammar:
|
||||
return
|
||||
# Test that all mandatory attributes have been added.
|
||||
required = grammar.required_attributes.get(self.qname)
|
||||
if required:
|
||||
for r in required:
|
||||
if self.getAttrNS(r[0],r[1]) is None:
|
||||
raise AttributeError, "Required attribute missing: %s in <%s>" % (r[1].lower().replace('-',''), self.tagName)
|
||||
|
||||
def get_knownns(self, prefix):
|
||||
""" Odfpy maintains a list of known namespaces. In some cases a prefix is used, and
|
||||
we need to know which namespace it resolves to.
|
||||
"""
|
||||
global nsdict
|
||||
for ns,p in nsdict.items():
|
||||
if p == prefix: return ns
|
||||
return None
|
||||
|
||||
def get_nsprefix(self, namespace):
|
||||
""" Odfpy maintains a list of known namespaces. In some cases we have a namespace URL,
|
||||
and needs to look up or assign the prefix for it.
|
||||
"""
|
||||
if namespace is None: namespace = ""
|
||||
prefix = _nsassign(namespace)
|
||||
if not self.namespaces.has_key(namespace):
|
||||
self.namespaces[namespace] = prefix
|
||||
return prefix
|
||||
|
||||
def allowed_attributes(self):
|
||||
return grammar.allowed_attributes.get(self.qname)
|
||||
|
||||
def _setOwnerDoc(self, element):
|
||||
element.ownerDocument = self.ownerDocument
|
||||
for child in element.childNodes:
|
||||
self._setOwnerDoc(child)
|
||||
|
||||
def addElement(self, element, check_grammar=True):
|
||||
""" adds an element to an Element
|
||||
|
||||
Element.addElement(Element)
|
||||
"""
|
||||
if check_grammar and self.allowed_children is not None:
|
||||
if element.qname not in self.allowed_children:
|
||||
raise IllegalChild, "<%s> is not allowed in <%s>" % ( element.tagName, self.tagName)
|
||||
self.appendChild(element)
|
||||
self._setOwnerDoc(element)
|
||||
if self.ownerDocument:
|
||||
self.ownerDocument.rebuild_caches(element)
|
||||
|
||||
def addText(self, text, check_grammar=True):
|
||||
""" Adds text to an element
|
||||
Setting check_grammar=False turns off grammar checking
|
||||
"""
|
||||
if check_grammar and self.qname not in grammar.allows_text:
|
||||
raise IllegalText, "The <%s> element does not allow text" % self.tagName
|
||||
else:
|
||||
if text != '':
|
||||
self.appendChild(Text(text))
|
||||
|
||||
def addCDATA(self, cdata, check_grammar=True):
|
||||
""" Adds CDATA to an element
|
||||
Setting check_grammar=False turns off grammar checking
|
||||
"""
|
||||
if check_grammar and self.qname not in grammar.allows_text:
|
||||
raise IllegalText, "The <%s> element does not allow text" % self.tagName
|
||||
else:
|
||||
self.appendChild(CDATASection(cdata))
|
||||
|
||||
def removeAttribute(self, attr, check_grammar=True):
|
||||
""" Removes an attribute by name. """
|
||||
allowed_attrs = self.allowed_attributes()
|
||||
if allowed_attrs is None:
|
||||
if type(attr) == type(()):
|
||||
prefix, localname = attr
|
||||
self.removeAttrNS(prefix, localname)
|
||||
else:
|
||||
raise AttributeError, "Unable to add simple attribute - use (namespace, localpart)"
|
||||
else:
|
||||
# Construct a list of allowed arguments
|
||||
allowed_args = [ a[1].lower().replace('-','') for a in allowed_attrs]
|
||||
if check_grammar and attr not in allowed_args:
|
||||
raise AttributeError, "Attribute %s is not allowed in <%s>" % ( attr, self.tagName)
|
||||
i = allowed_args.index(attr)
|
||||
self.removeAttrNS(allowed_attrs[i][0], allowed_attrs[i][1])
|
||||
|
||||
def setAttribute(self, attr, value, check_grammar=True):
|
||||
""" Add an attribute to the element
|
||||
This is sort of a convenience method. All attributes in ODF have
|
||||
namespaces. The library knows what attributes are legal and then allows
|
||||
the user to provide the attribute as a keyword argument and the
|
||||
library will add the correct namespace.
|
||||
Must overwrite, If attribute already exists.
|
||||
"""
|
||||
allowed_attrs = self.allowed_attributes()
|
||||
if allowed_attrs is None:
|
||||
if type(attr) == type(()):
|
||||
prefix, localname = attr
|
||||
self.setAttrNS(prefix, localname, value)
|
||||
else:
|
||||
raise AttributeError, "Unable to add simple attribute - use (namespace, localpart)"
|
||||
else:
|
||||
# Construct a list of allowed arguments
|
||||
allowed_args = [ a[1].lower().replace('-','') for a in allowed_attrs]
|
||||
if check_grammar and attr not in allowed_args:
|
||||
raise AttributeError, "Attribute %s is not allowed in <%s>" % ( attr, self.tagName)
|
||||
i = allowed_args.index(attr)
|
||||
self.setAttrNS(allowed_attrs[i][0], allowed_attrs[i][1], value)
|
||||
|
||||
def setAttrNS(self, namespace, localpart, value):
|
||||
""" Add an attribute to the element
|
||||
In case you need to add an attribute the library doesn't know about
|
||||
then you must provide the full qualified name
|
||||
It will not check that the attribute is legal according to the schema.
|
||||
Must overwrite, If attribute already exists.
|
||||
"""
|
||||
allowed_attrs = self.allowed_attributes()
|
||||
prefix = self.get_nsprefix(namespace)
|
||||
# if allowed_attrs and (namespace, localpart) not in allowed_attrs:
|
||||
# raise AttributeError, "Attribute %s:%s is not allowed in element <%s>" % ( prefix, localpart, self.tagName)
|
||||
c = AttrConverters()
|
||||
self.attributes[(namespace, localpart)] = c.convert((namespace, localpart), value, self)
|
||||
|
||||
def getAttrNS(self, namespace, localpart):
|
||||
prefix = self.get_nsprefix(namespace)
|
||||
return self.attributes.get((namespace, localpart))
|
||||
|
||||
def removeAttrNS(self, namespace, localpart):
|
||||
del self.attributes[(namespace, localpart)]
|
||||
|
||||
def getAttribute(self, attr):
|
||||
""" Get an attribute value. The method knows which namespace the attribute is in
|
||||
"""
|
||||
allowed_attrs = self.allowed_attributes()
|
||||
if allowed_attrs is None:
|
||||
if type(attr) == type(()):
|
||||
prefix, localname = attr
|
||||
return self.getAttrNS(prefix, localname)
|
||||
else:
|
||||
raise AttributeError, "Unable to get simple attribute - use (namespace, localpart)"
|
||||
else:
|
||||
# Construct a list of allowed arguments
|
||||
allowed_args = [ a[1].lower().replace('-','') for a in allowed_attrs]
|
||||
i = allowed_args.index(attr)
|
||||
return self.getAttrNS(allowed_attrs[i][0], allowed_attrs[i][1])
|
||||
|
||||
def write_open_tag(self, level, f):
|
||||
f.write('<'+self.tagName)
|
||||
if level == 0:
|
||||
for namespace, prefix in self.namespaces.items():
|
||||
f.write(' xmlns:' + prefix + '="'+ _escape(str(namespace))+'"')
|
||||
for qname in self.attributes.keys():
|
||||
prefix = self.get_nsprefix(qname[0])
|
||||
f.write(' '+_escape(str(prefix+':'+qname[1]))+'='+_quoteattr(unicode(self.attributes[qname]).encode('utf-8')))
|
||||
f.write('>')
|
||||
|
||||
def write_close_tag(self, level, f):
|
||||
f.write('</'+self.tagName+'>')
|
||||
|
||||
def toXml(self, level, f):
|
||||
""" Generate XML stream out of the tree structure """
|
||||
f.write('<'+self.tagName)
|
||||
if level == 0:
|
||||
for namespace, prefix in self.namespaces.items():
|
||||
f.write(' xmlns:' + prefix + '="'+ _escape(str(namespace))+'"')
|
||||
for qname in self.attributes.keys():
|
||||
prefix = self.get_nsprefix(qname[0])
|
||||
f.write(' '+_escape(str(prefix+':'+qname[1]))+'='+_quoteattr(unicode(self.attributes[qname]).encode('utf-8')))
|
||||
if self.childNodes:
|
||||
f.write('>')
|
||||
for element in self.childNodes:
|
||||
element.toXml(level+1,f)
|
||||
f.write('</'+self.tagName+'>')
|
||||
else:
|
||||
f.write('/>')
|
||||
|
||||
def _getElementsByObj(self, obj, accumulator):
|
||||
if self.qname == obj.qname:
|
||||
accumulator.append(self)
|
||||
for e in self.childNodes:
|
||||
if e.nodeType == Node.ELEMENT_NODE:
|
||||
accumulator = e._getElementsByObj(obj, accumulator)
|
||||
return accumulator
|
||||
|
||||
def getElementsByType(self, element):
|
||||
""" Gets elements based on the type, which is function from text.py, draw.py etc. """
|
||||
obj = element(check_grammar=False)
|
||||
return self._getElementsByObj(obj,[])
|
||||
|
||||
def isInstanceOf(self, element):
|
||||
""" This is a check to see if the object is an instance of a type """
|
||||
obj = element(check_grammar=False)
|
||||
return self.qname == obj.qname
|
||||
|
||||
|
||||
@@ -0,0 +1,325 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2008 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import *
|
||||
|
||||
# Inline element don't cause a box
|
||||
# They are analogous to the HTML elements SPAN, B, I etc.
|
||||
inline_elements = (
|
||||
(TEXTNS,u'a'),
|
||||
(TEXTNS,u'author-initials'),
|
||||
(TEXTNS,u'author-name'),
|
||||
(TEXTNS,u'bibliography-mark'),
|
||||
(TEXTNS,u'bookmark-ref'),
|
||||
(TEXTNS,u'chapter'),
|
||||
(TEXTNS,u'character-count'),
|
||||
(TEXTNS,u'conditional-text'),
|
||||
(TEXTNS,u'creation-date'),
|
||||
(TEXTNS,u'creation-time'),
|
||||
(TEXTNS,u'creator'),
|
||||
(TEXTNS,u'database-display'),
|
||||
(TEXTNS,u'database-name'),
|
||||
(TEXTNS,u'database-next'),
|
||||
(TEXTNS,u'database-row-number'),
|
||||
(TEXTNS,u'database-row-select'),
|
||||
(TEXTNS,u'date'),
|
||||
(TEXTNS,u'dde-connection'),
|
||||
(TEXTNS,u'description'),
|
||||
(TEXTNS,u'editing-cycles'),
|
||||
(TEXTNS,u'editing-duration'),
|
||||
(TEXTNS,u'execute-macro'),
|
||||
(TEXTNS,u'expression'),
|
||||
(TEXTNS,u'file-name'),
|
||||
(TEXTNS,u'hidden-paragraph'),
|
||||
(TEXTNS,u'hidden-text'),
|
||||
(TEXTNS,u'image-count'),
|
||||
(TEXTNS,u'initial-creator'),
|
||||
(TEXTNS,u'keywords'),
|
||||
(TEXTNS,u'measure'),
|
||||
(TEXTNS,u'modification-date'),
|
||||
(TEXTNS,u'modification-time'),
|
||||
(TEXTNS,u'note-ref'),
|
||||
(TEXTNS,u'object-count'),
|
||||
(TEXTNS,u'page-continuation'),
|
||||
(TEXTNS,u'page-count'),
|
||||
(TEXTNS,u'page-number'),
|
||||
(TEXTNS,u'page-variable-get'),
|
||||
(TEXTNS,u'page-variable-set'),
|
||||
(TEXTNS,u'paragraph-count'),
|
||||
(TEXTNS,u'placeholder'),
|
||||
(TEXTNS,u'print-date'),
|
||||
(TEXTNS,u'printed-by'),
|
||||
(TEXTNS,u'print-time'),
|
||||
(TEXTNS,u'reference-ref'),
|
||||
(TEXTNS,u'ruby'),
|
||||
(TEXTNS,u'ruby-base'),
|
||||
(TEXTNS,u'ruby-text'),
|
||||
(TEXTNS,u'script'),
|
||||
(TEXTNS,u'sender-city'),
|
||||
(TEXTNS,u'sender-company'),
|
||||
(TEXTNS,u'sender-country'),
|
||||
(TEXTNS,u'sender-email'),
|
||||
(TEXTNS,u'sender-fax'),
|
||||
(TEXTNS,u'sender-firstname'),
|
||||
(TEXTNS,u'sender-initials'),
|
||||
(TEXTNS,u'sender-lastname'),
|
||||
(TEXTNS,u'sender-phone-private'),
|
||||
(TEXTNS,u'sender-phone-work'),
|
||||
(TEXTNS,u'sender-position'),
|
||||
(TEXTNS,u'sender-postal-code'),
|
||||
(TEXTNS,u'sender-state-or-province'),
|
||||
(TEXTNS,u'sender-street'),
|
||||
(TEXTNS,u'sender-title'),
|
||||
(TEXTNS,u'sequence'),
|
||||
(TEXTNS,u'sequence-ref'),
|
||||
(TEXTNS,u'sheet-name'),
|
||||
(TEXTNS,u'span'),
|
||||
(TEXTNS,u'subject'),
|
||||
(TEXTNS,u'table-count'),
|
||||
(TEXTNS,u'table-formula'),
|
||||
(TEXTNS,u'template-name'),
|
||||
(TEXTNS,u'text-input'),
|
||||
(TEXTNS,u'time'),
|
||||
(TEXTNS,u'title'),
|
||||
(TEXTNS,u'user-defined'),
|
||||
(TEXTNS,u'user-field-get'),
|
||||
(TEXTNS,u'user-field-input'),
|
||||
(TEXTNS,u'variable-get'),
|
||||
(TEXTNS,u'variable-input'),
|
||||
(TEXTNS,u'variable-set'),
|
||||
(TEXTNS,u'word-count'),
|
||||
)
|
||||
|
||||
|
||||
# It is almost impossible to determine what elements are block elements.
|
||||
# There are so many that don't fit the form
|
||||
block_elements = (
|
||||
(TEXTNS,u'h'),
|
||||
(TEXTNS,u'p'),
|
||||
(TEXTNS,u'list'),
|
||||
(TEXTNS,u'list-item'),
|
||||
(TEXTNS,u'section'),
|
||||
)
|
||||
|
||||
declarative_elements = (
|
||||
(OFFICENS,u'font-face-decls'),
|
||||
(PRESENTATIONNS,u'date-time-decl'),
|
||||
(PRESENTATIONNS,u'footer-decl'),
|
||||
(PRESENTATIONNS,u'header-decl'),
|
||||
(TABLENS,u'table-template'),
|
||||
(TEXTNS,u'alphabetical-index-entry-template'),
|
||||
(TEXTNS,u'alphabetical-index-source'),
|
||||
(TEXTNS,u'bibliography-entry-template'),
|
||||
(TEXTNS,u'bibliography-source'),
|
||||
(TEXTNS,u'dde-connection-decls'),
|
||||
(TEXTNS,u'illustration-index-entry-template'),
|
||||
(TEXTNS,u'illustration-index-source'),
|
||||
(TEXTNS,u'index-source-styles'),
|
||||
(TEXTNS,u'index-title-template'),
|
||||
(TEXTNS,u'note-continuation-notice-backward'),
|
||||
(TEXTNS,u'note-continuation-notice-forward'),
|
||||
(TEXTNS,u'notes-configuration'),
|
||||
(TEXTNS,u'object-index-entry-template'),
|
||||
(TEXTNS,u'object-index-source'),
|
||||
(TEXTNS,u'sequence-decls'),
|
||||
(TEXTNS,u'table-index-entry-template'),
|
||||
(TEXTNS,u'table-index-source'),
|
||||
(TEXTNS,u'table-of-content-entry-template'),
|
||||
(TEXTNS,u'table-of-content-source'),
|
||||
(TEXTNS,u'user-field-decls'),
|
||||
(TEXTNS,u'user-index-entry-template'),
|
||||
(TEXTNS,u'user-index-source'),
|
||||
(TEXTNS,u'variable-decls'),
|
||||
)
|
||||
|
||||
empty_elements = (
|
||||
(ANIMNS,u'animate'),
|
||||
(ANIMNS,u'animateColor'),
|
||||
(ANIMNS,u'animateMotion'),
|
||||
(ANIMNS,u'animateTransform'),
|
||||
(ANIMNS,u'audio'),
|
||||
(ANIMNS,u'param'),
|
||||
(ANIMNS,u'set'),
|
||||
(ANIMNS,u'transitionFilter'),
|
||||
(CHARTNS,u'categories'),
|
||||
(CHARTNS,u'data-point'),
|
||||
(CHARTNS,u'domain'),
|
||||
(CHARTNS,u'error-indicator'),
|
||||
(CHARTNS,u'floor'),
|
||||
(CHARTNS,u'grid'),
|
||||
(CHARTNS,u'legend'),
|
||||
(CHARTNS,u'mean-value'),
|
||||
(CHARTNS,u'regression-curve'),
|
||||
(CHARTNS,u'stock-gain-marker'),
|
||||
(CHARTNS,u'stock-loss-marker'),
|
||||
(CHARTNS,u'stock-range-line'),
|
||||
(CHARTNS,u'symbol-image'),
|
||||
(CHARTNS,u'wall'),
|
||||
(DR3DNS,u'cube'),
|
||||
(DR3DNS,u'extrude'),
|
||||
(DR3DNS,u'light'),
|
||||
(DR3DNS,u'rotate'),
|
||||
(DR3DNS,u'sphere'),
|
||||
(DRAWNS,u'contour-path'),
|
||||
(DRAWNS,u'contour-polygon'),
|
||||
(DRAWNS,u'equation'),
|
||||
(DRAWNS,u'fill-image'),
|
||||
(DRAWNS,u'floating-frame'),
|
||||
(DRAWNS,u'glue-point'),
|
||||
(DRAWNS,u'gradient'),
|
||||
(DRAWNS,u'handle'),
|
||||
(DRAWNS,u'hatch'),
|
||||
(DRAWNS,u'layer'),
|
||||
(DRAWNS,u'marker'),
|
||||
(DRAWNS,u'opacity'),
|
||||
(DRAWNS,u'page-thumbnail'),
|
||||
(DRAWNS,u'param'),
|
||||
(DRAWNS,u'stroke-dash'),
|
||||
(FORMNS,u'connection-resource'),
|
||||
(FORMNS,u'list-value'),
|
||||
(FORMNS,u'property'),
|
||||
(MANIFESTNS,u'algorithm'),
|
||||
(MANIFESTNS,u'key-derivation'),
|
||||
(METANS,u'auto-reload'),
|
||||
(METANS,u'document-statistic'),
|
||||
(METANS,u'hyperlink-behaviour'),
|
||||
(METANS,u'template'),
|
||||
(NUMBERNS,u'am-pm'),
|
||||
(NUMBERNS,u'boolean'),
|
||||
(NUMBERNS,u'day'),
|
||||
(NUMBERNS,u'day-of-week'),
|
||||
(NUMBERNS,u'era'),
|
||||
(NUMBERNS,u'fraction'),
|
||||
(NUMBERNS,u'hours'),
|
||||
(NUMBERNS,u'minutes'),
|
||||
(NUMBERNS,u'month'),
|
||||
(NUMBERNS,u'quarter'),
|
||||
(NUMBERNS,u'scientific-number'),
|
||||
(NUMBERNS,u'seconds'),
|
||||
(NUMBERNS,u'text-content'),
|
||||
(NUMBERNS,u'week-of-year'),
|
||||
(NUMBERNS,u'year'),
|
||||
(OFFICENS,u'dde-source'),
|
||||
(PRESENTATIONNS,u'date-time'),
|
||||
(PRESENTATIONNS,u'footer'),
|
||||
(PRESENTATIONNS,u'header'),
|
||||
(PRESENTATIONNS,u'placeholder'),
|
||||
(PRESENTATIONNS,u'play'),
|
||||
(PRESENTATIONNS,u'show'),
|
||||
(PRESENTATIONNS,u'sound'),
|
||||
(SCRIPTNS,u'event-listener'),
|
||||
(STYLENS,u'column'),
|
||||
(STYLENS,u'column-sep'),
|
||||
(STYLENS,u'drop-cap'),
|
||||
(STYLENS,u'footnote-sep'),
|
||||
(STYLENS,u'list-level-properties'),
|
||||
(STYLENS,u'map'),
|
||||
(STYLENS,u'ruby-properties'),
|
||||
(STYLENS,u'table-column-properties'),
|
||||
(STYLENS,u'tab-stop'),
|
||||
(STYLENS,u'text-properties'),
|
||||
(SVGNS,u'definition-src'),
|
||||
(SVGNS,u'font-face-format'),
|
||||
(SVGNS,u'font-face-name'),
|
||||
(SVGNS,u'stop'),
|
||||
(TABLENS,u'body'),
|
||||
(TABLENS,u'cell-address'),
|
||||
(TABLENS,u'cell-range-source'),
|
||||
(TABLENS,u'change-deletion'),
|
||||
(TABLENS,u'consolidation'),
|
||||
(TABLENS,u'database-source-query'),
|
||||
(TABLENS,u'database-source-sql'),
|
||||
(TABLENS,u'database-source-table'),
|
||||
(TABLENS,u'data-pilot-display-info'),
|
||||
(TABLENS,u'data-pilot-field-reference'),
|
||||
(TABLENS,u'data-pilot-group-member'),
|
||||
(TABLENS,u'data-pilot-layout-info'),
|
||||
(TABLENS,u'data-pilot-member'),
|
||||
(TABLENS,u'data-pilot-sort-info'),
|
||||
(TABLENS,u'data-pilot-subtotal'),
|
||||
(TABLENS,u'dependency'),
|
||||
(TABLENS,u'error-macro'),
|
||||
(TABLENS,u'even-columns'),
|
||||
(TABLENS,u'even-rows'),
|
||||
(TABLENS,u'filter-condition'),
|
||||
(TABLENS,u'first-column'),
|
||||
(TABLENS,u'first-row'),
|
||||
(TABLENS,u'highlighted-range'),
|
||||
(TABLENS,u'insertion-cut-off'),
|
||||
(TABLENS,u'iteration'),
|
||||
(TABLENS,u'label-range'),
|
||||
(TABLENS,u'last-column'),
|
||||
(TABLENS,u'last-row'),
|
||||
(TABLENS,u'movement-cut-off'),
|
||||
(TABLENS,u'named-expression'),
|
||||
(TABLENS,u'named-range'),
|
||||
(TABLENS,u'null-date'),
|
||||
(TABLENS,u'odd-columns'),
|
||||
(TABLENS,u'odd-rows'),
|
||||
(TABLENS,u'operation'),
|
||||
(TABLENS,u'scenario'),
|
||||
(TABLENS,u'sort-by'),
|
||||
(TABLENS,u'sort-groups'),
|
||||
(TABLENS,u'source-range-address'),
|
||||
(TABLENS,u'source-service'),
|
||||
(TABLENS,u'subtotal-field'),
|
||||
(TABLENS,u'table-column'),
|
||||
(TABLENS,u'table-source'),
|
||||
(TABLENS,u'target-range-address'),
|
||||
(TEXTNS,u'alphabetical-index-auto-mark-file'),
|
||||
(TEXTNS,u'alphabetical-index-mark'),
|
||||
(TEXTNS,u'alphabetical-index-mark-end'),
|
||||
(TEXTNS,u'alphabetical-index-mark-start'),
|
||||
(TEXTNS,u'bookmark'),
|
||||
(TEXTNS,u'bookmark-end'),
|
||||
(TEXTNS,u'bookmark-start'),
|
||||
(TEXTNS,u'change'),
|
||||
(TEXTNS,u'change-end'),
|
||||
(TEXTNS,u'change-start'),
|
||||
(TEXTNS,u'dde-connection-decl'),
|
||||
(TEXTNS,u'index-entry-bibliography'),
|
||||
(TEXTNS,u'index-entry-chapter'),
|
||||
(TEXTNS,u'index-entry-link-end'),
|
||||
(TEXTNS,u'index-entry-link-start'),
|
||||
(TEXTNS,u'index-entry-page-number'),
|
||||
(TEXTNS,u'index-entry-tab-stop'),
|
||||
(TEXTNS,u'index-entry-text'),
|
||||
(TEXTNS,u'index-source-style'),
|
||||
(TEXTNS,u'line-break'),
|
||||
(TEXTNS,u'page'),
|
||||
(TEXTNS,u'reference-mark'),
|
||||
(TEXTNS,u'reference-mark-end'),
|
||||
(TEXTNS,u'reference-mark-start'),
|
||||
(TEXTNS,u's'),
|
||||
(TEXTNS,u'section-source'),
|
||||
(TEXTNS,u'sequence-decl'),
|
||||
(TEXTNS,u'soft-page-break'),
|
||||
(TEXTNS,u'sort-key'),
|
||||
(TEXTNS,u'tab'),
|
||||
(TEXTNS,u'toc-mark'),
|
||||
(TEXTNS,u'toc-mark-end'),
|
||||
(TEXTNS,u'toc-mark-start'),
|
||||
(TEXTNS,u'user-field-decl'),
|
||||
(TEXTNS,u'user-index-mark'),
|
||||
(TEXTNS,u'user-index-mark-end'),
|
||||
(TEXTNS,u'user-index-mark-start'),
|
||||
(TEXTNS,u'variable-decl')
|
||||
)
|
||||
@@ -0,0 +1,115 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import FORMNS
|
||||
from element import Element
|
||||
|
||||
|
||||
# Autogenerated
|
||||
def Button(**args):
|
||||
return Element(qname = (FORMNS,'button'), **args)
|
||||
|
||||
def Checkbox(**args):
|
||||
return Element(qname = (FORMNS,'checkbox'), **args)
|
||||
|
||||
def Column(**args):
|
||||
return Element(qname = (FORMNS,'column'), **args)
|
||||
|
||||
def Combobox(**args):
|
||||
return Element(qname = (FORMNS,'combobox'), **args)
|
||||
|
||||
def ConnectionResource(**args):
|
||||
return Element(qname = (FORMNS,'connection-resource'), **args)
|
||||
|
||||
def Date(**args):
|
||||
return Element(qname = (FORMNS,'date'), **args)
|
||||
|
||||
def File(**args):
|
||||
return Element(qname = (FORMNS,'file'), **args)
|
||||
|
||||
def FixedText(**args):
|
||||
return Element(qname = (FORMNS,'fixed-text'), **args)
|
||||
|
||||
def Form(**args):
|
||||
return Element(qname = (FORMNS,'form'), **args)
|
||||
|
||||
def FormattedText(**args):
|
||||
return Element(qname = (FORMNS,'formatted-text'), **args)
|
||||
|
||||
def Frame(**args):
|
||||
return Element(qname = (FORMNS,'frame'), **args)
|
||||
|
||||
def GenericControl(**args):
|
||||
return Element(qname = (FORMNS,'generic-control'), **args)
|
||||
|
||||
def Grid(**args):
|
||||
return Element(qname = (FORMNS,'grid'), **args)
|
||||
|
||||
def Hidden(**args):
|
||||
return Element(qname = (FORMNS,'hidden'), **args)
|
||||
|
||||
def Image(**args):
|
||||
return Element(qname = (FORMNS,'image'), **args)
|
||||
|
||||
def ImageFrame(**args):
|
||||
return Element(qname = (FORMNS,'image-frame'), **args)
|
||||
|
||||
def Item(**args):
|
||||
return Element(qname = (FORMNS,'item'), **args)
|
||||
|
||||
def ListProperty(**args):
|
||||
return Element(qname = (FORMNS,'list-property'), **args)
|
||||
|
||||
def ListValue(**args):
|
||||
return Element(qname = (FORMNS,'list-value'), **args)
|
||||
|
||||
def Listbox(**args):
|
||||
return Element(qname = (FORMNS,'listbox'), **args)
|
||||
|
||||
def Number(**args):
|
||||
return Element(qname = (FORMNS,'number'), **args)
|
||||
|
||||
def Option(**args):
|
||||
return Element(qname = (FORMNS,'option'), **args)
|
||||
|
||||
def Password(**args):
|
||||
return Element(qname = (FORMNS,'password'), **args)
|
||||
|
||||
def Properties(**args):
|
||||
return Element(qname = (FORMNS,'properties'), **args)
|
||||
|
||||
def Property(**args):
|
||||
return Element(qname = (FORMNS,'property'), **args)
|
||||
|
||||
def Radio(**args):
|
||||
return Element(qname = (FORMNS,'radio'), **args)
|
||||
|
||||
def Text(**args):
|
||||
return Element(qname = (FORMNS,'text'), **args)
|
||||
|
||||
def Textarea(**args):
|
||||
return Element(qname = (FORMNS,'textarea'), **args)
|
||||
|
||||
def Time(**args):
|
||||
return Element(qname = (FORMNS,'time'), **args)
|
||||
|
||||
def ValueRange(**args):
|
||||
return Element(qname = (FORMNS,'value-range'), **args)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2007-2008 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
# This script is to be embedded in opendocument.py later
|
||||
# The purpose is to read an ODT/ODP/ODS file and create the datastructure
|
||||
# in memory. The user should then be able to make operations and then save
|
||||
# the structure again.
|
||||
|
||||
from xml.sax import make_parser,handler
|
||||
from xml.sax.xmlreader import InputSource
|
||||
import xml.sax.saxutils
|
||||
from element import Element
|
||||
from namespaces import OFFICENS
|
||||
from cStringIO import StringIO
|
||||
|
||||
#
|
||||
# Parse the XML files
|
||||
#
|
||||
class LoadParser(handler.ContentHandler):
|
||||
""" Extract headings from content.xml of an ODT file """
|
||||
triggers = (
|
||||
(OFFICENS, 'automatic-styles'), (OFFICENS, 'body'),
|
||||
(OFFICENS, 'font-face-decls'), (OFFICENS, 'master-styles'),
|
||||
(OFFICENS, 'meta'), (OFFICENS, 'scripts'),
|
||||
(OFFICENS, 'settings'), (OFFICENS, 'styles') )
|
||||
|
||||
def __init__(self, document):
|
||||
self.doc = document
|
||||
self.data = []
|
||||
self.level = 0
|
||||
self.parse = False
|
||||
|
||||
def characters(self, data):
|
||||
if self.parse == False:
|
||||
return
|
||||
self.data.append(data)
|
||||
|
||||
def startElementNS(self, tag, qname, attrs):
|
||||
if tag in self.triggers:
|
||||
self.parse = True
|
||||
if self.doc._parsing != "styles.xml" and tag == (OFFICENS, 'font-face-decls'):
|
||||
self.parse = False
|
||||
if self.parse == False:
|
||||
return
|
||||
|
||||
self.level = self.level + 1
|
||||
# Add any accumulated text content
|
||||
content = ''.join(self.data)
|
||||
if len(content.strip()) > 0:
|
||||
self.parent.addText(content, check_grammar=False)
|
||||
self.data = []
|
||||
# Create the element
|
||||
attrdict = {}
|
||||
for (att,value) in attrs.items():
|
||||
attrdict[att] = value
|
||||
try:
|
||||
e = Element(qname = tag, qattributes=attrdict, check_grammar=False)
|
||||
self.curr = e
|
||||
except AttributeError, v:
|
||||
print "Error: %s" % v
|
||||
|
||||
if tag == (OFFICENS, 'automatic-styles'):
|
||||
e = self.doc.automaticstyles
|
||||
elif tag == (OFFICENS, 'body'):
|
||||
e = self.doc.body
|
||||
elif tag == (OFFICENS, 'master-styles'):
|
||||
e = self.doc.masterstyles
|
||||
elif tag == (OFFICENS, 'meta'):
|
||||
e = self.doc.meta
|
||||
elif tag == (OFFICENS,'scripts'):
|
||||
e = self.doc.scripts
|
||||
elif tag == (OFFICENS,'settings'):
|
||||
e = self.doc.settings
|
||||
elif tag == (OFFICENS,'styles'):
|
||||
e = self.doc.styles
|
||||
elif self.doc._parsing == "styles.xml" and tag == (OFFICENS, 'font-face-decls'):
|
||||
e = self.doc.fontfacedecls
|
||||
elif hasattr(self,'parent'):
|
||||
self.parent.addElement(e, check_grammar=False)
|
||||
self.parent = e
|
||||
|
||||
|
||||
def endElementNS(self, tag, qname):
|
||||
if self.parse == False:
|
||||
return
|
||||
self.level = self.level - 1
|
||||
str = ''.join(self.data)
|
||||
if len(str.strip()) > 0:
|
||||
self.curr.addText(str, check_grammar=False)
|
||||
self.data = []
|
||||
self.curr = self.curr.parentNode
|
||||
self.parent = self.curr
|
||||
if tag in self.triggers:
|
||||
self.parse = False
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
#
|
||||
|
||||
from namespaces import MANIFESTNS
|
||||
from element import Element
|
||||
|
||||
# Autogenerated
|
||||
def Manifest(**args):
|
||||
return Element(qname = (MANIFESTNS,'manifest'), **args)
|
||||
|
||||
def FileEntry(**args):
|
||||
return Element(qname = (MANIFESTNS,'file-entry'), **args)
|
||||
|
||||
def EncryptionData(**args):
|
||||
return Element(qname = (MANIFESTNS,'encryption-data'), **args)
|
||||
|
||||
def Algorithm(**args):
|
||||
return Element(qname = (MANIFESTNS,'algorithm'), **args)
|
||||
|
||||
def KeyDerivation(**args):
|
||||
return Element(qname = (MANIFESTNS,'key-derivation'), **args)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import MATHNS
|
||||
from element import Element
|
||||
|
||||
# ODF 1.0 section 12.5
|
||||
# Mathematical content is represented by MathML 2.0
|
||||
|
||||
# Autogenerated
|
||||
def Math(**args):
|
||||
return Element(qname = (MATHNS,'math'), **args)
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import METANS
|
||||
from element import Element
|
||||
|
||||
# Autogenerated
|
||||
def AutoReload(**args):
|
||||
return Element(qname = (METANS,'auto-reload'), **args)
|
||||
|
||||
def CreationDate(**args):
|
||||
return Element(qname = (METANS,'creation-date'), **args)
|
||||
|
||||
def DateString(**args):
|
||||
return Element(qname = (METANS,'date-string'), **args)
|
||||
|
||||
def DocumentStatistic(**args):
|
||||
return Element(qname = (METANS,'document-statistic'), **args)
|
||||
|
||||
def EditingCycles(**args):
|
||||
return Element(qname = (METANS,'editing-cycles'), **args)
|
||||
|
||||
def EditingDuration(**args):
|
||||
return Element(qname = (METANS,'editing-duration'), **args)
|
||||
|
||||
def Generator(**args):
|
||||
return Element(qname = (METANS,'generator'), **args)
|
||||
|
||||
def HyperlinkBehaviour(**args):
|
||||
return Element(qname = (METANS,'hyperlink-behaviour'), **args)
|
||||
|
||||
def InitialCreator(**args):
|
||||
return Element(qname = (METANS,'initial-creator'), **args)
|
||||
|
||||
def Keyword(**args):
|
||||
return Element(qname = (METANS,'keyword'), **args)
|
||||
|
||||
def PrintDate(**args):
|
||||
return Element(qname = (METANS,'print-date'), **args)
|
||||
|
||||
def PrintedBy(**args):
|
||||
return Element(qname = (METANS,'printed-by'), **args)
|
||||
|
||||
def Template(**args):
|
||||
return Element(qname = (METANS,'template'), **args)
|
||||
|
||||
def UserDefined(**args):
|
||||
return Element(qname = (METANS,'user-defined'), **args)
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2010 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
TOOLSVERSION = u"ODFPY/0.9.3"
|
||||
|
||||
ANIMNS = u"urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
|
||||
DBNS = u"urn:oasis:names:tc:opendocument:xmlns:database:1.0"
|
||||
CHARTNS = u"urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
CONFIGNS = u"urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
#DBNS = u"http://openoffice.org/2004/database"
|
||||
DCNS = u"http://purl.org/dc/elements/1.1/"
|
||||
DOMNS = u"http://www.w3.org/2001/xml-events"
|
||||
DR3DNS = u"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
DRAWNS = u"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
FIELDNS = u"urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0"
|
||||
FONS = u"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
FORMNS = u"urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
GRDDLNS = u"http://www.w3.org/2003/g/data-view#"
|
||||
KOFFICENS = u"http://www.koffice.org/2005/"
|
||||
MANIFESTNS = u"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"
|
||||
MATHNS = u"http://www.w3.org/1998/Math/MathML"
|
||||
METANS = u"urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
NUMBERNS = u"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
OFFICENS = u"urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
OFNS = u"urn:oasis:names:tc:opendocument:xmlns:of:1.2"
|
||||
OOONS = u"http://openoffice.org/2004/office"
|
||||
OOOWNS = u"http://openoffice.org/2004/writer"
|
||||
OOOCNS = u"http://openoffice.org/2004/calc"
|
||||
PRESENTATIONNS = u"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
|
||||
RDFANS = u"http://docs.oasis-open.org/opendocument/meta/rdfa#"
|
||||
RPTNS = u"http://openoffice.org/2005/report"
|
||||
SCRIPTNS = u"urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
SMILNS = u"urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
|
||||
STYLENS = u"urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
SVGNS = u"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
TABLENS = u"urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
TEXTNS = u"urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
XFORMSNS = u"http://www.w3.org/2002/xforms"
|
||||
XLINKNS = u"http://www.w3.org/1999/xlink"
|
||||
XMLNS = u"http://www.w3.org/XML/1998/namespace"
|
||||
XSDNS = u"http://www.w3.org/2001/XMLSchema"
|
||||
XSINS = u"http://www.w3.org/2001/XMLSchema-instance"
|
||||
|
||||
nsdict = {
|
||||
ANIMNS: u'anim',
|
||||
CHARTNS: u'chart',
|
||||
CONFIGNS: u'config',
|
||||
DBNS: u'db',
|
||||
DCNS: u'dc',
|
||||
DOMNS: u'dom',
|
||||
DR3DNS: u'dr3d',
|
||||
DRAWNS: u'draw',
|
||||
FIELDNS: u'field',
|
||||
FONS: u'fo',
|
||||
FORMNS: u'form',
|
||||
GRDDLNS: u'grddl',
|
||||
KOFFICENS: u'koffice',
|
||||
MANIFESTNS: u'manifest',
|
||||
MATHNS: u'math',
|
||||
METANS: u'meta',
|
||||
NUMBERNS: u'number',
|
||||
OFFICENS: u'office',
|
||||
OFNS: u'of',
|
||||
OOONS: u'ooo',
|
||||
OOOWNS: u'ooow',
|
||||
OOOCNS: u'oooc',
|
||||
PRESENTATIONNS: u'presentation',
|
||||
RDFANS: u'rdfa',
|
||||
RPTNS: u'rpt',
|
||||
SCRIPTNS: u'script',
|
||||
SMILNS: u'smil',
|
||||
STYLENS: u'style',
|
||||
SVGNS: u'svg',
|
||||
TABLENS: u'table',
|
||||
TEXTNS: u'text',
|
||||
XFORMSNS: u'xforms',
|
||||
XLINKNS: u'xlink',
|
||||
XMLNS: u'xml',
|
||||
XSDNS: u'xsd',
|
||||
XSINS: u'xsi',
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import NUMBERNS
|
||||
from element import Element
|
||||
from style import StyleElement
|
||||
|
||||
|
||||
# Autogenerated
|
||||
def AmPm(**args):
|
||||
return Element(qname = (NUMBERNS,'am-pm'), **args)
|
||||
|
||||
def Boolean(**args):
|
||||
return Element(qname = (NUMBERNS,'boolean'), **args)
|
||||
|
||||
def BooleanStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'boolean-style'), **args)
|
||||
|
||||
def CurrencyStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'currency-style'), **args)
|
||||
|
||||
def CurrencySymbol(**args):
|
||||
return Element(qname = (NUMBERNS,'currency-symbol'), **args)
|
||||
|
||||
def DateStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'date-style'), **args)
|
||||
|
||||
def Day(**args):
|
||||
return Element(qname = (NUMBERNS,'day'), **args)
|
||||
|
||||
def DayOfWeek(**args):
|
||||
return Element(qname = (NUMBERNS,'day-of-week'), **args)
|
||||
|
||||
def EmbeddedText(**args):
|
||||
return Element(qname = (NUMBERNS,'embedded-text'), **args)
|
||||
|
||||
def Era(**args):
|
||||
return Element(qname = (NUMBERNS,'era'), **args)
|
||||
|
||||
def Fraction(**args):
|
||||
return Element(qname = (NUMBERNS,'fraction'), **args)
|
||||
|
||||
def Hours(**args):
|
||||
return Element(qname = (NUMBERNS,'hours'), **args)
|
||||
|
||||
def Minutes(**args):
|
||||
return Element(qname = (NUMBERNS,'minutes'), **args)
|
||||
|
||||
def Month(**args):
|
||||
return Element(qname = (NUMBERNS,'month'), **args)
|
||||
|
||||
def Number(**args):
|
||||
return Element(qname = (NUMBERNS,'number'), **args)
|
||||
|
||||
def NumberStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'number-style'), **args)
|
||||
|
||||
def PercentageStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'percentage-style'), **args)
|
||||
|
||||
def Quarter(**args):
|
||||
return Element(qname = (NUMBERNS,'quarter'), **args)
|
||||
|
||||
def ScientificNumber(**args):
|
||||
return Element(qname = (NUMBERNS,'scientific-number'), **args)
|
||||
|
||||
def Seconds(**args):
|
||||
return Element(qname = (NUMBERNS,'seconds'), **args)
|
||||
|
||||
def Text(**args):
|
||||
return Element(qname = (NUMBERNS,'text'), **args)
|
||||
|
||||
def TextContent(**args):
|
||||
return Element(qname = (NUMBERNS,'text-content'), **args)
|
||||
|
||||
def TextStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'text-style'), **args)
|
||||
|
||||
def TimeStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'time-style'), **args)
|
||||
|
||||
def WeekOfYear(**args):
|
||||
return Element(qname = (NUMBERNS,'week-of-year'), **args)
|
||||
|
||||
def Year(**args):
|
||||
return Element(qname = (NUMBERNS,'year'), **args)
|
||||
|
||||
@@ -0,0 +1,579 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2008 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# See http://trac.edgewall.org/wiki/WikiFormatting
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
import sys, zipfile, xml.dom.minidom
|
||||
from namespaces import nsdict
|
||||
from elementtypes import *
|
||||
|
||||
IGNORED_TAGS = [
|
||||
'draw:a'
|
||||
'draw:g',
|
||||
'draw:line',
|
||||
'draw:object-ole',
|
||||
'office:annotation',
|
||||
'presentation:notes',
|
||||
'svg:desc',
|
||||
] + [ nsdict[item[0]]+":"+item[1] for item in empty_elements]
|
||||
|
||||
INLINE_TAGS = [ nsdict[item[0]]+":"+item[1] for item in inline_elements]
|
||||
|
||||
|
||||
class TextProps:
|
||||
""" Holds properties for a text style. """
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.italic = False
|
||||
self.bold = False
|
||||
self.fixed = False
|
||||
self.underlined = False
|
||||
self.strikethrough = False
|
||||
self.superscript = False
|
||||
self.subscript = False
|
||||
|
||||
def setItalic(self, value):
|
||||
if value == "italic":
|
||||
self.italic = True
|
||||
elif value == "normal":
|
||||
self.italic = False
|
||||
|
||||
def setBold(self, value):
|
||||
if value == "bold":
|
||||
self.bold = True
|
||||
elif value == "normal":
|
||||
self.bold = False
|
||||
|
||||
def setFixed(self, value):
|
||||
self.fixed = value
|
||||
|
||||
def setUnderlined(self, value):
|
||||
if value and value != "none":
|
||||
self.underlined = True
|
||||
|
||||
def setStrikethrough(self, value):
|
||||
if value and value != "none":
|
||||
self.strikethrough = True
|
||||
|
||||
def setPosition(self, value):
|
||||
if value is None or value == '':
|
||||
return
|
||||
posisize = value.split(' ')
|
||||
textpos = posisize[0]
|
||||
if textpos.find('%') == -1:
|
||||
if textpos == "sub":
|
||||
self.superscript = False
|
||||
self.subscript = True
|
||||
elif textpos == "super":
|
||||
self.superscript = True
|
||||
self.subscript = False
|
||||
else:
|
||||
itextpos = int(textpos[:textpos.find('%')])
|
||||
if itextpos > 10:
|
||||
self.superscript = False
|
||||
self.subscript = True
|
||||
elif itextpos < -10:
|
||||
self.superscript = True
|
||||
self.subscript = False
|
||||
|
||||
def __str__(self):
|
||||
|
||||
return "[italic=%s, bold=i%s, fixed=%s]" % (str(self.italic),
|
||||
str(self.bold),
|
||||
str(self.fixed))
|
||||
|
||||
class ParagraphProps:
|
||||
""" Holds properties of a paragraph style. """
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.blockquote = False
|
||||
self.headingLevel = 0
|
||||
self.code = False
|
||||
self.title = False
|
||||
self.indented = 0
|
||||
|
||||
def setIndented(self, value):
|
||||
self.indented = value
|
||||
|
||||
def setHeading(self, level):
|
||||
self.headingLevel = level
|
||||
|
||||
def setTitle(self, value):
|
||||
self.title = value
|
||||
|
||||
def setCode(self, value):
|
||||
self.code = value
|
||||
|
||||
|
||||
def __str__(self):
|
||||
|
||||
return "[bq=%s, h=%d, code=%s]" % (str(self.blockquote),
|
||||
self.headingLevel,
|
||||
str(self.code))
|
||||
|
||||
|
||||
class ListProperties:
|
||||
""" Holds properties for a list style. """
|
||||
|
||||
def __init__(self):
|
||||
self.ordered = False
|
||||
|
||||
def setOrdered(self, value):
|
||||
self.ordered = value
|
||||
|
||||
|
||||
|
||||
class ODF2MoinMoin(object):
|
||||
|
||||
|
||||
def __init__(self, filepath):
|
||||
self.footnotes = []
|
||||
self.footnoteCounter = 0
|
||||
self.textStyles = {"Standard": TextProps()}
|
||||
self.paragraphStyles = {"Standard": ParagraphProps()}
|
||||
self.listStyles = {}
|
||||
self.fixedFonts = []
|
||||
self.hasTitle = 0
|
||||
self.lastsegment = None
|
||||
|
||||
# Tags
|
||||
self.elements = {
|
||||
'draw:page': self.textToString,
|
||||
'draw:frame': self.textToString,
|
||||
'draw:image': self.draw_image,
|
||||
'draw:text-box': self.textToString,
|
||||
'text:a': self.text_a,
|
||||
'text:note': self.text_note,
|
||||
}
|
||||
for tag in IGNORED_TAGS:
|
||||
self.elements[tag] = self.do_nothing
|
||||
|
||||
for tag in INLINE_TAGS:
|
||||
self.elements[tag] = self.inline_markup
|
||||
self.elements['text:line-break'] = self.text_line_break
|
||||
self.elements['text:s'] = self.text_s
|
||||
self.elements['text:tab'] = self.text_tab
|
||||
|
||||
self.load(filepath)
|
||||
|
||||
def processFontDeclarations(self, fontDecl):
|
||||
""" Extracts necessary font information from a font-declaration
|
||||
element.
|
||||
"""
|
||||
for fontFace in fontDecl.getElementsByTagName("style:font-face"):
|
||||
if fontFace.getAttribute("style:font-pitch") == "fixed":
|
||||
self.fixedFonts.append(fontFace.getAttribute("style:name"))
|
||||
|
||||
|
||||
|
||||
def extractTextProperties(self, style, parent=None):
|
||||
""" Extracts text properties from a style element. """
|
||||
|
||||
textProps = TextProps()
|
||||
|
||||
if parent:
|
||||
parentProp = self.textStyles.get(parent, None)
|
||||
if parentProp:
|
||||
textProp = parentProp
|
||||
|
||||
textPropEl = style.getElementsByTagName("style:text-properties")
|
||||
if not textPropEl: return textProps
|
||||
|
||||
textPropEl = textPropEl[0]
|
||||
|
||||
textProps.setItalic(textPropEl.getAttribute("fo:font-style"))
|
||||
textProps.setBold(textPropEl.getAttribute("fo:font-weight"))
|
||||
textProps.setUnderlined(textPropEl.getAttribute("style:text-underline-style"))
|
||||
textProps.setStrikethrough(textPropEl.getAttribute("style:text-line-through-style"))
|
||||
textProps.setPosition(textPropEl.getAttribute("style:text-position"))
|
||||
|
||||
if textPropEl.getAttribute("style:font-name") in self.fixedFonts:
|
||||
textProps.setFixed(True)
|
||||
|
||||
return textProps
|
||||
|
||||
def extractParagraphProperties(self, style, parent=None):
|
||||
""" Extracts paragraph properties from a style element. """
|
||||
|
||||
paraProps = ParagraphProps()
|
||||
|
||||
name = style.getAttribute("style:name")
|
||||
|
||||
if name.startswith("Heading_20_"):
|
||||
level = name[11:]
|
||||
try:
|
||||
level = int(level)
|
||||
paraProps.setHeading(level)
|
||||
except:
|
||||
level = 0
|
||||
|
||||
if name == "Title":
|
||||
paraProps.setTitle(True)
|
||||
|
||||
paraPropEl = style.getElementsByTagName("style:paragraph-properties")
|
||||
if paraPropEl:
|
||||
paraPropEl = paraPropEl[0]
|
||||
leftMargin = paraPropEl.getAttribute("fo:margin-left")
|
||||
if leftMargin:
|
||||
try:
|
||||
leftMargin = float(leftMargin[:-2])
|
||||
if leftMargin > 0.01:
|
||||
paraProps.setIndented(True)
|
||||
except:
|
||||
pass
|
||||
|
||||
textProps = self.extractTextProperties(style)
|
||||
if textProps.fixed:
|
||||
paraProps.setCode(True)
|
||||
|
||||
return paraProps
|
||||
|
||||
|
||||
def processStyles(self, styleElements):
|
||||
""" Runs through "style" elements extracting necessary information.
|
||||
"""
|
||||
|
||||
for style in styleElements:
|
||||
|
||||
name = style.getAttribute("style:name")
|
||||
|
||||
if name == "Standard": continue
|
||||
|
||||
family = style.getAttribute("style:family")
|
||||
parent = style.getAttribute("style:parent-style-name")
|
||||
|
||||
if family == "text":
|
||||
self.textStyles[name] = self.extractTextProperties(style, parent)
|
||||
|
||||
elif family == "paragraph":
|
||||
self.paragraphStyles[name] = \
|
||||
self.extractParagraphProperties(style, parent)
|
||||
self.textStyles[name] = self.extractTextProperties(style, parent)
|
||||
|
||||
def processListStyles(self, listStyleElements):
|
||||
|
||||
for style in listStyleElements:
|
||||
name = style.getAttribute("style:name")
|
||||
|
||||
prop = ListProperties()
|
||||
if style.hasChildNodes():
|
||||
subitems = [el for el in style.childNodes
|
||||
if el.nodeType == xml.dom.Node.ELEMENT_NODE
|
||||
and el.tagName == "text:list-level-style-number"]
|
||||
if len(subitems) > 0:
|
||||
prop.setOrdered(True)
|
||||
|
||||
self.listStyles[name] = prop
|
||||
|
||||
|
||||
def load(self, filepath):
|
||||
""" Loads an ODT file. """
|
||||
|
||||
zip = zipfile.ZipFile(filepath)
|
||||
|
||||
styles_doc = xml.dom.minidom.parseString(zip.read("styles.xml"))
|
||||
fontfacedecls = styles_doc.getElementsByTagName("office:font-face-decls")
|
||||
if fontfacedecls:
|
||||
self.processFontDeclarations(fontfacedecls[0])
|
||||
self.processStyles(styles_doc.getElementsByTagName("style:style"))
|
||||
self.processListStyles(styles_doc.getElementsByTagName("text:list-style"))
|
||||
|
||||
self.content = xml.dom.minidom.parseString(zip.read("content.xml"))
|
||||
fontfacedecls = self.content.getElementsByTagName("office:font-face-decls")
|
||||
if fontfacedecls:
|
||||
self.processFontDeclarations(fontfacedecls[0])
|
||||
|
||||
self.processStyles(self.content.getElementsByTagName("style:style"))
|
||||
self.processListStyles(self.content.getElementsByTagName("text:list-style"))
|
||||
|
||||
def compressCodeBlocks(self, text):
|
||||
""" Removes extra blank lines from code blocks. """
|
||||
|
||||
return text
|
||||
lines = text.split("\n")
|
||||
buffer = []
|
||||
numLines = len(lines)
|
||||
for i in range(numLines):
|
||||
|
||||
if (lines[i].strip() or i == numLines-1 or i == 0 or
|
||||
not ( lines[i-1].startswith(" ")
|
||||
and lines[i+1].startswith(" ") ) ):
|
||||
buffer.append("\n" + lines[i])
|
||||
|
||||
return ''.join(buffer)
|
||||
|
||||
#-----------------------------------
|
||||
def do_nothing(self, node):
|
||||
return ''
|
||||
|
||||
def draw_image(self, node):
|
||||
"""
|
||||
"""
|
||||
|
||||
link = node.getAttribute("xlink:href")
|
||||
if link and link[:2] == './': # Indicates a sub-object, which isn't supported
|
||||
return "%s\n" % link
|
||||
if link and link[:9] == 'Pictures/':
|
||||
link = link[9:]
|
||||
return "[[Image(%s)]]\n" % link
|
||||
|
||||
def text_a(self, node):
|
||||
text = self.textToString(node)
|
||||
link = node.getAttribute("xlink:href")
|
||||
if link.strip() == text.strip():
|
||||
return "[%s] " % link.strip()
|
||||
else:
|
||||
return "[%s %s] " % (link.strip(), text.strip())
|
||||
|
||||
|
||||
def text_line_break(self, node):
|
||||
return "[[BR]]"
|
||||
|
||||
def text_note(self, node):
|
||||
cite = (node.getElementsByTagName("text:note-citation")[0]
|
||||
.childNodes[0].nodeValue)
|
||||
body = (node.getElementsByTagName("text:note-body")[0]
|
||||
.childNodes[0])
|
||||
self.footnotes.append((cite, self.textToString(body)))
|
||||
return "^%s^" % cite
|
||||
|
||||
def text_s(self, node):
|
||||
try:
|
||||
num = int(node.getAttribute("text:c"))
|
||||
return " "*num
|
||||
except:
|
||||
return " "
|
||||
|
||||
def text_tab(self, node):
|
||||
return " "
|
||||
|
||||
def inline_markup(self, node):
|
||||
text = self.textToString(node)
|
||||
|
||||
if not text.strip():
|
||||
return '' # don't apply styles to white space
|
||||
|
||||
styleName = node.getAttribute("text:style-name")
|
||||
style = self.textStyles.get(styleName, TextProps())
|
||||
|
||||
if style.fixed:
|
||||
return "`" + text + "`"
|
||||
|
||||
mark = []
|
||||
if style:
|
||||
if style.italic:
|
||||
mark.append("''")
|
||||
if style.bold:
|
||||
mark.append("'''")
|
||||
if style.underlined:
|
||||
mark.append("__")
|
||||
if style.strikethrough:
|
||||
mark.append("~~")
|
||||
if style.superscript:
|
||||
mark.append("^")
|
||||
if style.subscript:
|
||||
mark.append(",,")
|
||||
revmark = mark[:]
|
||||
revmark.reverse()
|
||||
return "%s%s%s" % (''.join(mark), text, ''.join(revmark))
|
||||
|
||||
#-----------------------------------
|
||||
def listToString(self, listElement, indent = 0):
|
||||
|
||||
self.lastsegment = listElement.tagName
|
||||
buffer = []
|
||||
|
||||
styleName = listElement.getAttribute("text:style-name")
|
||||
props = self.listStyles.get(styleName, ListProperties())
|
||||
|
||||
i = 0
|
||||
for item in listElement.childNodes:
|
||||
buffer.append(" "*indent)
|
||||
i += 1
|
||||
if props.ordered:
|
||||
number = str(i)
|
||||
number = " " + number + ". "
|
||||
buffer.append(" 1. ")
|
||||
else:
|
||||
buffer.append(" * ")
|
||||
subitems = [el for el in item.childNodes
|
||||
if el.tagName in ["text:p", "text:h", "text:list"]]
|
||||
for subitem in subitems:
|
||||
if subitem.tagName == "text:list":
|
||||
buffer.append("\n")
|
||||
buffer.append(self.listToString(subitem, indent+3))
|
||||
else:
|
||||
buffer.append(self.paragraphToString(subitem, indent+3))
|
||||
self.lastsegment = subitem.tagName
|
||||
self.lastsegment = item.tagName
|
||||
buffer.append("\n")
|
||||
|
||||
return ''.join(buffer)
|
||||
|
||||
def tableToString(self, tableElement):
|
||||
""" MoinMoin uses || to delimit table cells
|
||||
"""
|
||||
|
||||
self.lastsegment = tableElement.tagName
|
||||
buffer = []
|
||||
|
||||
for item in tableElement.childNodes:
|
||||
self.lastsegment = item.tagName
|
||||
if item.tagName == "table:table-header-rows":
|
||||
buffer.append(self.tableToString(item))
|
||||
if item.tagName == "table:table-row":
|
||||
buffer.append("\n||")
|
||||
for cell in item.childNodes:
|
||||
buffer.append(self.inline_markup(cell))
|
||||
buffer.append("||")
|
||||
self.lastsegment = cell.tagName
|
||||
return ''.join(buffer)
|
||||
|
||||
|
||||
def toString(self):
|
||||
""" Converts the document to a string.
|
||||
FIXME: Result from second call differs from first call
|
||||
"""
|
||||
body = self.content.getElementsByTagName("office:body")[0]
|
||||
text = body.childNodes[0]
|
||||
|
||||
buffer = []
|
||||
|
||||
paragraphs = [el for el in text.childNodes
|
||||
if el.tagName in ["draw:page", "text:p", "text:h","text:section",
|
||||
"text:list", "table:table"]]
|
||||
|
||||
for paragraph in paragraphs:
|
||||
if paragraph.tagName == "text:list":
|
||||
text = self.listToString(paragraph)
|
||||
elif paragraph.tagName == "text:section":
|
||||
text = self.textToString(paragraph)
|
||||
elif paragraph.tagName == "table:table":
|
||||
text = self.tableToString(paragraph)
|
||||
else:
|
||||
text = self.paragraphToString(paragraph)
|
||||
if text:
|
||||
buffer.append(text)
|
||||
|
||||
if self.footnotes:
|
||||
|
||||
buffer.append("----")
|
||||
for cite, body in self.footnotes:
|
||||
buffer.append("%s: %s" % (cite, body))
|
||||
|
||||
|
||||
buffer.append("")
|
||||
return self.compressCodeBlocks('\n'.join(buffer))
|
||||
|
||||
|
||||
def textToString(self, element):
|
||||
|
||||
buffer = []
|
||||
|
||||
for node in element.childNodes:
|
||||
|
||||
if node.nodeType == xml.dom.Node.TEXT_NODE:
|
||||
buffer.append(node.nodeValue)
|
||||
|
||||
elif node.nodeType == xml.dom.Node.ELEMENT_NODE:
|
||||
tag = node.tagName
|
||||
|
||||
if tag in ("draw:text-box", "draw:frame"):
|
||||
buffer.append(self.textToString(node))
|
||||
|
||||
elif tag in ("text:p", "text:h"):
|
||||
text = self.paragraphToString(node)
|
||||
if text:
|
||||
buffer.append(text)
|
||||
elif tag == "text:list":
|
||||
buffer.append(self.listToString(node))
|
||||
else:
|
||||
method = self.elements.get(tag)
|
||||
if method:
|
||||
buffer.append(method(node))
|
||||
else:
|
||||
buffer.append(" {" + tag + "} ")
|
||||
|
||||
return ''.join(buffer)
|
||||
|
||||
def paragraphToString(self, paragraph, indent = 0):
|
||||
|
||||
dummyParaProps = ParagraphProps()
|
||||
|
||||
style_name = paragraph.getAttribute("text:style-name")
|
||||
paraProps = self.paragraphStyles.get(style_name, dummyParaProps)
|
||||
text = self.inline_markup(paragraph)
|
||||
|
||||
if paraProps and not paraProps.code:
|
||||
text = text.strip()
|
||||
|
||||
if paragraph.tagName == "text:p" and self.lastsegment == "text:p":
|
||||
text = "\n" + text
|
||||
|
||||
self.lastsegment = paragraph.tagName
|
||||
|
||||
if paraProps.title:
|
||||
self.hasTitle = 1
|
||||
return "= " + text + " =\n"
|
||||
|
||||
outlinelevel = paragraph.getAttribute("text:outline-level")
|
||||
if outlinelevel:
|
||||
|
||||
level = int(outlinelevel)
|
||||
if self.hasTitle: level += 1
|
||||
|
||||
if level >= 1:
|
||||
return "=" * level + " " + text + " " + "=" * level + "\n"
|
||||
|
||||
elif paraProps.code:
|
||||
return "{{{\n" + text + "\n}}}\n"
|
||||
|
||||
if paraProps.indented:
|
||||
return self.wrapParagraph(text, indent = indent, blockquote = True)
|
||||
|
||||
else:
|
||||
return self.wrapParagraph(text, indent = indent)
|
||||
|
||||
|
||||
def wrapParagraph(self, text, indent = 0, blockquote=False):
|
||||
|
||||
counter = 0
|
||||
buffer = []
|
||||
LIMIT = 50
|
||||
|
||||
if blockquote:
|
||||
buffer.append(" ")
|
||||
|
||||
return ''.join(buffer) + text
|
||||
# Unused from here
|
||||
for token in text.split():
|
||||
|
||||
if counter > LIMIT - indent:
|
||||
buffer.append("\n" + " "*indent)
|
||||
if blockquote:
|
||||
buffer.append(" ")
|
||||
counter = 0
|
||||
|
||||
buffer.append(token + " ")
|
||||
counter += len(token)
|
||||
|
||||
return ''.join(buffer)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
# This script lists the content of the manifest.xml file
|
||||
import zipfile
|
||||
from xml.sax import make_parser,handler
|
||||
from xml.sax.xmlreader import InputSource
|
||||
import xml.sax.saxutils
|
||||
from cStringIO import StringIO
|
||||
|
||||
MANIFESTNS="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# ODFMANIFESTHANDLER
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
class ODFManifestHandler(handler.ContentHandler):
|
||||
""" The ODFManifestHandler parses a manifest file and produces a list of
|
||||
content """
|
||||
|
||||
def __init__(self):
|
||||
self.manifest = {}
|
||||
|
||||
# Tags
|
||||
# FIXME: Also handle encryption data
|
||||
self.elements = {
|
||||
(MANIFESTNS, 'file-entry'): (self.s_file_entry, self.donothing),
|
||||
}
|
||||
|
||||
def handle_starttag(self, tag, method, attrs):
|
||||
method(tag,attrs)
|
||||
|
||||
def handle_endtag(self, tag, method):
|
||||
method(tag)
|
||||
|
||||
def startElementNS(self, tag, qname, attrs):
|
||||
method = self.elements.get(tag, (None, None))[0]
|
||||
if method:
|
||||
self.handle_starttag(tag, method, attrs)
|
||||
else:
|
||||
self.unknown_starttag(tag,attrs)
|
||||
|
||||
def endElementNS(self, tag, qname):
|
||||
method = self.elements.get(tag, (None, None))[1]
|
||||
if method:
|
||||
self.handle_endtag(tag, method)
|
||||
else:
|
||||
self.unknown_endtag(tag)
|
||||
|
||||
def unknown_starttag(self, tag, attrs):
|
||||
pass
|
||||
|
||||
def unknown_endtag(self, tag):
|
||||
pass
|
||||
|
||||
def donothing(self, tag, attrs=None):
|
||||
pass
|
||||
|
||||
def s_file_entry(self, tag, attrs):
|
||||
m = attrs.get((MANIFESTNS, 'media-type'),"application/octet-stream")
|
||||
p = attrs.get((MANIFESTNS, 'full-path'))
|
||||
self.manifest[p] = { 'media-type':m, 'full-path':p }
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Reading the file
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
def manifestlist(manifestxml):
|
||||
odhandler = ODFManifestHandler()
|
||||
parser = make_parser()
|
||||
parser.setFeature(handler.feature_namespaces, 1)
|
||||
parser.setContentHandler(odhandler)
|
||||
parser.setErrorHandler(handler.ErrorHandler())
|
||||
|
||||
inpsrc = InputSource()
|
||||
inpsrc.setByteStream(StringIO(manifestxml))
|
||||
parser.parse(inpsrc)
|
||||
|
||||
return odhandler.manifest
|
||||
|
||||
def odfmanifest(odtfile):
|
||||
z = zipfile.ZipFile(odtfile)
|
||||
manifest = z.read('META-INF/manifest.xml')
|
||||
z.close()
|
||||
return manifestlist(manifest)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
result = odfmanifest(sys.argv[1])
|
||||
for file in result.values():
|
||||
print "%-40s %-40s" % (file['media-type'], file['full-path'])
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import OFFICENS
|
||||
from element import Element
|
||||
from draw import StyleRefElement
|
||||
|
||||
# Autogenerated
|
||||
def Annotation(**args):
|
||||
return StyleRefElement(qname = (OFFICENS,'annotation'), **args)
|
||||
|
||||
def AutomaticStyles(**args):
|
||||
return Element(qname = (OFFICENS, 'automatic-styles'), **args)
|
||||
|
||||
def BinaryData(**args):
|
||||
return Element(qname = (OFFICENS,'binary-data'), **args)
|
||||
|
||||
def Body(**args):
|
||||
return Element(qname = (OFFICENS, 'body'), **args)
|
||||
|
||||
def ChangeInfo(**args):
|
||||
return Element(qname = (OFFICENS,'change-info'), **args)
|
||||
|
||||
def Chart(**args):
|
||||
return Element(qname = (OFFICENS,'chart'), **args)
|
||||
|
||||
def DdeSource(**args):
|
||||
return Element(qname = (OFFICENS,'dde-source'), **args)
|
||||
|
||||
def Document(version="1.1", **args):
|
||||
return Element(qname = (OFFICENS,'document'), version=version, **args)
|
||||
|
||||
def DocumentContent(version="1.1", **args):
|
||||
return Element(qname = (OFFICENS, 'document-content'), version=version, **args)
|
||||
|
||||
def DocumentMeta(version="1.1", **args):
|
||||
return Element(qname = (OFFICENS, 'document-meta'), version=version, **args)
|
||||
|
||||
def DocumentSettings(version="1.1", **args):
|
||||
return Element(qname = (OFFICENS, 'document-settings'), version=version, **args)
|
||||
|
||||
def DocumentStyles(version="1.1", **args):
|
||||
return Element(qname = (OFFICENS, 'document-styles'), version=version, **args)
|
||||
|
||||
def Drawing(**args):
|
||||
return Element(qname = (OFFICENS,'drawing'), **args)
|
||||
|
||||
def EventListeners(**args):
|
||||
return Element(qname = (OFFICENS,'event-listeners'), **args)
|
||||
|
||||
def FontFaceDecls(**args):
|
||||
return Element(qname = (OFFICENS, 'font-face-decls'), **args)
|
||||
|
||||
def Forms(**args):
|
||||
return Element(qname = (OFFICENS,'forms'), **args)
|
||||
|
||||
def Image(**args):
|
||||
return Element(qname = (OFFICENS,'image'), **args)
|
||||
|
||||
def MasterStyles(**args):
|
||||
return Element(qname = (OFFICENS, 'master-styles'), **args)
|
||||
|
||||
def Meta(**args):
|
||||
return Element(qname = (OFFICENS, 'meta'), **args)
|
||||
|
||||
def Presentation(**args):
|
||||
return Element(qname = (OFFICENS,'presentation'), **args)
|
||||
|
||||
def Script(**args):
|
||||
return Element(qname = (OFFICENS, 'script'), **args)
|
||||
|
||||
def Scripts(**args):
|
||||
return Element(qname = (OFFICENS, 'scripts'), **args)
|
||||
|
||||
def Settings(**args):
|
||||
return Element(qname = (OFFICENS, 'settings'), **args)
|
||||
|
||||
def Spreadsheet(**args):
|
||||
return Element(qname = (OFFICENS, 'spreadsheet'), **args)
|
||||
|
||||
def Styles(**args):
|
||||
return Element(qname = (OFFICENS, 'styles'), **args)
|
||||
|
||||
def Text(**args):
|
||||
return Element(qname = (OFFICENS, 'text'), **args)
|
||||
|
||||
# Autogenerated end
|
||||
@@ -0,0 +1,654 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2010 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
__doc__="""Use OpenDocument to generate your documents."""
|
||||
|
||||
import zipfile, time, sys, mimetypes, copy
|
||||
from cStringIO import StringIO
|
||||
from namespaces import *
|
||||
import manifest, meta
|
||||
from office import *
|
||||
import element
|
||||
from attrconverters import make_NCName
|
||||
from xml.sax.xmlreader import InputSource
|
||||
from odfmanifest import manifestlist
|
||||
|
||||
__version__= TOOLSVERSION
|
||||
|
||||
_XMLPROLOGUE = u"<?xml version='1.0' encoding='UTF-8'?>\n"
|
||||
|
||||
UNIXPERMS = 0100644 << 16L # -rw-r--r--
|
||||
|
||||
IS_FILENAME = 0
|
||||
IS_IMAGE = 1
|
||||
# We need at least Python 2.2
|
||||
assert sys.version_info[0]>=2 and sys.version_info[1] >= 2
|
||||
|
||||
#sys.setrecursionlimit(100)
|
||||
#The recursion limit is set conservative so mistakes like
|
||||
# s=content() s.addElement(s) won't eat up too much processor time.
|
||||
|
||||
odmimetypes = {
|
||||
'application/vnd.oasis.opendocument.text': '.odt',
|
||||
'application/vnd.oasis.opendocument.text-template': '.ott',
|
||||
'application/vnd.oasis.opendocument.graphics': '.odg',
|
||||
'application/vnd.oasis.opendocument.graphics-template': '.otg',
|
||||
'application/vnd.oasis.opendocument.presentation': '.odp',
|
||||
'application/vnd.oasis.opendocument.presentation-template': '.otp',
|
||||
'application/vnd.oasis.opendocument.spreadsheet': '.ods',
|
||||
'application/vnd.oasis.opendocument.spreadsheet-template': '.ots',
|
||||
'application/vnd.oasis.opendocument.chart': '.odc',
|
||||
'application/vnd.oasis.opendocument.chart-template': '.otc',
|
||||
'application/vnd.oasis.opendocument.image': '.odi',
|
||||
'application/vnd.oasis.opendocument.image-template': '.oti',
|
||||
'application/vnd.oasis.opendocument.formula': '.odf',
|
||||
'application/vnd.oasis.opendocument.formula-template': '.otf',
|
||||
'application/vnd.oasis.opendocument.text-master': '.odm',
|
||||
'application/vnd.oasis.opendocument.text-web': '.oth',
|
||||
}
|
||||
|
||||
class OpaqueObject:
|
||||
def __init__(self, filename, mediatype, content=None):
|
||||
self.mediatype = mediatype
|
||||
self.filename = filename
|
||||
self.content = content
|
||||
|
||||
class OpenDocument:
|
||||
""" A class to hold the content of an OpenDocument document
|
||||
Use the xml method to write the XML
|
||||
source to the screen or to a file
|
||||
d = OpenDocument(mimetype)
|
||||
fd.write(d.xml())
|
||||
"""
|
||||
thumbnail = None
|
||||
|
||||
def __init__(self, mimetype, add_generator=True):
|
||||
self.mimetype = mimetype
|
||||
self.childobjects = []
|
||||
self._extra = []
|
||||
self.folder = "" # Always empty for toplevel documents
|
||||
self.topnode = Document(mimetype=self.mimetype)
|
||||
self.topnode.ownerDocument = self
|
||||
|
||||
self.clear_caches()
|
||||
|
||||
self.Pictures = {}
|
||||
self.meta = Meta()
|
||||
self.topnode.addElement(self.meta)
|
||||
if add_generator:
|
||||
self.meta.addElement(meta.Generator(text=TOOLSVERSION))
|
||||
self.scripts = Scripts()
|
||||
self.topnode.addElement(self.scripts)
|
||||
self.fontfacedecls = FontFaceDecls()
|
||||
self.topnode.addElement(self.fontfacedecls)
|
||||
self.settings = Settings()
|
||||
self.topnode.addElement(self.settings)
|
||||
self.styles = Styles()
|
||||
self.topnode.addElement(self.styles)
|
||||
self.automaticstyles = AutomaticStyles()
|
||||
self.topnode.addElement(self.automaticstyles)
|
||||
self.masterstyles = MasterStyles()
|
||||
self.topnode.addElement(self.masterstyles)
|
||||
self.body = Body()
|
||||
self.topnode.addElement(self.body)
|
||||
|
||||
def rebuild_caches(self, node=None):
|
||||
if node is None: node = self.topnode
|
||||
self.build_caches(node)
|
||||
for e in node.childNodes:
|
||||
if e.nodeType == element.Node.ELEMENT_NODE:
|
||||
self.rebuild_caches(e)
|
||||
|
||||
def clear_caches(self):
|
||||
self.element_dict = {}
|
||||
self._styles_dict = {}
|
||||
self._styles_ooo_fix = {}
|
||||
|
||||
def build_caches(self, element):
|
||||
""" Called from element.py
|
||||
"""
|
||||
if not self.element_dict.has_key(element.qname):
|
||||
self.element_dict[element.qname] = []
|
||||
self.element_dict[element.qname].append(element)
|
||||
if element.qname == (STYLENS, u'style'):
|
||||
self.__register_stylename(element) # Add to style dictionary
|
||||
styleref = element.getAttrNS(TEXTNS,u'style-name')
|
||||
if styleref is not None and self._styles_ooo_fix.has_key(styleref):
|
||||
element.setAttrNS(TEXTNS,u'style-name', self._styles_ooo_fix[styleref])
|
||||
|
||||
def __register_stylename(self, element):
|
||||
''' Register a style. But there are three style dictionaries:
|
||||
office:styles, office:automatic-styles and office:master-styles
|
||||
Chapter 14
|
||||
'''
|
||||
name = element.getAttrNS(STYLENS, u'name')
|
||||
if name is None:
|
||||
return
|
||||
if element.parentNode.qname in ((OFFICENS,u'styles'), (OFFICENS,u'automatic-styles')):
|
||||
if self._styles_dict.has_key(name):
|
||||
newname = 'M'+name # Rename style
|
||||
self._styles_ooo_fix[name] = newname
|
||||
# From here on all references to the old name will refer to the new one
|
||||
name = newname
|
||||
element.setAttrNS(STYLENS, u'name', name)
|
||||
self._styles_dict[name] = element
|
||||
|
||||
def toXml(self, filename=''):
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
self.body.toXml(0, xml)
|
||||
if not filename:
|
||||
return xml.getvalue()
|
||||
else:
|
||||
f=file(filename,'w')
|
||||
f.write(xml.getvalue())
|
||||
f.close()
|
||||
|
||||
def xml(self):
|
||||
""" Generates the full document as an XML file
|
||||
Always written as a bytestream in UTF-8 encoding
|
||||
"""
|
||||
self.__replaceGenerator()
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
self.topnode.toXml(0, xml)
|
||||
return xml.getvalue()
|
||||
|
||||
|
||||
def contentxml(self):
|
||||
""" Generates the content.xml file
|
||||
Always written as a bytestream in UTF-8 encoding
|
||||
"""
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
x = DocumentContent()
|
||||
x.write_open_tag(0, xml)
|
||||
if self.scripts.hasChildNodes():
|
||||
self.scripts.toXml(1, xml)
|
||||
if self.fontfacedecls.hasChildNodes():
|
||||
self.fontfacedecls.toXml(1, xml)
|
||||
a = AutomaticStyles()
|
||||
stylelist = self._used_auto_styles([self.styles, self.automaticstyles, self.body])
|
||||
if len(stylelist) > 0:
|
||||
a.write_open_tag(1, xml)
|
||||
for s in stylelist:
|
||||
s.toXml(2, xml)
|
||||
a.write_close_tag(1, xml)
|
||||
else:
|
||||
a.toXml(1, xml)
|
||||
self.body.toXml(1, xml)
|
||||
x.write_close_tag(0, xml)
|
||||
return xml.getvalue()
|
||||
|
||||
def __manifestxml(self):
|
||||
""" Generates the manifest.xml file
|
||||
The self.manifest isn't avaible unless the document is being saved
|
||||
"""
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
self.manifest.toXml(0,xml)
|
||||
return xml.getvalue()
|
||||
|
||||
def metaxml(self):
|
||||
""" Generates the meta.xml file """
|
||||
self.__replaceGenerator()
|
||||
x = DocumentMeta()
|
||||
x.addElement(self.meta)
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
x.toXml(0,xml)
|
||||
return xml.getvalue()
|
||||
|
||||
def settingsxml(self):
|
||||
""" Generates the settings.xml file """
|
||||
x = DocumentSettings()
|
||||
x.addElement(self.settings)
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
x.toXml(0,xml)
|
||||
return xml.getvalue()
|
||||
|
||||
def _parseoneelement(self, top, stylenamelist):
|
||||
""" Finds references to style objects in master-styles
|
||||
and add the style name to the style list if not already there.
|
||||
Recursive
|
||||
"""
|
||||
for e in top.childNodes:
|
||||
if e.nodeType == element.Node.ELEMENT_NODE:
|
||||
for styleref in ( (DRAWNS,u'style-name'),
|
||||
(DRAWNS,u'text-style-name'),
|
||||
(PRESENTATIONNS,u'style-name'),
|
||||
(STYLENS,u'data-style-name'),
|
||||
(STYLENS,u'list-style-name'),
|
||||
(STYLENS,u'page-layout-name'),
|
||||
(STYLENS,u'style-name'),
|
||||
(TABLENS,u'default-cell-style-name'),
|
||||
(TABLENS,u'style-name'),
|
||||
(TEXTNS,u'style-name') ):
|
||||
if e.getAttrNS(styleref[0],styleref[1]):
|
||||
stylename = e.getAttrNS(styleref[0],styleref[1])
|
||||
if stylename not in stylenamelist:
|
||||
stylenamelist.append(stylename)
|
||||
stylenamelist = self._parseoneelement(e, stylenamelist)
|
||||
return stylenamelist
|
||||
|
||||
def _used_auto_styles(self, segments):
|
||||
""" Loop through the masterstyles elements, and find the automatic
|
||||
styles that are used. These will be added to the automatic-styles
|
||||
element in styles.xml
|
||||
"""
|
||||
stylenamelist = []
|
||||
for top in segments:
|
||||
stylenamelist = self._parseoneelement(top, stylenamelist)
|
||||
stylelist = []
|
||||
for e in self.automaticstyles.childNodes:
|
||||
if e.getAttrNS(STYLENS,u'name') in stylenamelist:
|
||||
stylelist.append(e)
|
||||
return stylelist
|
||||
|
||||
def stylesxml(self):
|
||||
""" Generates the styles.xml file """
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
x = DocumentStyles()
|
||||
x.write_open_tag(0, xml)
|
||||
if self.fontfacedecls.hasChildNodes():
|
||||
self.fontfacedecls.toXml(1, xml)
|
||||
self.styles.toXml(1, xml)
|
||||
a = AutomaticStyles()
|
||||
a.write_open_tag(1, xml)
|
||||
for s in self._used_auto_styles([self.masterstyles]):
|
||||
s.toXml(2, xml)
|
||||
a.write_close_tag(1, xml)
|
||||
if self.masterstyles.hasChildNodes():
|
||||
self.masterstyles.toXml(1, xml)
|
||||
x.write_close_tag(0, xml)
|
||||
return xml.getvalue()
|
||||
|
||||
def addPicture(self, filename, mediatype=None, content=None):
|
||||
""" Add a picture
|
||||
It uses the same convention as OOo, in that it saves the picture in
|
||||
the zipfile in the subdirectory 'Pictures'
|
||||
If passed a file ptr, mediatype must be set
|
||||
"""
|
||||
if content is None:
|
||||
if mediatype is None:
|
||||
mediatype, encoding = mimetypes.guess_type(filename)
|
||||
if mediatype is None:
|
||||
mediatype = ''
|
||||
try: ext = filename[filename.rindex('.'):]
|
||||
except: ext=''
|
||||
else:
|
||||
ext = mimetypes.guess_extension(mediatype)
|
||||
manifestfn = "Pictures/%0.0f%s" % ((time.time()*10000000000), ext)
|
||||
self.Pictures[manifestfn] = (IS_FILENAME, filename, mediatype)
|
||||
else:
|
||||
manifestfn = filename
|
||||
self.Pictures[manifestfn] = (IS_IMAGE, content, mediatype)
|
||||
return manifestfn
|
||||
|
||||
def addPictureFromFile(self, filename, mediatype=None):
|
||||
""" Add a picture
|
||||
It uses the same convention as OOo, in that it saves the picture in
|
||||
the zipfile in the subdirectory 'Pictures'.
|
||||
If mediatype is not given, it will be guessed from the filename
|
||||
extension.
|
||||
"""
|
||||
if mediatype is None:
|
||||
mediatype, encoding = mimetypes.guess_type(filename)
|
||||
if mediatype is None:
|
||||
mediatype = ''
|
||||
try: ext = filename[filename.rindex('.'):]
|
||||
except ValueError: ext=''
|
||||
else:
|
||||
ext = mimetypes.guess_extension(mediatype)
|
||||
manifestfn = "Pictures/%0.0f%s" % ((time.time()*10000000000), ext)
|
||||
self.Pictures[manifestfn] = (IS_FILENAME, filename, mediatype)
|
||||
return manifestfn
|
||||
|
||||
def addPictureFromString(self, content, mediatype):
|
||||
""" Add a picture
|
||||
It uses the same convention as OOo, in that it saves the picture in
|
||||
the zipfile in the subdirectory 'Pictures'. The content variable
|
||||
is a string that contains the binary image data. The mediatype
|
||||
indicates the image format.
|
||||
"""
|
||||
ext = mimetypes.guess_extension(mediatype)
|
||||
manifestfn = "Pictures/%0.0f%s" % ((time.time()*10000000000), ext)
|
||||
self.Pictures[manifestfn] = (IS_IMAGE, content, mediatype)
|
||||
return manifestfn
|
||||
|
||||
def addThumbnail(self, filecontent=None):
|
||||
""" Add a fixed thumbnail
|
||||
The thumbnail in the library is big, so this is pretty useless.
|
||||
"""
|
||||
if filecontent is None:
|
||||
import thumbnail
|
||||
self.thumbnail = thumbnail.thumbnail()
|
||||
else:
|
||||
self.thumbnail = filecontent
|
||||
|
||||
def addObject(self, document, objectname=None):
|
||||
""" Adds an object (subdocument). The object must be an OpenDocument class
|
||||
The return value will be the folder in the zipfile the object is stored in
|
||||
"""
|
||||
self.childobjects.append(document)
|
||||
if objectname is None:
|
||||
document.folder = "%s/Object %d" % (self.folder, len(self.childobjects))
|
||||
else:
|
||||
document.folder = objectname
|
||||
return ".%s" % document.folder
|
||||
|
||||
def _savePictures(self, object, folder):
|
||||
hasPictures = False
|
||||
for arcname, picturerec in object.Pictures.items():
|
||||
what_it_is, fileobj, mediatype = picturerec
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="%s%s" % ( folder ,arcname), mediatype=mediatype))
|
||||
hasPictures = True
|
||||
if what_it_is == IS_FILENAME:
|
||||
self._z.write(fileobj, arcname, zipfile.ZIP_STORED)
|
||||
else:
|
||||
zi = zipfile.ZipInfo(str(arcname), self._now)
|
||||
zi.compress_type = zipfile.ZIP_STORED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, fileobj)
|
||||
# According to section 17.7.3 in ODF 1.1, the pictures folder should not have a manifest entry
|
||||
# if hasPictures:
|
||||
# self.manifest.addElement(manifest.FileEntry(fullpath="%sPictures/" % folder, mediatype=""))
|
||||
# Look in subobjects
|
||||
subobjectnum = 1
|
||||
for subobject in object.childobjects:
|
||||
self._savePictures(subobject,'%sObject %d/' % (folder, subobjectnum))
|
||||
subobjectnum += 1
|
||||
|
||||
def __replaceGenerator(self):
|
||||
""" Section 3.1.1: The application MUST NOT export the original identifier
|
||||
belonging to the application that created the document.
|
||||
"""
|
||||
for m in self.meta.childNodes[:]:
|
||||
if m.qname == (METANS, u'generator'):
|
||||
self.meta.removeChild(m)
|
||||
self.meta.addElement(meta.Generator(text=TOOLSVERSION))
|
||||
|
||||
def save(self, outputfile, addsuffix=False):
|
||||
""" Save the document under the filename.
|
||||
If the filename is '-' then save to stdout
|
||||
"""
|
||||
if outputfile == '-':
|
||||
outputfp = zipfile.ZipFile(sys.stdout,"w")
|
||||
else:
|
||||
if addsuffix:
|
||||
outputfile = outputfile + odmimetypes.get(self.mimetype,'.xxx')
|
||||
outputfp = zipfile.ZipFile(outputfile, "w")
|
||||
self.__zipwrite(outputfp)
|
||||
outputfp.close()
|
||||
|
||||
def write(self, outputfp):
|
||||
""" User API to write the ODF file to an open file descriptor
|
||||
Writes the ZIP format
|
||||
"""
|
||||
zipoutputfp = zipfile.ZipFile(outputfp,"w")
|
||||
self.__zipwrite(zipoutputfp)
|
||||
|
||||
def __zipwrite(self, outputfp):
|
||||
""" Write the document to an open file pointer
|
||||
This is where the real work is done
|
||||
"""
|
||||
self._z = outputfp
|
||||
self._now = time.localtime()[:6]
|
||||
self.manifest = manifest.Manifest()
|
||||
|
||||
# Write mimetype
|
||||
zi = zipfile.ZipInfo('mimetype', self._now)
|
||||
zi.compress_type = zipfile.ZIP_STORED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, self.mimetype)
|
||||
|
||||
self._saveXmlObjects(self,"")
|
||||
|
||||
# Write pictures
|
||||
self._savePictures(self,"")
|
||||
|
||||
# Write the thumbnail
|
||||
if self.thumbnail is not None:
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="Thumbnails/", mediatype=''))
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="Thumbnails/thumbnail.png", mediatype=''))
|
||||
zi = zipfile.ZipInfo("Thumbnails/thumbnail.png", self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, self.thumbnail)
|
||||
|
||||
# Write any extra files
|
||||
for op in self._extra:
|
||||
if op.filename == "META-INF/documentsignatures.xml": continue # Don't save signatures
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath=op.filename, mediatype=op.mediatype))
|
||||
zi = zipfile.ZipInfo(op.filename.encode('utf-8'), self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
if op.content is not None:
|
||||
self._z.writestr(zi, op.content)
|
||||
# Write manifest
|
||||
zi = zipfile.ZipInfo("META-INF/manifest.xml", self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, self.__manifestxml() )
|
||||
del self._z
|
||||
del self._now
|
||||
del self.manifest
|
||||
|
||||
|
||||
def _saveXmlObjects(self, object, folder):
|
||||
if self == object:
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="/", mediatype=object.mimetype))
|
||||
else:
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath=folder, mediatype=object.mimetype))
|
||||
# Write styles
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="%sstyles.xml" % folder, mediatype="text/xml"))
|
||||
zi = zipfile.ZipInfo("%sstyles.xml" % folder, self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, object.stylesxml() )
|
||||
|
||||
# Write content
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="%scontent.xml" % folder, mediatype="text/xml"))
|
||||
zi = zipfile.ZipInfo("%scontent.xml" % folder, self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, object.contentxml() )
|
||||
|
||||
# Write settings
|
||||
if object.settings.hasChildNodes():
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="%ssettings.xml" % folder, mediatype="text/xml"))
|
||||
zi = zipfile.ZipInfo("%ssettings.xml" % folder, self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, object.settingsxml() )
|
||||
|
||||
# Write meta
|
||||
if self == object:
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="meta.xml", mediatype="text/xml"))
|
||||
zi = zipfile.ZipInfo("meta.xml", self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, object.metaxml() )
|
||||
|
||||
# Write subobjects
|
||||
subobjectnum = 1
|
||||
for subobject in object.childobjects:
|
||||
self._saveXmlObjects(subobject, '%sObject %d/' % (folder, subobjectnum))
|
||||
subobjectnum += 1
|
||||
|
||||
# Document's DOM methods
|
||||
def createElement(self, element):
|
||||
""" Inconvenient interface to create an element, but follows XML-DOM.
|
||||
Does not allow attributes as argument, therefore can't check grammar.
|
||||
"""
|
||||
return element(check_grammar=False)
|
||||
|
||||
def createTextNode(self, data):
|
||||
""" Method to create a text node """
|
||||
return element.Text(data)
|
||||
|
||||
def createCDATASection(self, data):
|
||||
""" Method to create a CDATA section """
|
||||
return element.CDATASection(cdata)
|
||||
|
||||
def getMediaType(self):
|
||||
""" Returns the media type """
|
||||
return self.mimetype
|
||||
|
||||
def getStyleByName(self, name):
|
||||
""" Finds a style object based on the name """
|
||||
ncname = make_NCName(name)
|
||||
if self._styles_dict == {}:
|
||||
self.rebuild_caches()
|
||||
return self._styles_dict.get(ncname, None)
|
||||
|
||||
def getElementsByType(self, element):
|
||||
""" Gets elements based on the type, which is function from text.py, draw.py etc. """
|
||||
obj = element(check_grammar=False)
|
||||
if self.element_dict == {}:
|
||||
self.rebuild_caches()
|
||||
return self.element_dict.get(obj.qname, [])
|
||||
|
||||
# Convenience functions
|
||||
def OpenDocumentChart():
|
||||
""" Creates a chart document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.chart')
|
||||
doc.chart = Chart()
|
||||
doc.body.addElement(doc.chart)
|
||||
return doc
|
||||
|
||||
def OpenDocumentDrawing():
|
||||
""" Creates a drawing document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.graphics')
|
||||
doc.drawing = Drawing()
|
||||
doc.body.addElement(doc.drawing)
|
||||
return doc
|
||||
|
||||
def OpenDocumentImage():
|
||||
""" Creates an image document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.image')
|
||||
doc.image = Image()
|
||||
doc.body.addElement(doc.image)
|
||||
return doc
|
||||
|
||||
def OpenDocumentPresentation():
|
||||
""" Creates a presentation document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.presentation')
|
||||
doc.presentation = Presentation()
|
||||
doc.body.addElement(doc.presentation)
|
||||
return doc
|
||||
|
||||
def OpenDocumentSpreadsheet():
|
||||
""" Creates a spreadsheet document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.spreadsheet')
|
||||
doc.spreadsheet = Spreadsheet()
|
||||
doc.body.addElement(doc.spreadsheet)
|
||||
return doc
|
||||
|
||||
def OpenDocumentText():
|
||||
""" Creates a text document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.text')
|
||||
doc.text = Text()
|
||||
doc.body.addElement(doc.text)
|
||||
return doc
|
||||
|
||||
def OpenDocumentTextMaster():
|
||||
""" Creates a text master document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.text-master')
|
||||
doc.text = Text()
|
||||
doc.body.addElement(doc.text)
|
||||
return doc
|
||||
|
||||
def __loadxmlparts(z, manifest, doc, objectpath):
|
||||
from load import LoadParser
|
||||
from xml.sax import make_parser, handler
|
||||
|
||||
for xmlfile in (objectpath+'settings.xml', objectpath+'meta.xml', objectpath+'content.xml', objectpath+'styles.xml'):
|
||||
if not manifest.has_key(xmlfile):
|
||||
continue
|
||||
try:
|
||||
xmlpart = z.read(xmlfile)
|
||||
doc._parsing = xmlfile
|
||||
|
||||
parser = make_parser()
|
||||
parser.setFeature(handler.feature_namespaces, 1)
|
||||
parser.setContentHandler(LoadParser(doc))
|
||||
parser.setErrorHandler(handler.ErrorHandler())
|
||||
|
||||
inpsrc = InputSource()
|
||||
inpsrc.setByteStream(StringIO(xmlpart))
|
||||
parser.parse(inpsrc)
|
||||
del doc._parsing
|
||||
except KeyError, v: pass
|
||||
|
||||
def load(odffile):
|
||||
""" Load an ODF file into memory
|
||||
Returns a reference to the structure
|
||||
"""
|
||||
z = zipfile.ZipFile(odffile)
|
||||
mimetype = z.read('mimetype')
|
||||
doc = OpenDocument(mimetype, add_generator=False)
|
||||
|
||||
# Look in the manifest file to see if which of the four files there are
|
||||
manifestpart = z.read('META-INF/manifest.xml')
|
||||
manifest = manifestlist(manifestpart)
|
||||
__loadxmlparts(z, manifest, doc, '')
|
||||
for mentry,mvalue in manifest.items():
|
||||
if mentry[:9] == "Pictures/" and len(mentry) > 9:
|
||||
doc.addPicture(mvalue['full-path'], mvalue['media-type'], z.read(mentry))
|
||||
elif mentry == "Thumbnails/thumbnail.png":
|
||||
doc.addThumbnail(z.read(mentry))
|
||||
elif mentry in ('settings.xml', 'meta.xml', 'content.xml', 'styles.xml'):
|
||||
pass
|
||||
# Load subobjects into structure
|
||||
elif mentry[:7] == "Object " and len(mentry) < 11 and mentry[-1] == "/":
|
||||
subdoc = OpenDocument(mvalue['media-type'], add_generator=False)
|
||||
doc.addObject(subdoc, "/" + mentry[:-1])
|
||||
__loadxmlparts(z, manifest, subdoc, mentry)
|
||||
elif mentry[:7] == "Object ":
|
||||
pass # Don't load subobjects as opaque objects
|
||||
else:
|
||||
if mvalue['full-path'][-1] == '/':
|
||||
doc._extra.append(OpaqueObject(mvalue['full-path'], mvalue['media-type'], None))
|
||||
else:
|
||||
doc._extra.append(OpaqueObject(mvalue['full-path'], mvalue['media-type'], z.read(mentry)))
|
||||
# Add the SUN junk here to the struct somewhere
|
||||
# It is cached data, so it can be out-of-date
|
||||
z.close()
|
||||
b = doc.getElementsByType(Body)
|
||||
if mimetype[:39] == 'application/vnd.oasis.opendocument.text':
|
||||
doc.text = b[0].firstChild
|
||||
elif mimetype[:43] == 'application/vnd.oasis.opendocument.graphics':
|
||||
doc.graphics = b[0].firstChild
|
||||
elif mimetype[:47] == 'application/vnd.oasis.opendocument.presentation':
|
||||
doc.presentation = b[0].firstChild
|
||||
elif mimetype[:46] == 'application/vnd.oasis.opendocument.spreadsheet':
|
||||
doc.spreadsheet = b[0].firstChild
|
||||
elif mimetype[:40] == 'application/vnd.oasis.opendocument.chart':
|
||||
doc.chart = b[0].firstChild
|
||||
elif mimetype[:40] == 'application/vnd.oasis.opendocument.image':
|
||||
doc.image = b[0].firstChild
|
||||
elif mimetype[:42] == 'application/vnd.oasis.opendocument.formula':
|
||||
doc.formula = b[0].firstChild
|
||||
return doc
|
||||
|
||||
# vim: set expandtab sw=4 :
|
||||
@@ -0,0 +1,85 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import PRESENTATIONNS
|
||||
from element import Element
|
||||
|
||||
# ODF 1.0 section 9.6 and 9.7
|
||||
# Autogenerated
|
||||
def AnimationGroup(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'animation-group'), **args)
|
||||
|
||||
def Animations(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'animations'), **args)
|
||||
|
||||
def DateTime(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'date-time'), **args)
|
||||
|
||||
def DateTimeDecl(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'date-time-decl'), **args)
|
||||
|
||||
def Dim(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'dim'), **args)
|
||||
|
||||
def EventListener(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'event-listener'), **args)
|
||||
|
||||
def Footer(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'footer'), **args)
|
||||
|
||||
def FooterDecl(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'footer-decl'), **args)
|
||||
|
||||
def Header(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'header'), **args)
|
||||
|
||||
def HeaderDecl(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'header-decl'), **args)
|
||||
|
||||
def HideShape(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'hide-shape'), **args)
|
||||
|
||||
def HideText(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'hide-text'), **args)
|
||||
|
||||
def Notes(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'notes'), **args)
|
||||
|
||||
def Placeholder(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'placeholder'), **args)
|
||||
|
||||
def Play(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'play'), **args)
|
||||
|
||||
def Settings(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'settings'), **args)
|
||||
|
||||
def Show(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'show'), **args)
|
||||
|
||||
def ShowShape(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'show-shape'), **args)
|
||||
|
||||
def ShowText(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'show-text'), **args)
|
||||
|
||||
def Sound(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'sound'), **args)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import SCRIPTNS
|
||||
from element import Element
|
||||
|
||||
# ODF 1.0 section 12.4.1
|
||||
# The <script:event-listener> element binds an event to a macro.
|
||||
|
||||
# Autogenerated
|
||||
def EventListener(**args):
|
||||
return Element(qname = (SCRIPTNS,'event-listener'), **args)
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import STYLENS
|
||||
from element import Element
|
||||
|
||||
def StyleElement(**args):
|
||||
e = Element(**args)
|
||||
if args.get('check_grammar', True) == True:
|
||||
if not args.has_key('displayname'):
|
||||
e.setAttrNS(STYLENS,'display-name', args.get('name'))
|
||||
return e
|
||||
|
||||
# Autogenerated
|
||||
def BackgroundImage(**args):
|
||||
return Element(qname = (STYLENS,'background-image'), **args)
|
||||
|
||||
def ChartProperties(**args):
|
||||
return Element(qname = (STYLENS,'chart-properties'), **args)
|
||||
|
||||
def Column(**args):
|
||||
return Element(qname = (STYLENS,'column'), **args)
|
||||
|
||||
def ColumnSep(**args):
|
||||
return Element(qname = (STYLENS,'column-sep'), **args)
|
||||
|
||||
def Columns(**args):
|
||||
return Element(qname = (STYLENS,'columns'), **args)
|
||||
|
||||
def DefaultStyle(**args):
|
||||
return Element(qname = (STYLENS,'default-style'), **args)
|
||||
|
||||
def DrawingPageProperties(**args):
|
||||
return Element(qname = (STYLENS,'drawing-page-properties'), **args)
|
||||
|
||||
def DropCap(**args):
|
||||
return Element(qname = (STYLENS,'drop-cap'), **args)
|
||||
|
||||
def FontFace(**args):
|
||||
return Element(qname = (STYLENS,'font-face'), **args)
|
||||
|
||||
def Footer(**args):
|
||||
return Element(qname = (STYLENS,'footer'), **args)
|
||||
|
||||
def FooterLeft(**args):
|
||||
return Element(qname = (STYLENS,'footer-left'), **args)
|
||||
|
||||
def FooterStyle(**args):
|
||||
return Element(qname = (STYLENS,'footer-style'), **args)
|
||||
|
||||
def FootnoteSep(**args):
|
||||
return Element(qname = (STYLENS,'footnote-sep'), **args)
|
||||
|
||||
def GraphicProperties(**args):
|
||||
return Element(qname = (STYLENS,'graphic-properties'), **args)
|
||||
|
||||
def HandoutMaster(**args):
|
||||
return Element(qname = (STYLENS,'handout-master'), **args)
|
||||
|
||||
def Header(**args):
|
||||
return Element(qname = (STYLENS,'header'), **args)
|
||||
|
||||
def HeaderFooterProperties(**args):
|
||||
return Element(qname = (STYLENS,'header-footer-properties'), **args)
|
||||
|
||||
def HeaderLeft(**args):
|
||||
return Element(qname = (STYLENS,'header-left'), **args)
|
||||
|
||||
def HeaderStyle(**args):
|
||||
return Element(qname = (STYLENS,'header-style'), **args)
|
||||
|
||||
def ListLevelProperties(**args):
|
||||
return Element(qname = (STYLENS,'list-level-properties'), **args)
|
||||
|
||||
def Map(**args):
|
||||
return Element(qname = (STYLENS,'map'), **args)
|
||||
|
||||
def MasterPage(**args):
|
||||
return StyleElement(qname = (STYLENS,'master-page'), **args)
|
||||
|
||||
def PageLayout(**args):
|
||||
return Element(qname = (STYLENS,'page-layout'), **args)
|
||||
|
||||
def PageLayoutProperties(**args):
|
||||
return Element(qname = (STYLENS,'page-layout-properties'), **args)
|
||||
|
||||
def ParagraphProperties(**args):
|
||||
return Element(qname = (STYLENS,'paragraph-properties'), **args)
|
||||
|
||||
def PresentationPageLayout(**args):
|
||||
return StyleElement(qname = (STYLENS,'presentation-page-layout'), **args)
|
||||
|
||||
def RegionCenter(**args):
|
||||
return Element(qname = (STYLENS,'region-center'), **args)
|
||||
|
||||
def RegionLeft(**args):
|
||||
return Element(qname = (STYLENS,'region-left'), **args)
|
||||
|
||||
def RegionRight(**args):
|
||||
return Element(qname = (STYLENS,'region-right'), **args)
|
||||
|
||||
def RubyProperties(**args):
|
||||
return Element(qname = (STYLENS,'ruby-properties'), **args)
|
||||
|
||||
def SectionProperties(**args):
|
||||
return Element(qname = (STYLENS,'section-properties'), **args)
|
||||
|
||||
def Style(**args):
|
||||
return StyleElement(qname = (STYLENS,'style'), **args)
|
||||
|
||||
def TabStop(**args):
|
||||
return Element(qname = (STYLENS,'tab-stop'), **args)
|
||||
|
||||
def TabStops(**args):
|
||||
return Element(qname = (STYLENS,'tab-stops'), **args)
|
||||
|
||||
def TableCellProperties(**args):
|
||||
return Element(qname = (STYLENS,'table-cell-properties'), **args)
|
||||
|
||||
def TableColumnProperties(**args):
|
||||
return Element(qname = (STYLENS,'table-column-properties'), **args)
|
||||
|
||||
def TableProperties(**args):
|
||||
return Element(qname = (STYLENS,'table-properties'), **args)
|
||||
|
||||
def TableRowProperties(**args):
|
||||
return Element(qname = (STYLENS,'table-row-properties'), **args)
|
||||
|
||||
def TextProperties(**args):
|
||||
return Element(qname = (STYLENS,'text-properties'), **args)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import SVGNS
|
||||
from element import Element
|
||||
from draw import DrawElement
|
||||
|
||||
# Autogenerated
|
||||
def DefinitionSrc(**args):
|
||||
return Element(qname = (SVGNS,'definition-src'), **args)
|
||||
|
||||
def Desc(**args):
|
||||
return Element(qname = (SVGNS,'desc'), **args)
|
||||
|
||||
def FontFaceFormat(**args):
|
||||
return Element(qname = (SVGNS,'font-face-format'), **args)
|
||||
|
||||
def FontFaceName(**args):
|
||||
return Element(qname = (SVGNS,'font-face-name'), **args)
|
||||
|
||||
def FontFaceSrc(**args):
|
||||
return Element(qname = (SVGNS,'font-face-src'), **args)
|
||||
|
||||
def FontFaceUri(**args):
|
||||
return Element(qname = (SVGNS,'font-face-uri'), **args)
|
||||
|
||||
def Lineargradient(**args):
|
||||
return DrawElement(qname = (SVGNS,'linearGradient'), **args)
|
||||
|
||||
def Radialgradient(**args):
|
||||
return DrawElement(qname = (SVGNS,'radialGradient'), **args)
|
||||
|
||||
def Stop(**args):
|
||||
return Element(qname = (SVGNS,'stop'), **args)
|
||||
|
||||
def Title(**args):
|
||||
return Element(qname = (SVGNS,'title'), **args)
|
||||
@@ -0,0 +1,307 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import TABLENS
|
||||
from element import Element
|
||||
|
||||
|
||||
# Autogenerated
|
||||
def Body(**args):
|
||||
return Element(qname = (TABLENS,'body'), **args)
|
||||
|
||||
def CalculationSettings(**args):
|
||||
return Element(qname = (TABLENS,'calculation-settings'), **args)
|
||||
|
||||
def CellAddress(**args):
|
||||
return Element(qname = (TABLENS,'cell-address'), **args)
|
||||
|
||||
def CellContentChange(**args):
|
||||
return Element(qname = (TABLENS,'cell-content-change'), **args)
|
||||
|
||||
def CellContentDeletion(**args):
|
||||
return Element(qname = (TABLENS,'cell-content-deletion'), **args)
|
||||
|
||||
def CellRangeSource(**args):
|
||||
return Element(qname = (TABLENS,'cell-range-source'), **args)
|
||||
|
||||
def ChangeDeletion(**args):
|
||||
return Element(qname = (TABLENS,'change-deletion'), **args)
|
||||
|
||||
def ChangeTrackTableCell(**args):
|
||||
return Element(qname = (TABLENS,'change-track-table-cell'), **args)
|
||||
|
||||
def Consolidation(**args):
|
||||
return Element(qname = (TABLENS,'consolidation'), **args)
|
||||
|
||||
def ContentValidation(**args):
|
||||
return Element(qname = (TABLENS,'content-validation'), **args)
|
||||
|
||||
def ContentValidations(**args):
|
||||
return Element(qname = (TABLENS,'content-validations'), **args)
|
||||
|
||||
def CoveredTableCell(**args):
|
||||
return Element(qname = (TABLENS,'covered-table-cell'), **args)
|
||||
|
||||
def CutOffs(**args):
|
||||
return Element(qname = (TABLENS,'cut-offs'), **args)
|
||||
|
||||
def DataPilotDisplayInfo(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-display-info'), **args)
|
||||
|
||||
def DataPilotField(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-field'), **args)
|
||||
|
||||
def DataPilotFieldReference(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-field-reference'), **args)
|
||||
|
||||
def DataPilotGroup(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-group'), **args)
|
||||
|
||||
def DataPilotGroupMember(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-group-member'), **args)
|
||||
|
||||
def DataPilotGroups(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-groups'), **args)
|
||||
|
||||
def DataPilotLayoutInfo(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-layout-info'), **args)
|
||||
|
||||
def DataPilotLevel(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-level'), **args)
|
||||
|
||||
def DataPilotMember(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-member'), **args)
|
||||
|
||||
def DataPilotMembers(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-members'), **args)
|
||||
|
||||
def DataPilotSortInfo(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-sort-info'), **args)
|
||||
|
||||
def DataPilotSubtotal(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-subtotal'), **args)
|
||||
|
||||
def DataPilotSubtotals(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-subtotals'), **args)
|
||||
|
||||
def DataPilotTable(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-table'), **args)
|
||||
|
||||
def DataPilotTables(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-tables'), **args)
|
||||
|
||||
def DatabaseRange(**args):
|
||||
return Element(qname = (TABLENS,'database-range'), **args)
|
||||
|
||||
def DatabaseRanges(**args):
|
||||
return Element(qname = (TABLENS,'database-ranges'), **args)
|
||||
|
||||
def DatabaseSourceQuery(**args):
|
||||
return Element(qname = (TABLENS,'database-source-query'), **args)
|
||||
|
||||
def DatabaseSourceSql(**args):
|
||||
return Element(qname = (TABLENS,'database-source-sql'), **args)
|
||||
|
||||
def DatabaseSourceTable(**args):
|
||||
return Element(qname = (TABLENS,'database-source-table'), **args)
|
||||
|
||||
def DdeLink(**args):
|
||||
return Element(qname = (TABLENS,'dde-link'), **args)
|
||||
|
||||
def DdeLinks(**args):
|
||||
return Element(qname = (TABLENS,'dde-links'), **args)
|
||||
|
||||
def Deletion(**args):
|
||||
return Element(qname = (TABLENS,'deletion'), **args)
|
||||
|
||||
def Deletions(**args):
|
||||
return Element(qname = (TABLENS,'deletions'), **args)
|
||||
|
||||
def Dependencies(**args):
|
||||
return Element(qname = (TABLENS,'dependencies'), **args)
|
||||
|
||||
def Dependency(**args):
|
||||
return Element(qname = (TABLENS,'dependency'), **args)
|
||||
|
||||
def Detective(**args):
|
||||
return Element(qname = (TABLENS,'detective'), **args)
|
||||
|
||||
def ErrorMacro(**args):
|
||||
return Element(qname = (TABLENS,'error-macro'), **args)
|
||||
|
||||
def ErrorMessage(**args):
|
||||
return Element(qname = (TABLENS,'error-message'), **args)
|
||||
|
||||
def EvenColumns(**args):
|
||||
return Element(qname = (TABLENS,'even-columns'), **args)
|
||||
|
||||
def EvenRows(**args):
|
||||
return Element(qname = (TABLENS,'even-rows'), **args)
|
||||
|
||||
def Filter(**args):
|
||||
return Element(qname = (TABLENS,'filter'), **args)
|
||||
|
||||
def FilterAnd(**args):
|
||||
return Element(qname = (TABLENS,'filter-and'), **args)
|
||||
|
||||
def FilterCondition(**args):
|
||||
return Element(qname = (TABLENS,'filter-condition'), **args)
|
||||
|
||||
def FilterOr(**args):
|
||||
return Element(qname = (TABLENS,'filter-or'), **args)
|
||||
|
||||
def FirstColumn(**args):
|
||||
return Element(qname = (TABLENS,'first-column'), **args)
|
||||
|
||||
def FirstRow(**args):
|
||||
return Element(qname = (TABLENS,'first-row'), **args)
|
||||
|
||||
def HelpMessage(**args):
|
||||
return Element(qname = (TABLENS,'help-message'), **args)
|
||||
|
||||
def HighlightedRange(**args):
|
||||
return Element(qname = (TABLENS,'highlighted-range'), **args)
|
||||
|
||||
def Insertion(**args):
|
||||
return Element(qname = (TABLENS,'insertion'), **args)
|
||||
|
||||
def InsertionCutOff(**args):
|
||||
return Element(qname = (TABLENS,'insertion-cut-off'), **args)
|
||||
|
||||
def Iteration(**args):
|
||||
return Element(qname = (TABLENS,'iteration'), **args)
|
||||
|
||||
def LabelRange(**args):
|
||||
return Element(qname = (TABLENS,'label-range'), **args)
|
||||
|
||||
def LabelRanges(**args):
|
||||
return Element(qname = (TABLENS,'label-ranges'), **args)
|
||||
|
||||
def LastColumn(**args):
|
||||
return Element(qname = (TABLENS,'last-column'), **args)
|
||||
|
||||
def LastRow(**args):
|
||||
return Element(qname = (TABLENS,'last-row'), **args)
|
||||
|
||||
def Movement(**args):
|
||||
return Element(qname = (TABLENS,'movement'), **args)
|
||||
|
||||
def MovementCutOff(**args):
|
||||
return Element(qname = (TABLENS,'movement-cut-off'), **args)
|
||||
|
||||
def NamedExpression(**args):
|
||||
return Element(qname = (TABLENS,'named-expression'), **args)
|
||||
|
||||
def NamedExpressions(**args):
|
||||
return Element(qname = (TABLENS,'named-expressions'), **args)
|
||||
|
||||
def NamedRange(**args):
|
||||
return Element(qname = (TABLENS,'named-range'), **args)
|
||||
|
||||
def NullDate(**args):
|
||||
return Element(qname = (TABLENS,'null-date'), **args)
|
||||
|
||||
def OddColumns(**args):
|
||||
return Element(qname = (TABLENS,'odd-columns'), **args)
|
||||
|
||||
def OddRows(**args):
|
||||
return Element(qname = (TABLENS,'odd-rows'), **args)
|
||||
|
||||
def Operation(**args):
|
||||
return Element(qname = (TABLENS,'operation'), **args)
|
||||
|
||||
def Previous(**args):
|
||||
return Element(qname = (TABLENS,'previous'), **args)
|
||||
|
||||
def Scenario(**args):
|
||||
return Element(qname = (TABLENS,'scenario'), **args)
|
||||
|
||||
def Shapes(**args):
|
||||
return Element(qname = (TABLENS,'shapes'), **args)
|
||||
|
||||
def Sort(**args):
|
||||
return Element(qname = (TABLENS,'sort'), **args)
|
||||
|
||||
def SortBy(**args):
|
||||
return Element(qname = (TABLENS,'sort-by'), **args)
|
||||
|
||||
def SortGroups(**args):
|
||||
return Element(qname = (TABLENS,'sort-groups'), **args)
|
||||
|
||||
def SourceCellRange(**args):
|
||||
return Element(qname = (TABLENS,'source-cell-range'), **args)
|
||||
|
||||
def SourceRangeAddress(**args):
|
||||
return Element(qname = (TABLENS,'source-range-address'), **args)
|
||||
|
||||
def SourceService(**args):
|
||||
return Element(qname = (TABLENS,'source-service'), **args)
|
||||
|
||||
def SubtotalField(**args):
|
||||
return Element(qname = (TABLENS,'subtotal-field'), **args)
|
||||
|
||||
def SubtotalRule(**args):
|
||||
return Element(qname = (TABLENS,'subtotal-rule'), **args)
|
||||
|
||||
def SubtotalRules(**args):
|
||||
return Element(qname = (TABLENS,'subtotal-rules'), **args)
|
||||
|
||||
def Table(**args):
|
||||
return Element(qname = (TABLENS,'table'), **args)
|
||||
|
||||
def TableCell(**args):
|
||||
return Element(qname = (TABLENS,'table-cell'), **args)
|
||||
|
||||
def TableColumn(**args):
|
||||
return Element(qname = (TABLENS,'table-column'), **args)
|
||||
|
||||
def TableColumnGroup(**args):
|
||||
return Element(qname = (TABLENS,'table-column-group'), **args)
|
||||
|
||||
def TableColumns(**args):
|
||||
return Element(qname = (TABLENS,'table-columns'), **args)
|
||||
|
||||
def TableHeaderColumns(**args):
|
||||
return Element(qname = (TABLENS,'table-header-columns'), **args)
|
||||
|
||||
def TableHeaderRows(**args):
|
||||
return Element(qname = (TABLENS,'table-header-rows'), **args)
|
||||
|
||||
def TableRow(**args):
|
||||
return Element(qname = (TABLENS,'table-row'), **args)
|
||||
|
||||
def TableRowGroup(**args):
|
||||
return Element(qname = (TABLENS,'table-row-group'), **args)
|
||||
|
||||
def TableRows(**args):
|
||||
return Element(qname = (TABLENS,'table-rows'), **args)
|
||||
|
||||
def TableSource(**args):
|
||||
return Element(qname = (TABLENS,'table-source'), **args)
|
||||
|
||||
def TableTemplate(**args):
|
||||
return Element(qname = (TABLENS,'table-template'), **args)
|
||||
|
||||
def TargetRangeAddress(**args):
|
||||
return Element(qname = (TABLENS,'target-range-address'), **args)
|
||||
|
||||
def TrackedChanges(**args):
|
||||
return Element(qname = (TABLENS,'tracked-changes'), **args)
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Create and extract text from ODF, handling whitespace correctly.
|
||||
# Copyright (C) 2008 J. David Eisenberg
|
||||
#
|
||||
# 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 2 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, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
|
||||
"""
|
||||
Class for handling whitespace properly in OpenDocument.
|
||||
|
||||
While it is possible to use getTextContent() and setTextContent()
|
||||
to extract or create ODF content, these won't extract or create
|
||||
the appropriate <text:s>, <text:tab>, or <text:line-break>
|
||||
elements. This module takes care of that problem.
|
||||
"""
|
||||
|
||||
from odf.element import Node
|
||||
import odf.opendocument
|
||||
from odf.text import S,LineBreak,Tab
|
||||
|
||||
class WhitespaceText(object):
|
||||
|
||||
def __init__(self):
|
||||
self.textBuffer = []
|
||||
self.spaceCount = 0
|
||||
|
||||
def addTextToElement(self, odfElement, s):
|
||||
""" Process an input string, inserting
|
||||
<text:tab> elements for '\t',
|
||||
<text:line-break> elements for '\n', and
|
||||
<text:s> elements for runs of more than one blank.
|
||||
These will be added to the given element.
|
||||
"""
|
||||
i = 0
|
||||
ch = ' '
|
||||
|
||||
# When we encounter a tab or newline, we can immediately
|
||||
# dump any accumulated text and then emit the appropriate
|
||||
# ODF element.
|
||||
#
|
||||
# When we encounter a space, we add it to the text buffer,
|
||||
# and then collect more spaces. If there are more spaces
|
||||
# after the first one, we dump the text buffer and then
|
||||
# then emit the appropriate <text:s> element.
|
||||
|
||||
while i < len(s):
|
||||
ch = s[i]
|
||||
if ch == '\t':
|
||||
self._emitTextBuffer(odfElement)
|
||||
odfElement.addElement(Tab())
|
||||
i += 1
|
||||
elif ch == '\n':
|
||||
self._emitTextBuffer(odfElement);
|
||||
odfElement.addElement(LineBreak())
|
||||
i += 1
|
||||
elif ch == ' ':
|
||||
self.textBuffer.append(' ')
|
||||
i += 1
|
||||
self.spaceCount = 0
|
||||
while i < len(s) and (s[i] == ' '):
|
||||
self.spaceCount += 1
|
||||
i += 1
|
||||
if self.spaceCount > 0:
|
||||
self._emitTextBuffer(odfElement)
|
||||
self._emitSpaces(odfElement)
|
||||
else:
|
||||
self.textBuffer.append(ch)
|
||||
i += 1
|
||||
|
||||
self._emitTextBuffer(odfElement)
|
||||
|
||||
def _emitTextBuffer(self, odfElement):
|
||||
""" Creates a Text Node whose contents are the current textBuffer.
|
||||
Side effect: clears the text buffer.
|
||||
"""
|
||||
if len(self.textBuffer) > 0:
|
||||
odfElement.addText(''.join(self.textBuffer))
|
||||
self.textBuffer = []
|
||||
|
||||
|
||||
def _emitSpaces(self, odfElement):
|
||||
""" Creates a <text:s> element for the current spaceCount.
|
||||
Side effect: sets spaceCount back to zero
|
||||
"""
|
||||
if self.spaceCount > 0:
|
||||
spaceElement = S(c=self.spaceCount)
|
||||
odfElement.addElement(spaceElement)
|
||||
self.spaceCount = 0
|
||||
|
||||
def addTextToElement(odfElement, s):
|
||||
wst = WhitespaceText()
|
||||
wst.addTextToElement(odfElement, s)
|
||||
|
||||
def extractText(odfElement):
|
||||
""" Extract text content from an Element, with whitespace represented
|
||||
properly. Returns the text, with tabs, spaces, and newlines
|
||||
correctly evaluated. This method recursively descends through the
|
||||
children of the given element, accumulating text and "unwrapping"
|
||||
<text:s>, <text:tab>, and <text:line-break> elements along the way.
|
||||
"""
|
||||
result = [];
|
||||
|
||||
if len(odfElement.childNodes) != 0:
|
||||
for child in odfElement.childNodes:
|
||||
if child.nodeType == Node.TEXT_NODE:
|
||||
result.append(child.data)
|
||||
elif child.nodeType == Node.ELEMENT_NODE:
|
||||
subElement = child
|
||||
tagName = subElement.qname;
|
||||
if tagName == (u"urn:oasis:names:tc:opendocument:xmlns:text:1.0", u"line-break"):
|
||||
result.append("\n")
|
||||
elif tagName == (u"urn:oasis:names:tc:opendocument:xmlns:text:1.0", u"tab"):
|
||||
result.append("\t")
|
||||
elif tagName == (u"urn:oasis:names:tc:opendocument:xmlns:text:1.0", u"s"):
|
||||
c = subElement.getAttribute('c')
|
||||
if c:
|
||||
spaceCount = int(c)
|
||||
else:
|
||||
spaceCount = 1
|
||||
|
||||
result.append(" " * spaceCount)
|
||||
else:
|
||||
result.append(extractText(subElement))
|
||||
return ''.join(result)
|
||||
@@ -0,0 +1,562 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import TEXTNS
|
||||
from element import Element
|
||||
from style import StyleElement
|
||||
|
||||
# Autogenerated
|
||||
def A(**args):
|
||||
return Element(qname = (TEXTNS,'a'), **args)
|
||||
|
||||
def AlphabeticalIndex(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index'), **args)
|
||||
|
||||
def AlphabeticalIndexAutoMarkFile(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index-auto-mark-file'), **args)
|
||||
|
||||
def AlphabeticalIndexEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index-entry-template'), **args)
|
||||
|
||||
def AlphabeticalIndexMark(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index-mark'), **args)
|
||||
|
||||
def AlphabeticalIndexMarkEnd(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index-mark-end'), **args)
|
||||
|
||||
def AlphabeticalIndexMarkStart(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index-mark-start'), **args)
|
||||
|
||||
def AlphabeticalIndexSource(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index-source'), **args)
|
||||
|
||||
def AuthorInitials(**args):
|
||||
return Element(qname = (TEXTNS,'author-initials'), **args)
|
||||
|
||||
def AuthorName(**args):
|
||||
return Element(qname = (TEXTNS,'author-name'), **args)
|
||||
|
||||
def Bibliography(**args):
|
||||
return Element(qname = (TEXTNS,'bibliography'), **args)
|
||||
|
||||
def BibliographyConfiguration(**args):
|
||||
return Element(qname = (TEXTNS,'bibliography-configuration'), **args)
|
||||
|
||||
def BibliographyEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'bibliography-entry-template'), **args)
|
||||
|
||||
def BibliographyMark(**args):
|
||||
return Element(qname = (TEXTNS,'bibliography-mark'), **args)
|
||||
|
||||
def BibliographySource(**args):
|
||||
return Element(qname = (TEXTNS,'bibliography-source'), **args)
|
||||
|
||||
def Bookmark(**args):
|
||||
return Element(qname = (TEXTNS,'bookmark'), **args)
|
||||
|
||||
def BookmarkEnd(**args):
|
||||
return Element(qname = (TEXTNS,'bookmark-end'), **args)
|
||||
|
||||
def BookmarkRef(**args):
|
||||
return Element(qname = (TEXTNS,'bookmark-ref'), **args)
|
||||
|
||||
def BookmarkStart(**args):
|
||||
return Element(qname = (TEXTNS,'bookmark-start'), **args)
|
||||
|
||||
def Change(**args):
|
||||
return Element(qname = (TEXTNS,'change'), **args)
|
||||
|
||||
def ChangeEnd(**args):
|
||||
return Element(qname = (TEXTNS,'change-end'), **args)
|
||||
|
||||
def ChangeStart(**args):
|
||||
return Element(qname = (TEXTNS,'change-start'), **args)
|
||||
|
||||
def ChangedRegion(**args):
|
||||
return Element(qname = (TEXTNS,'changed-region'), **args)
|
||||
|
||||
def Chapter(**args):
|
||||
return Element(qname = (TEXTNS,'chapter'), **args)
|
||||
|
||||
def CharacterCount(**args):
|
||||
return Element(qname = (TEXTNS,'character-count'), **args)
|
||||
|
||||
def ConditionalText(**args):
|
||||
return Element(qname = (TEXTNS,'conditional-text'), **args)
|
||||
|
||||
def CreationDate(**args):
|
||||
return Element(qname = (TEXTNS,'creation-date'), **args)
|
||||
|
||||
def CreationTime(**args):
|
||||
return Element(qname = (TEXTNS,'creation-time'), **args)
|
||||
|
||||
def Creator(**args):
|
||||
return Element(qname = (TEXTNS,'creator'), **args)
|
||||
|
||||
def DatabaseDisplay(**args):
|
||||
return Element(qname = (TEXTNS,'database-display'), **args)
|
||||
|
||||
def DatabaseName(**args):
|
||||
return Element(qname = (TEXTNS,'database-name'), **args)
|
||||
|
||||
def DatabaseNext(**args):
|
||||
return Element(qname = (TEXTNS,'database-next'), **args)
|
||||
|
||||
def DatabaseRowNumber(**args):
|
||||
return Element(qname = (TEXTNS,'database-row-number'), **args)
|
||||
|
||||
def DatabaseRowSelect(**args):
|
||||
return Element(qname = (TEXTNS,'database-row-select'), **args)
|
||||
|
||||
def Date(**args):
|
||||
return Element(qname = (TEXTNS,'date'), **args)
|
||||
|
||||
def DdeConnection(**args):
|
||||
return Element(qname = (TEXTNS,'dde-connection'), **args)
|
||||
|
||||
def DdeConnectionDecl(**args):
|
||||
return Element(qname = (TEXTNS,'dde-connection-decl'), **args)
|
||||
|
||||
def DdeConnectionDecls(**args):
|
||||
return Element(qname = (TEXTNS,'dde-connection-decls'), **args)
|
||||
|
||||
def Deletion(**args):
|
||||
return Element(qname = (TEXTNS,'deletion'), **args)
|
||||
|
||||
def Description(**args):
|
||||
return Element(qname = (TEXTNS,'description'), **args)
|
||||
|
||||
def EditingCycles(**args):
|
||||
return Element(qname = (TEXTNS,'editing-cycles'), **args)
|
||||
|
||||
def EditingDuration(**args):
|
||||
return Element(qname = (TEXTNS,'editing-duration'), **args)
|
||||
|
||||
def ExecuteMacro(**args):
|
||||
return Element(qname = (TEXTNS,'execute-macro'), **args)
|
||||
|
||||
def Expression(**args):
|
||||
return Element(qname = (TEXTNS,'expression'), **args)
|
||||
|
||||
def FileName(**args):
|
||||
return Element(qname = (TEXTNS,'file-name'), **args)
|
||||
|
||||
def FormatChange(**args):
|
||||
return Element(qname = (TEXTNS,'format-change'), **args)
|
||||
|
||||
def H(**args):
|
||||
return Element(qname = (TEXTNS, 'h'), **args)
|
||||
|
||||
def HiddenParagraph(**args):
|
||||
return Element(qname = (TEXTNS,'hidden-paragraph'), **args)
|
||||
|
||||
def HiddenText(**args):
|
||||
return Element(qname = (TEXTNS,'hidden-text'), **args)
|
||||
|
||||
def IllustrationIndex(**args):
|
||||
return Element(qname = (TEXTNS,'illustration-index'), **args)
|
||||
|
||||
def IllustrationIndexEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'illustration-index-entry-template'), **args)
|
||||
|
||||
def IllustrationIndexSource(**args):
|
||||
return Element(qname = (TEXTNS,'illustration-index-source'), **args)
|
||||
|
||||
def ImageCount(**args):
|
||||
return Element(qname = (TEXTNS,'image-count'), **args)
|
||||
|
||||
def IndexBody(**args):
|
||||
return Element(qname = (TEXTNS,'index-body'), **args)
|
||||
|
||||
def IndexEntryBibliography(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-bibliography'), **args)
|
||||
|
||||
def IndexEntryChapter(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-chapter'), **args)
|
||||
|
||||
def IndexEntryLinkEnd(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-link-end'), **args)
|
||||
|
||||
def IndexEntryLinkStart(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-link-start'), **args)
|
||||
|
||||
def IndexEntryPageNumber(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-page-number'), **args)
|
||||
|
||||
def IndexEntrySpan(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-span'), **args)
|
||||
|
||||
def IndexEntryTabStop(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-tab-stop'), **args)
|
||||
|
||||
def IndexEntryText(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-text'), **args)
|
||||
|
||||
def IndexSourceStyle(**args):
|
||||
return Element(qname = (TEXTNS,'index-source-style'), **args)
|
||||
|
||||
def IndexSourceStyles(**args):
|
||||
return Element(qname = (TEXTNS,'index-source-styles'), **args)
|
||||
|
||||
def IndexTitle(**args):
|
||||
return Element(qname = (TEXTNS,'index-title'), **args)
|
||||
|
||||
def IndexTitleTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'index-title-template'), **args)
|
||||
|
||||
def InitialCreator(**args):
|
||||
return Element(qname = (TEXTNS,'initial-creator'), **args)
|
||||
|
||||
def Insertion(**args):
|
||||
return Element(qname = (TEXTNS,'insertion'), **args)
|
||||
|
||||
def Keywords(**args):
|
||||
return Element(qname = (TEXTNS,'keywords'), **args)
|
||||
|
||||
def LineBreak(**args):
|
||||
return Element(qname = (TEXTNS,'line-break'), **args)
|
||||
|
||||
def LinenumberingConfiguration(**args):
|
||||
return Element(qname = (TEXTNS,'linenumbering-configuration'), **args)
|
||||
|
||||
def LinenumberingSeparator(**args):
|
||||
return Element(qname = (TEXTNS,'linenumbering-separator'), **args)
|
||||
|
||||
def List(**args):
|
||||
return Element(qname = (TEXTNS,'list'), **args)
|
||||
|
||||
def ListHeader(**args):
|
||||
return Element(qname = (TEXTNS,'list-header'), **args)
|
||||
|
||||
def ListItem(**args):
|
||||
return Element(qname = (TEXTNS,'list-item'), **args)
|
||||
|
||||
def ListLevelStyleBullet(**args):
|
||||
return Element(qname = (TEXTNS,'list-level-style-bullet'), **args)
|
||||
|
||||
def ListLevelStyleImage(**args):
|
||||
return Element(qname = (TEXTNS,'list-level-style-image'), **args)
|
||||
|
||||
def ListLevelStyleNumber(**args):
|
||||
return Element(qname = (TEXTNS,'list-level-style-number'), **args)
|
||||
|
||||
def ListStyle(**args):
|
||||
return StyleElement(qname = (TEXTNS,'list-style'), **args)
|
||||
|
||||
def Measure(**args):
|
||||
return Element(qname = (TEXTNS,'measure'), **args)
|
||||
|
||||
def ModificationDate(**args):
|
||||
return Element(qname = (TEXTNS,'modification-date'), **args)
|
||||
|
||||
def ModificationTime(**args):
|
||||
return Element(qname = (TEXTNS,'modification-time'), **args)
|
||||
|
||||
def Note(**args):
|
||||
return Element(qname = (TEXTNS,'note'), **args)
|
||||
|
||||
def NoteBody(**args):
|
||||
return Element(qname = (TEXTNS,'note-body'), **args)
|
||||
|
||||
def NoteCitation(**args):
|
||||
return Element(qname = (TEXTNS,'note-citation'), **args)
|
||||
|
||||
def NoteContinuationNoticeBackward(**args):
|
||||
return Element(qname = (TEXTNS,'note-continuation-notice-backward'), **args)
|
||||
|
||||
def NoteContinuationNoticeForward(**args):
|
||||
return Element(qname = (TEXTNS,'note-continuation-notice-forward'), **args)
|
||||
|
||||
def NoteRef(**args):
|
||||
return Element(qname = (TEXTNS,'note-ref'), **args)
|
||||
|
||||
def NotesConfiguration(**args):
|
||||
return Element(qname = (TEXTNS,'notes-configuration'), **args)
|
||||
|
||||
def Number(**args):
|
||||
return Element(qname = (TEXTNS,'number'), **args)
|
||||
|
||||
def NumberedParagraph(**args):
|
||||
return Element(qname = (TEXTNS,'numbered-paragraph'), **args)
|
||||
|
||||
def ObjectCount(**args):
|
||||
return Element(qname = (TEXTNS,'object-count'), **args)
|
||||
|
||||
def ObjectIndex(**args):
|
||||
return Element(qname = (TEXTNS,'object-index'), **args)
|
||||
|
||||
def ObjectIndexEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'object-index-entry-template'), **args)
|
||||
|
||||
def ObjectIndexSource(**args):
|
||||
return Element(qname = (TEXTNS,'object-index-source'), **args)
|
||||
|
||||
def OutlineLevelStyle(**args):
|
||||
return Element(qname = (TEXTNS,'outline-level-style'), **args)
|
||||
|
||||
def OutlineStyle(**args):
|
||||
return Element(qname = (TEXTNS,'outline-style'), **args)
|
||||
|
||||
def P(**args):
|
||||
return Element(qname = (TEXTNS, 'p'), **args)
|
||||
|
||||
def Page(**args):
|
||||
return Element(qname = (TEXTNS,'page'), **args)
|
||||
|
||||
def PageContinuation(**args):
|
||||
return Element(qname = (TEXTNS,'page-continuation'), **args)
|
||||
|
||||
def PageCount(**args):
|
||||
return Element(qname = (TEXTNS,'page-count'), **args)
|
||||
|
||||
def PageNumber(**args):
|
||||
return Element(qname = (TEXTNS,'page-number'), **args)
|
||||
|
||||
def PageSequence(**args):
|
||||
return Element(qname = (TEXTNS,'page-sequence'), **args)
|
||||
|
||||
def PageVariableGet(**args):
|
||||
return Element(qname = (TEXTNS,'page-variable-get'), **args)
|
||||
|
||||
def PageVariableSet(**args):
|
||||
return Element(qname = (TEXTNS,'page-variable-set'), **args)
|
||||
|
||||
def ParagraphCount(**args):
|
||||
return Element(qname = (TEXTNS,'paragraph-count'), **args)
|
||||
|
||||
def Placeholder(**args):
|
||||
return Element(qname = (TEXTNS,'placeholder'), **args)
|
||||
|
||||
def PrintDate(**args):
|
||||
return Element(qname = (TEXTNS,'print-date'), **args)
|
||||
|
||||
def PrintTime(**args):
|
||||
return Element(qname = (TEXTNS,'print-time'), **args)
|
||||
|
||||
def PrintedBy(**args):
|
||||
return Element(qname = (TEXTNS,'printed-by'), **args)
|
||||
|
||||
def ReferenceMark(**args):
|
||||
return Element(qname = (TEXTNS,'reference-mark'), **args)
|
||||
|
||||
def ReferenceMarkEnd(**args):
|
||||
return Element(qname = (TEXTNS,'reference-mark-end'), **args)
|
||||
|
||||
def ReferenceMarkStart(**args):
|
||||
return Element(qname = (TEXTNS,'reference-mark-start'), **args)
|
||||
|
||||
def ReferenceRef(**args):
|
||||
return Element(qname = (TEXTNS,'reference-ref'), **args)
|
||||
|
||||
def Ruby(**args):
|
||||
return Element(qname = (TEXTNS,'ruby'), **args)
|
||||
|
||||
def RubyBase(**args):
|
||||
return Element(qname = (TEXTNS,'ruby-base'), **args)
|
||||
|
||||
def RubyText(**args):
|
||||
return Element(qname = (TEXTNS,'ruby-text'), **args)
|
||||
|
||||
def S(**args):
|
||||
return Element(qname = (TEXTNS,'s'), **args)
|
||||
|
||||
def Script(**args):
|
||||
return Element(qname = (TEXTNS,'script'), **args)
|
||||
|
||||
def Section(**args):
|
||||
return Element(qname = (TEXTNS,'section'), **args)
|
||||
|
||||
def SectionSource(**args):
|
||||
return Element(qname = (TEXTNS,'section-source'), **args)
|
||||
|
||||
def SenderCity(**args):
|
||||
return Element(qname = (TEXTNS,'sender-city'), **args)
|
||||
|
||||
def SenderCompany(**args):
|
||||
return Element(qname = (TEXTNS,'sender-company'), **args)
|
||||
|
||||
def SenderCountry(**args):
|
||||
return Element(qname = (TEXTNS,'sender-country'), **args)
|
||||
|
||||
def SenderEmail(**args):
|
||||
return Element(qname = (TEXTNS,'sender-email'), **args)
|
||||
|
||||
def SenderFax(**args):
|
||||
return Element(qname = (TEXTNS,'sender-fax'), **args)
|
||||
|
||||
def SenderFirstname(**args):
|
||||
return Element(qname = (TEXTNS,'sender-firstname'), **args)
|
||||
|
||||
def SenderInitials(**args):
|
||||
return Element(qname = (TEXTNS,'sender-initials'), **args)
|
||||
|
||||
def SenderLastname(**args):
|
||||
return Element(qname = (TEXTNS,'sender-lastname'), **args)
|
||||
|
||||
def SenderPhonePrivate(**args):
|
||||
return Element(qname = (TEXTNS,'sender-phone-private'), **args)
|
||||
|
||||
def SenderPhoneWork(**args):
|
||||
return Element(qname = (TEXTNS,'sender-phone-work'), **args)
|
||||
|
||||
def SenderPosition(**args):
|
||||
return Element(qname = (TEXTNS,'sender-position'), **args)
|
||||
|
||||
def SenderPostalCode(**args):
|
||||
return Element(qname = (TEXTNS,'sender-postal-code'), **args)
|
||||
|
||||
def SenderStateOrProvince(**args):
|
||||
return Element(qname = (TEXTNS,'sender-state-or-province'), **args)
|
||||
|
||||
def SenderStreet(**args):
|
||||
return Element(qname = (TEXTNS,'sender-street'), **args)
|
||||
|
||||
def SenderTitle(**args):
|
||||
return Element(qname = (TEXTNS,'sender-title'), **args)
|
||||
|
||||
def Sequence(**args):
|
||||
return Element(qname = (TEXTNS,'sequence'), **args)
|
||||
|
||||
def SequenceDecl(**args):
|
||||
return Element(qname = (TEXTNS,'sequence-decl'), **args)
|
||||
|
||||
def SequenceDecls(**args):
|
||||
return Element(qname = (TEXTNS,'sequence-decls'), **args)
|
||||
|
||||
def SequenceRef(**args):
|
||||
return Element(qname = (TEXTNS,'sequence-ref'), **args)
|
||||
|
||||
def SheetName(**args):
|
||||
return Element(qname = (TEXTNS,'sheet-name'), **args)
|
||||
|
||||
def SoftPageBreak(**args):
|
||||
return Element(qname = (TEXTNS,'soft-page-break'), **args)
|
||||
|
||||
def SortKey(**args):
|
||||
return Element(qname = (TEXTNS,'sort-key'), **args)
|
||||
|
||||
def Span(**args):
|
||||
return Element(qname = (TEXTNS,'span'), **args)
|
||||
|
||||
def Subject(**args):
|
||||
return Element(qname = (TEXTNS,'subject'), **args)
|
||||
|
||||
def Tab(**args):
|
||||
return Element(qname = (TEXTNS,'tab'), **args)
|
||||
|
||||
def TableCount(**args):
|
||||
return Element(qname = (TEXTNS,'table-count'), **args)
|
||||
|
||||
def TableFormula(**args):
|
||||
return Element(qname = (TEXTNS,'table-formula'), **args)
|
||||
|
||||
def TableIndex(**args):
|
||||
return Element(qname = (TEXTNS,'table-index'), **args)
|
||||
|
||||
def TableIndexEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'table-index-entry-template'), **args)
|
||||
|
||||
def TableIndexSource(**args):
|
||||
return Element(qname = (TEXTNS,'table-index-source'), **args)
|
||||
|
||||
def TableOfContent(**args):
|
||||
return Element(qname = (TEXTNS,'table-of-content'), **args)
|
||||
|
||||
def TableOfContentEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'table-of-content-entry-template'), **args)
|
||||
|
||||
def TableOfContentSource(**args):
|
||||
return Element(qname = (TEXTNS,'table-of-content-source'), **args)
|
||||
|
||||
def TemplateName(**args):
|
||||
return Element(qname = (TEXTNS,'template-name'), **args)
|
||||
|
||||
def TextInput(**args):
|
||||
return Element(qname = (TEXTNS,'text-input'), **args)
|
||||
|
||||
def Time(**args):
|
||||
return Element(qname = (TEXTNS,'time'), **args)
|
||||
|
||||
def Title(**args):
|
||||
return Element(qname = (TEXTNS,'title'), **args)
|
||||
|
||||
def TocMark(**args):
|
||||
return Element(qname = (TEXTNS,'toc-mark'), **args)
|
||||
|
||||
def TocMarkEnd(**args):
|
||||
return Element(qname = (TEXTNS,'toc-mark-end'), **args)
|
||||
|
||||
def TocMarkStart(**args):
|
||||
return Element(qname = (TEXTNS,'toc-mark-start'), **args)
|
||||
|
||||
def TrackedChanges(**args):
|
||||
return Element(qname = (TEXTNS,'tracked-changes'), **args)
|
||||
|
||||
def UserDefined(**args):
|
||||
return Element(qname = (TEXTNS,'user-defined'), **args)
|
||||
|
||||
def UserFieldDecl(**args):
|
||||
return Element(qname = (TEXTNS,'user-field-decl'), **args)
|
||||
|
||||
def UserFieldDecls(**args):
|
||||
return Element(qname = (TEXTNS,'user-field-decls'), **args)
|
||||
|
||||
def UserFieldGet(**args):
|
||||
return Element(qname = (TEXTNS,'user-field-get'), **args)
|
||||
|
||||
def UserFieldInput(**args):
|
||||
return Element(qname = (TEXTNS,'user-field-input'), **args)
|
||||
|
||||
def UserIndex(**args):
|
||||
return Element(qname = (TEXTNS,'user-index'), **args)
|
||||
|
||||
def UserIndexEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'user-index-entry-template'), **args)
|
||||
|
||||
def UserIndexMark(**args):
|
||||
return Element(qname = (TEXTNS,'user-index-mark'), **args)
|
||||
|
||||
def UserIndexMarkEnd(**args):
|
||||
return Element(qname = (TEXTNS,'user-index-mark-end'), **args)
|
||||
|
||||
def UserIndexMarkStart(**args):
|
||||
return Element(qname = (TEXTNS,'user-index-mark-start'), **args)
|
||||
|
||||
def UserIndexSource(**args):
|
||||
return Element(qname = (TEXTNS,'user-index-source'), **args)
|
||||
|
||||
def VariableDecl(**args):
|
||||
return Element(qname = (TEXTNS,'variable-decl'), **args)
|
||||
|
||||
def VariableDecls(**args):
|
||||
return Element(qname = (TEXTNS,'variable-decls'), **args)
|
||||
|
||||
def VariableGet(**args):
|
||||
return Element(qname = (TEXTNS,'variable-get'), **args)
|
||||
|
||||
def VariableInput(**args):
|
||||
return Element(qname = (TEXTNS,'variable-input'), **args)
|
||||
|
||||
def VariableSet(**args):
|
||||
return Element(qname = (TEXTNS,'variable-set'), **args)
|
||||
|
||||
def WordCount(**args):
|
||||
return Element(qname = (TEXTNS,'word-count'), **args)
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# This contains a 128x128 px thumbnail in PNG format
|
||||
# Taken from http://www.zwahlendesign.ch/en/node/20
|
||||
# openoffice_icons/openoffice_icons_linux/openoffice11.png
|
||||
# License: Freeware
|
||||
import base64
|
||||
|
||||
iconstr = """\
|
||||
iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAAG0OVFdAAAABGdBTUEAANbY1E9YMgAAABl0RVh0
|
||||
U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAFoHSURBVHjaYvz//z8DJQAggFhu3LiBU1JI
|
||||
SOiPmJgYM7IYUD0jMh8ggFhAhKamJuOHDx/+8fPz4zQsMTGRYf78+RjiAAHEBCJOnTr1HZvmN2/e
|
||||
MDAyQiycOXMmw5MnTxhmzZoViqwGIIAYrl+/DqKM/6OBNWvWgOmvX7/+37Rp0/8jR478//fv3/+f
|
||||
P3/+h+phPHHixH+AAIK75D8WMGnSpP8vXrz4//v37/9///6Fi4MMALruf3Bw8H+AAAJp5rQrOoeh
|
||||
edmyZWAbgd77f/bsWTAbBoB6JOpbmkF0OkAAgcLgO8gUYCCCnSIlJQWmw8LCGA4cOAAOAyMjI3hY
|
||||
gMDvP7+f3791+weQuQAggGBi7FPmrvnf3NwMtgnkt/Xr1//fuXMn2EaQ5TB89+nX/wUlJSDbPUFe
|
||||
AQgguKleiY2/QIpBTv727TuKJhB+//nf/xtP/4ANrK6tBRnAATIAIICQEwUjUCHIoyjOBYGbz/8y
|
||||
8HMwMXCzfmcoLC1kMDH3YNDU1mGQ4PvLCBBALEjq/t958Zfh0dt/DL/+MDD8BdkBNIeXnYFBhIeR
|
||||
4efffwybNqxgEOEXZLjw25Xh2QMWhmi9BwwAAYRsAMO5268ZZMREGGSEGBmYgcEL1MMAcgwo3D9/
|
||||
+sIwf84cBhHLGoYAVVYGxi/3wDYABBCKU6dPn37s1vM//3/+/v//20+gn5/9+b/7yq//iw++/6+o
|
||||
qAhy0zUg1gH5HYYBAgg99Srsvvzz//6Tt//beSf+V/doBGkqheaFL0CKF1kzCAMEECOWfAMSY3Yq
|
||||
PvF7X68FKCcCPcLAA8QqQHwB3VaAAGKktDwACCCc5QETE5ODjIz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amGAN0p/Q
|
||||
CGeAjdwhVVv/GQb3GhacACCAWIbY1bGwCKEL0NTU/A+1jxGaABiRIvs/NEcP6du0AAIMANtMxR3x
|
||||
N38FAAAAAElFTkSuQmCC\
|
||||
"""
|
||||
|
||||
def thumbnail():
|
||||
icon = base64.decodestring(iconstr)
|
||||
return icon
|
||||
|
||||
if __name__ == "__main__":
|
||||
icon = thumbnail()
|
||||
f = file("thumbnail.png","wb")
|
||||
f.write(icon)
|
||||
f.close()
|
||||
@@ -0,0 +1,169 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2009 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This is free software. You may redistribute it under the terms
|
||||
# of the Apache license and the GNU General Public License Version
|
||||
# 2 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, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s): Michael Howitz, gocept gmbh & co. kg
|
||||
#
|
||||
# $Id: userfield.py 447 2008-07-10 20:01:30Z roug $
|
||||
|
||||
"""Class to show and manipulate user fields in odf documents."""
|
||||
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
from odf.text import UserFieldDecl
|
||||
from odf.namespaces import OFFICENS
|
||||
from odf.opendocument import load
|
||||
|
||||
OUTENCODING = "utf-8"
|
||||
|
||||
|
||||
# OpenDocument v.1.0 section 6.7.1
|
||||
VALUE_TYPES = {
|
||||
'float': (OFFICENS, u'value'),
|
||||
'percentage': (OFFICENS, u'value'),
|
||||
'currency': (OFFICENS, u'value'),
|
||||
'date': (OFFICENS, u'date-value'),
|
||||
'time': (OFFICENS, u'time-value'),
|
||||
'boolean': (OFFICENS, u'boolean-value'),
|
||||
'string': (OFFICENS, u'string-value'),
|
||||
}
|
||||
|
||||
|
||||
class UserFields(object):
|
||||
"""List, view and manipulate user fields."""
|
||||
|
||||
# these attributes can be a filename or a file like object
|
||||
src_file = None
|
||||
dest_file = None
|
||||
|
||||
def __init__(self, src=None, dest=None):
|
||||
"""Constructor
|
||||
|
||||
src ... source document name, file like object or None for stdin
|
||||
dest ... destination document name, file like object or None for stdout
|
||||
|
||||
"""
|
||||
self.src_file = src
|
||||
self.dest_file = dest
|
||||
self.document = None
|
||||
|
||||
def loaddoc(self):
|
||||
if isinstance(self.src_file, basestring):
|
||||
# src_file is a filename, check if it is a zip-file
|
||||
if not zipfile.is_zipfile(self.src_file):
|
||||
raise TypeError("%s is no odt file." % self.src_file)
|
||||
elif self.src_file is None:
|
||||
# use stdin if no file given
|
||||
self.src_file = sys.stdin
|
||||
|
||||
self.document = load(self.src_file)
|
||||
|
||||
def savedoc(self):
|
||||
# write output
|
||||
if self.dest_file is None:
|
||||
# use stdout if no filename given
|
||||
self.document.save('-')
|
||||
else:
|
||||
self.document.save(self.dest_file)
|
||||
|
||||
def list_fields(self):
|
||||
"""List (extract) all known user-fields.
|
||||
|
||||
Returns list of user-field names.
|
||||
|
||||
"""
|
||||
return [x[0] for x in self.list_fields_and_values()]
|
||||
|
||||
def list_fields_and_values(self, field_names=None):
|
||||
"""List (extract) user-fields with type and value.
|
||||
|
||||
field_names ... list of field names to show or None for all.
|
||||
|
||||
Returns list of tuples (<field name>, <field type>, <value>).
|
||||
|
||||
"""
|
||||
self.loaddoc()
|
||||
found_fields = []
|
||||
all_fields = self.document.getElementsByType(UserFieldDecl)
|
||||
for f in all_fields:
|
||||
value_type = f.getAttribute('valuetype')
|
||||
if value_type == 'string':
|
||||
value = f.getAttribute('stringvalue')
|
||||
else:
|
||||
value = f.getAttribute('value')
|
||||
field_name = f.getAttribute('name')
|
||||
|
||||
if field_names is None or field_name in field_names:
|
||||
found_fields.append((field_name.encode(OUTENCODING),
|
||||
value_type.encode(OUTENCODING),
|
||||
value.encode(OUTENCODING)))
|
||||
return found_fields
|
||||
|
||||
def list_values(self, field_names):
|
||||
"""Extract the contents of given field names from the file.
|
||||
|
||||
field_names ... list of field names
|
||||
|
||||
Returns list of field values.
|
||||
|
||||
"""
|
||||
return [x[2] for x in self.list_fields_and_values(field_names)]
|
||||
|
||||
def get(self, field_name):
|
||||
"""Extract the contents of this field from the file.
|
||||
|
||||
Returns field value or None if field does not exist.
|
||||
|
||||
"""
|
||||
values = self.list_values([field_name])
|
||||
if not values:
|
||||
return None
|
||||
return values[0]
|
||||
|
||||
def get_type_and_value(self, field_name):
|
||||
"""Extract the type and contents of this field from the file.
|
||||
|
||||
Returns tuple (<type>, <field-value>) or None if field does not exist.
|
||||
|
||||
"""
|
||||
fields = self.list_fields_and_values([field_name])
|
||||
if not fields:
|
||||
return None
|
||||
field_name, value_type, value = fields[0]
|
||||
return value_type, value
|
||||
|
||||
def update(self, data):
|
||||
"""Set the value of user fields. The field types will be the same.
|
||||
|
||||
data ... dict, with field name as key, field value as value
|
||||
|
||||
Returns None
|
||||
|
||||
"""
|
||||
self.loaddoc()
|
||||
all_fields = self.document.getElementsByType(UserFieldDecl)
|
||||
for f in all_fields:
|
||||
field_name = f.getAttribute('name')
|
||||
if data.has_key(field_name):
|
||||
value_type = f.getAttribute('valuetype')
|
||||
value = data.get(field_name)
|
||||
if value_type == 'string':
|
||||
f.setAttribute('stringvalue', value)
|
||||
else:
|
||||
f.setAttribute('value', value)
|
||||
self.savedoc()
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from namespaces import XFORMSNS
|
||||
from element import Element
|
||||
|
||||
# ODF 1.0 section 11.2
|
||||
# XForms is designed to be embedded in another XML format.
|
||||
# Autogenerated
|
||||
def Model(**args):
|
||||
return Element(qname = (XFORMSNS,'model'), **args)
|
||||
|
||||
def Instance(**args):
|
||||
return Element(qname = (XFORMSNS,'instance'), **args)
|
||||
|
||||
def Bind(**args):
|
||||
return Element(qname = (XFORMSNS,'bind'), **args)
|
||||
@@ -0,0 +1,61 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import ANIMNS
|
||||
from .element import Element
|
||||
|
||||
|
||||
# Autogenerated
|
||||
def Animate(**args):
|
||||
return Element(qname = (ANIMNS,'animate'), **args)
|
||||
|
||||
def Animatecolor(**args):
|
||||
return Element(qname = (ANIMNS,'animateColor'), **args)
|
||||
|
||||
def Animatemotion(**args):
|
||||
return Element(qname = (ANIMNS,'animateMotion'), **args)
|
||||
|
||||
def Animatetransform(**args):
|
||||
return Element(qname = (ANIMNS,'animateTransform'), **args)
|
||||
|
||||
def Audio(**args):
|
||||
return Element(qname = (ANIMNS,'audio'), **args)
|
||||
|
||||
def Command(**args):
|
||||
return Element(qname = (ANIMNS,'command'), **args)
|
||||
|
||||
def Iterate(**args):
|
||||
return Element(qname = (ANIMNS,'iterate'), **args)
|
||||
|
||||
def Par(**args):
|
||||
return Element(qname = (ANIMNS,'par'), **args)
|
||||
|
||||
def Param(**args):
|
||||
return Element(qname = (ANIMNS,'param'), **args)
|
||||
|
||||
def Seq(**args):
|
||||
return Element(qname = (ANIMNS,'seq'), **args)
|
||||
|
||||
def Set(**args):
|
||||
return Element(qname = (ANIMNS,'set'), **args)
|
||||
|
||||
def Transitionfilter(**args):
|
||||
return Element(qname = (ANIMNS,'transitionFilter'), **args)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,87 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import CHARTNS
|
||||
from .element import Element
|
||||
|
||||
# Autogenerated
|
||||
def Axis(**args):
|
||||
return Element(qname = (CHARTNS,'axis'), **args)
|
||||
|
||||
def Categories(**args):
|
||||
return Element(qname = (CHARTNS,'categories'), **args)
|
||||
|
||||
def Chart(**args):
|
||||
return Element(qname = (CHARTNS,'chart'), **args)
|
||||
|
||||
def DataPoint(**args):
|
||||
return Element(qname = (CHARTNS,'data-point'), **args)
|
||||
|
||||
def Domain(**args):
|
||||
return Element(qname = (CHARTNS,'domain'), **args)
|
||||
|
||||
def ErrorIndicator(**args):
|
||||
return Element(qname = (CHARTNS,'error-indicator'), **args)
|
||||
|
||||
def Floor(**args):
|
||||
return Element(qname = (CHARTNS,'floor'), **args)
|
||||
|
||||
def Footer(**args):
|
||||
return Element(qname = (CHARTNS,'footer'), **args)
|
||||
|
||||
def Grid(**args):
|
||||
return Element(qname = (CHARTNS,'grid'), **args)
|
||||
|
||||
def Legend(**args):
|
||||
return Element(qname = (CHARTNS,'legend'), **args)
|
||||
|
||||
def MeanValue(**args):
|
||||
return Element(qname = (CHARTNS,'mean-value'), **args)
|
||||
|
||||
def PlotArea(**args):
|
||||
return Element(qname = (CHARTNS,'plot-area'), **args)
|
||||
|
||||
def RegressionCurve(**args):
|
||||
return Element(qname = (CHARTNS,'regression-curve'), **args)
|
||||
|
||||
def Series(**args):
|
||||
return Element(qname = (CHARTNS,'series'), **args)
|
||||
|
||||
def StockGainMarker(**args):
|
||||
return Element(qname = (CHARTNS,'stock-gain-marker'), **args)
|
||||
|
||||
def StockLossMarker(**args):
|
||||
return Element(qname = (CHARTNS,'stock-loss-marker'), **args)
|
||||
|
||||
def StockRangeLine(**args):
|
||||
return Element(qname = (CHARTNS,'stock-range-line'), **args)
|
||||
|
||||
def Subtitle(**args):
|
||||
return Element(qname = (CHARTNS,'subtitle'), **args)
|
||||
|
||||
def SymbolImage(**args):
|
||||
return Element(qname = (CHARTNS,'symbol-image'), **args)
|
||||
|
||||
def Title(**args):
|
||||
return Element(qname = (CHARTNS,'title'), **args)
|
||||
|
||||
def Wall(**args):
|
||||
return Element(qname = (CHARTNS,'wall'), **args)
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import CONFIGNS
|
||||
from .element import Element
|
||||
|
||||
# Autogenerated
|
||||
def ConfigItem(**args):
|
||||
return Element(qname = (CONFIGNS, 'config-item'), **args)
|
||||
|
||||
def ConfigItemMapEntry(**args):
|
||||
return Element(qname = (CONFIGNS,'config-item-map-entry'), **args)
|
||||
|
||||
def ConfigItemMapIndexed(**args):
|
||||
return Element(qname = (CONFIGNS,'config-item-map-indexed'), **args)
|
||||
|
||||
def ConfigItemMapNamed(**args):
|
||||
return Element(qname = (CONFIGNS,'config-item-map-named'), **args)
|
||||
|
||||
def ConfigItemSet(**args):
|
||||
return Element(qname = (CONFIGNS, 'config-item-set'), **args)
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import DCNS
|
||||
from .element import Element
|
||||
|
||||
# Autogenerated
|
||||
def Creator(**args):
|
||||
return Element(qname = (DCNS,'creator'), **args)
|
||||
|
||||
def Date(**args):
|
||||
return Element(qname = (DCNS,'date'), **args)
|
||||
|
||||
def Description(**args):
|
||||
return Element(qname = (DCNS,'description'), **args)
|
||||
|
||||
def Language(**args):
|
||||
return Element(qname = (DCNS,'language'), **args)
|
||||
|
||||
def Subject(**args):
|
||||
return Element(qname = (DCNS,'subject'), **args)
|
||||
|
||||
def Title(**args):
|
||||
return Element(qname = (DCNS,'title'), **args)
|
||||
|
||||
# The following complete the Dublin Core elements, but there is no
|
||||
# guarantee a compliant implementation of OpenDocument will preserve
|
||||
# these elements
|
||||
|
||||
#def Contributor(**args):
|
||||
# return Element(qname = (DCNS,'contributor'), **args)
|
||||
|
||||
#def Coverage(**args):
|
||||
# return Element(qname = (DCNS,'coverage'), **args)
|
||||
|
||||
#def Format(**args):
|
||||
# return Element(qname = (DCNS,'format'), **args)
|
||||
|
||||
#def Identifier(**args):
|
||||
# return Element(qname = (DCNS,'identifier'), **args)
|
||||
|
||||
#def Publisher(**args):
|
||||
# return Element(qname = (DCNS,'publisher'), **args)
|
||||
|
||||
#def Relation(**args):
|
||||
# return Element(qname = (DCNS,'relation'), **args)
|
||||
|
||||
#def Rights(**args):
|
||||
# return Element(qname = (DCNS,'rights'), **args)
|
||||
|
||||
#def Source(**args):
|
||||
# return Element(qname = (DCNS,'source'), **args)
|
||||
|
||||
#def Type(**args):
|
||||
# return Element(qname = (DCNS,'type'), **args)
|
||||
@@ -0,0 +1,43 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import DR3DNS
|
||||
from .element import Element
|
||||
from .draw import StyleRefElement
|
||||
|
||||
# Autogenerated
|
||||
def Cube(**args):
|
||||
return StyleRefElement(qname = (DR3DNS,'cube'), **args)
|
||||
|
||||
def Extrude(**args):
|
||||
return StyleRefElement(qname = (DR3DNS,'extrude'), **args)
|
||||
|
||||
def Light(Element):
|
||||
return StyleRefElement(qname = (DR3DNS,'light'), **args)
|
||||
|
||||
def Rotate(**args):
|
||||
return StyleRefElement(qname = (DR3DNS,'rotate'), **args)
|
||||
|
||||
def Scene(**args):
|
||||
return StyleRefElement(qname = (DR3DNS,'scene'), **args)
|
||||
|
||||
def Sphere(**args):
|
||||
return StyleRefElement(qname = (DR3DNS,'sphere'), **args)
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import DRAWNS, STYLENS, PRESENTATIONNS
|
||||
from .element import Element
|
||||
|
||||
def StyleRefElement(stylename=None, classnames=None, **args):
|
||||
qattrs = {}
|
||||
if stylename is not None:
|
||||
f = stylename.getAttrNS(STYLENS, 'family')
|
||||
if f == 'graphic':
|
||||
qattrs[(DRAWNS,'style-name')]= stylename
|
||||
elif f == 'presentation':
|
||||
qattrs[(PRESENTATIONNS,'style-name')]= stylename
|
||||
else:
|
||||
raise ValueError("Style's family must be either 'graphic' or 'presentation'")
|
||||
if classnames is not None:
|
||||
f = classnames[0].getAttrNS(STYLENS, 'family')
|
||||
if f == 'graphic':
|
||||
qattrs[(DRAWNS,'class-names')]= classnames
|
||||
elif f == 'presentation':
|
||||
qattrs[(PRESENTATIONNS,'class-names')]= classnames
|
||||
else:
|
||||
raise ValueError("Style's family must be either 'graphic' or 'presentation'")
|
||||
return Element(qattributes=qattrs, **args)
|
||||
|
||||
def DrawElement(name=None, **args):
|
||||
e = Element(name=name, **args)
|
||||
if 'displayname' not in args:
|
||||
e.setAttrNS(DRAWNS,'display-name', name)
|
||||
return e
|
||||
|
||||
# Autogenerated
|
||||
def A(**args):
|
||||
return Element(qname = (DRAWNS,'a'), **args)
|
||||
|
||||
def Applet(**args):
|
||||
return Element(qname = (DRAWNS,'applet'), **args)
|
||||
|
||||
def AreaCircle(**args):
|
||||
return Element(qname = (DRAWNS,'area-circle'), **args)
|
||||
|
||||
def AreaPolygon(**args):
|
||||
return Element(qname = (DRAWNS,'area-polygon'), **args)
|
||||
|
||||
def AreaRectangle(**args):
|
||||
return Element(qname = (DRAWNS,'area-rectangle'), **args)
|
||||
|
||||
def Caption(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'caption'), **args)
|
||||
|
||||
def Circle(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'circle'), **args)
|
||||
|
||||
def Connector(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'connector'), **args)
|
||||
|
||||
def ContourPath(**args):
|
||||
return Element(qname = (DRAWNS,'contour-path'), **args)
|
||||
|
||||
def ContourPolygon(**args):
|
||||
return Element(qname = (DRAWNS,'contour-polygon'), **args)
|
||||
|
||||
def Control(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'control'), **args)
|
||||
|
||||
def CustomShape(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'custom-shape'), **args)
|
||||
|
||||
def Ellipse(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'ellipse'), **args)
|
||||
|
||||
def EnhancedGeometry(**args):
|
||||
return Element(qname = (DRAWNS,'enhanced-geometry'), **args)
|
||||
|
||||
def Equation(**args):
|
||||
return Element(qname = (DRAWNS,'equation'), **args)
|
||||
|
||||
def FillImage(**args):
|
||||
return DrawElement(qname = (DRAWNS,'fill-image'), **args)
|
||||
|
||||
def FloatingFrame(**args):
|
||||
return Element(qname = (DRAWNS,'floating-frame'), **args)
|
||||
|
||||
def Frame(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'frame'), **args)
|
||||
|
||||
def G(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'g'), **args)
|
||||
|
||||
def GluePoint(**args):
|
||||
return Element(qname = (DRAWNS,'glue-point'), **args)
|
||||
|
||||
def Gradient(**args):
|
||||
return DrawElement(qname = (DRAWNS,'gradient'), **args)
|
||||
|
||||
def Handle(**args):
|
||||
return Element(qname = (DRAWNS,'handle'), **args)
|
||||
|
||||
def Hatch(**args):
|
||||
return DrawElement(qname = (DRAWNS,'hatch'), **args)
|
||||
|
||||
def Image(**args):
|
||||
return Element(qname = (DRAWNS,'image'), **args)
|
||||
|
||||
def ImageMap(**args):
|
||||
return Element(qname = (DRAWNS,'image-map'), **args)
|
||||
|
||||
def Layer(**args):
|
||||
return Element(qname = (DRAWNS,'layer'), **args)
|
||||
|
||||
def LayerSet(**args):
|
||||
return Element(qname = (DRAWNS,'layer-set'), **args)
|
||||
|
||||
def Line(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'line'), **args)
|
||||
|
||||
def Marker(**args):
|
||||
return DrawElement(qname = (DRAWNS,'marker'), **args)
|
||||
|
||||
def Measure(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'measure'), **args)
|
||||
|
||||
def Object(**args):
|
||||
return Element(qname = (DRAWNS,'object'), **args)
|
||||
|
||||
def ObjectOle(**args):
|
||||
return Element(qname = (DRAWNS,'object-ole'), **args)
|
||||
|
||||
def Opacity(**args):
|
||||
return DrawElement(qname = (DRAWNS,'opacity'), **args)
|
||||
|
||||
def Page(**args):
|
||||
return Element(qname = (DRAWNS,'page'), **args)
|
||||
|
||||
def PageThumbnail(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'page-thumbnail'), **args)
|
||||
|
||||
def Param(**args):
|
||||
return Element(qname = (DRAWNS,'param'), **args)
|
||||
|
||||
def Path(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'path'), **args)
|
||||
|
||||
def Plugin(**args):
|
||||
return Element(qname = (DRAWNS,'plugin'), **args)
|
||||
|
||||
def Polygon(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'polygon'), **args)
|
||||
|
||||
def Polyline(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'polyline'), **args)
|
||||
|
||||
def Rect(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'rect'), **args)
|
||||
|
||||
def RegularPolygon(**args):
|
||||
return StyleRefElement(qname = (DRAWNS,'regular-polygon'), **args)
|
||||
|
||||
def StrokeDash(**args):
|
||||
return DrawElement(qname = (DRAWNS,'stroke-dash'), **args)
|
||||
|
||||
def TextBox(**args):
|
||||
return Element(qname = (DRAWNS,'text-box'), **args)
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Create a <text:list-style> element from a text string.
|
||||
# Copyright (C) 2008 J. David Eisenberg
|
||||
#
|
||||
# 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 2 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, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
import re
|
||||
from .style import Style, TextProperties, ListLevelProperties
|
||||
from .text import ListStyle,ListLevelStyleNumber,ListLevelStyleBullet
|
||||
|
||||
"""
|
||||
Create a <text:list-style> element from a string or array.
|
||||
|
||||
List styles require a lot of code to create one level at a time.
|
||||
These routines take a string and delimiter, or a list of
|
||||
strings, and creates a <text:list-style> element for you.
|
||||
Each item in the string (or array) represents a list level
|
||||
* style for levels 1-10.</p>
|
||||
*
|
||||
* <p>If an item contains <code>1</code>, <code>I</code>,
|
||||
* <code>i</code>, <code>A</code>, or <code>a</code>, then it is presumed
|
||||
* to be a numbering style; otherwise it is a bulleted style.</p>
|
||||
"""
|
||||
|
||||
_MAX_LIST_LEVEL = 10
|
||||
SHOW_ALL_LEVELS = True
|
||||
SHOW_ONE_LEVEL = False
|
||||
|
||||
def styleFromString(name, specifiers, delim, spacing, showAllLevels):
|
||||
specArray = specifiers.split(delim)
|
||||
return styleFromList( name, specArray, spacing, showAllLevels )
|
||||
|
||||
def styleFromList( styleName, specArray, spacing, showAllLevels):
|
||||
bullet = ""
|
||||
numPrefix = ""
|
||||
numSuffix = ""
|
||||
numberFormat = ""
|
||||
cssLengthNum = 0
|
||||
cssLengthUnits = ""
|
||||
numbered = False
|
||||
displayLevels = 0
|
||||
listStyle = ListStyle(name=styleName)
|
||||
numFormatPattern = re.compile("([1IiAa])")
|
||||
cssLengthPattern = re.compile("([^a-z]+)\\s*([a-z]+)?")
|
||||
m = cssLengthPattern.search( spacing )
|
||||
if (m != None):
|
||||
cssLengthNum = float(m.group(1))
|
||||
if (m.lastindex == 2):
|
||||
cssLengthUnits = m.group(2)
|
||||
i = 0
|
||||
while i < len(specArray):
|
||||
specification = specArray[i]
|
||||
m = numFormatPattern.search(specification)
|
||||
if (m != None):
|
||||
numberFormat = m.group(1)
|
||||
numPrefix = specification[0:m.start(1)]
|
||||
numSuffix = specification[m.end(1):]
|
||||
bullet = ""
|
||||
numbered = True
|
||||
if (showAllLevels):
|
||||
displayLevels = i + 1
|
||||
else:
|
||||
displayLevels = 1
|
||||
else: # it's a bullet style
|
||||
bullet = specification
|
||||
numPrefix = ""
|
||||
numSuffix = ""
|
||||
numberFormat = ""
|
||||
displayLevels = 1
|
||||
numbered = False
|
||||
if (numbered):
|
||||
lls = ListLevelStyleNumber(level=(i+1))
|
||||
if (numPrefix != ''):
|
||||
lls.setAttribute('numprefix', numPrefix)
|
||||
if (numSuffix != ''):
|
||||
lls.setAttribute('numsuffix', numSuffix)
|
||||
lls.setAttribute('displaylevels', displayLevels)
|
||||
else:
|
||||
lls = ListLevelStyleBullet(level=(i+1),bulletchar=bullet[0])
|
||||
llp = ListLevelProperties()
|
||||
llp.setAttribute('spacebefore', str(cssLengthNum * (i+1)) + cssLengthUnits)
|
||||
llp.setAttribute('minlabelwidth', str(cssLengthNum) + cssLengthUnits)
|
||||
lls.addElement( llp )
|
||||
listStyle.addElement(lls)
|
||||
i += 1
|
||||
return listStyle
|
||||
|
||||
# vim: set expandtab sw=4 :
|
||||
@@ -0,0 +1,519 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2007-2010 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
# Note: This script has copied a lot of text from xml.dom.minidom.
|
||||
# Whatever license applies to that file also applies to this file.
|
||||
#
|
||||
import xml.dom
|
||||
from xml.dom.minicompat import *
|
||||
from .namespaces import nsdict
|
||||
from . import grammar
|
||||
from .attrconverters import AttrConverters
|
||||
|
||||
# The following code is pasted form xml.sax.saxutils
|
||||
# Tt makes it possible to run the code without the xml sax package installed
|
||||
# To make it possible to have <rubbish> in your text elements, it is necessary to escape the texts
|
||||
def _escape(data, entities={}):
|
||||
""" Escape &, <, and > in a string of data.
|
||||
|
||||
You can escape other strings of data by passing a dictionary as
|
||||
the optional entities parameter. The keys and values must all be
|
||||
strings; each key will be replaced with its corresponding value.
|
||||
"""
|
||||
try:
|
||||
data = data.decode('utf-8')
|
||||
except (TypeError, AttributeError):
|
||||
## Make sure our stream is a string
|
||||
## If it comes through as bytes it fails
|
||||
pass
|
||||
data = data.replace("&", "&")
|
||||
data = data.replace("<", "<")
|
||||
data = data.replace(">", ">")
|
||||
for chars, entity in list(entities.items()):
|
||||
data = data.replace(chars, entity)
|
||||
return data
|
||||
|
||||
def _quoteattr(data, entities={}):
|
||||
""" Escape and quote an attribute value.
|
||||
|
||||
Escape &, <, and > in a string of data, then quote it for use as
|
||||
an attribute value. The \" character will be escaped as well, if
|
||||
necessary.
|
||||
|
||||
You can escape other strings of data by passing a dictionary as
|
||||
the optional entities parameter. The keys and values must all be
|
||||
strings; each key will be replaced with its corresponding value.
|
||||
"""
|
||||
entities['\n']=' '
|
||||
entities['\r']=''
|
||||
data = _escape(data, entities)
|
||||
if '"' in data:
|
||||
if "'" in data:
|
||||
data = '"%s"' % data.replace('"', """)
|
||||
else:
|
||||
data = "'%s'" % data
|
||||
else:
|
||||
data = '"%s"' % data
|
||||
return data
|
||||
|
||||
def _nssplit(qualifiedName):
|
||||
""" Split a qualified name into namespace part and local part. """
|
||||
fields = qualifiedName.split(':', 1)
|
||||
if len(fields) == 2:
|
||||
return fields
|
||||
else:
|
||||
return (None, fields[0])
|
||||
|
||||
def _nsassign(namespace):
|
||||
return nsdict.setdefault(namespace,"ns" + str(len(nsdict)))
|
||||
|
||||
# Exceptions
|
||||
class IllegalChild(Exception):
|
||||
""" Complains if you add an element to a parent where it is not allowed """
|
||||
class IllegalText(Exception):
|
||||
""" Complains if you add text or cdata to an element where it is not allowed """
|
||||
|
||||
class Node(xml.dom.Node):
|
||||
""" super class for more specific nodes """
|
||||
parentNode = None
|
||||
nextSibling = None
|
||||
previousSibling = None
|
||||
|
||||
def hasChildNodes(self):
|
||||
""" Tells whether this element has any children; text nodes,
|
||||
subelements, whatever.
|
||||
"""
|
||||
if self.childNodes:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def _get_childNodes(self):
|
||||
return self.childNodes
|
||||
|
||||
def _get_firstChild(self):
|
||||
if self.childNodes:
|
||||
return self.childNodes[0]
|
||||
|
||||
def _get_lastChild(self):
|
||||
if self.childNodes:
|
||||
return self.childNodes[-1]
|
||||
|
||||
def insertBefore(self, newChild, refChild):
|
||||
""" Inserts the node newChild before the existing child node refChild.
|
||||
If refChild is null, insert newChild at the end of the list of children.
|
||||
"""
|
||||
if newChild.nodeType not in self._child_node_types:
|
||||
raise IllegalChild("%s cannot be child of %s" % (newChild.tagName, self.tagName))
|
||||
if newChild.parentNode is not None:
|
||||
newChild.parentNode.removeChild(newChild)
|
||||
if refChild is None:
|
||||
self.appendChild(newChild)
|
||||
else:
|
||||
try:
|
||||
index = self.childNodes.index(refChild)
|
||||
except ValueError:
|
||||
raise xml.dom.NotFoundErr()
|
||||
self.childNodes.insert(index, newChild)
|
||||
newChild.nextSibling = refChild
|
||||
refChild.previousSibling = newChild
|
||||
if index:
|
||||
node = self.childNodes[index-1]
|
||||
node.nextSibling = newChild
|
||||
newChild.previousSibling = node
|
||||
else:
|
||||
newChild.previousSibling = None
|
||||
newChild.parentNode = self
|
||||
return newChild
|
||||
|
||||
def appendChild(self, newChild):
|
||||
""" Adds the node newChild to the end of the list of children of this node.
|
||||
If the newChild is already in the tree, it is first removed.
|
||||
"""
|
||||
if newChild.nodeType == self.DOCUMENT_FRAGMENT_NODE:
|
||||
for c in tuple(newChild.childNodes):
|
||||
self.appendChild(c)
|
||||
### The DOM does not clearly specify what to return in this case
|
||||
return newChild
|
||||
if newChild.nodeType not in self._child_node_types:
|
||||
raise IllegalChild("<%s> is not allowed in %s" % ( newChild.tagName, self.tagName))
|
||||
if newChild.parentNode is not None:
|
||||
newChild.parentNode.removeChild(newChild)
|
||||
_append_child(self, newChild)
|
||||
newChild.nextSibling = None
|
||||
return newChild
|
||||
|
||||
def removeChild(self, oldChild):
|
||||
""" Removes the child node indicated by oldChild from the list of children, and returns it.
|
||||
"""
|
||||
#FIXME: update ownerDocument.element_dict or find other solution
|
||||
try:
|
||||
self.childNodes.remove(oldChild)
|
||||
except ValueError:
|
||||
raise xml.dom.NotFoundErr()
|
||||
if oldChild.nextSibling is not None:
|
||||
oldChild.nextSibling.previousSibling = oldChild.previousSibling
|
||||
if oldChild.previousSibling is not None:
|
||||
oldChild.previousSibling.nextSibling = oldChild.nextSibling
|
||||
oldChild.nextSibling = oldChild.previousSibling = None
|
||||
if self.ownerDocument:
|
||||
self.ownerDocument.clear_caches()
|
||||
oldChild.parentNode = None
|
||||
return oldChild
|
||||
|
||||
def __str__(self):
|
||||
val = []
|
||||
for c in self.childNodes:
|
||||
val.append(str(c))
|
||||
return ''.join(val)
|
||||
|
||||
def __unicode__(self):
|
||||
val = []
|
||||
for c in self.childNodes:
|
||||
val.append(str(c))
|
||||
return ''.join(val)
|
||||
|
||||
defproperty(Node, "firstChild", doc="First child node, or None.")
|
||||
defproperty(Node, "lastChild", doc="Last child node, or None.")
|
||||
|
||||
def _append_child(self, node):
|
||||
# fast path with less checks; usable by DOM builders if careful
|
||||
childNodes = self.childNodes
|
||||
if childNodes:
|
||||
last = childNodes[-1]
|
||||
node.__dict__["previousSibling"] = last
|
||||
last.__dict__["nextSibling"] = node
|
||||
childNodes.append(node)
|
||||
node.__dict__["parentNode"] = self
|
||||
|
||||
class Childless(object):
|
||||
""" Mixin that makes childless-ness easy to implement and avoids
|
||||
the complexity of the Node methods that deal with children.
|
||||
"""
|
||||
|
||||
attributes = None
|
||||
childNodes = EmptyNodeList()
|
||||
firstChild = None
|
||||
lastChild = None
|
||||
|
||||
def _get_firstChild(self):
|
||||
return None
|
||||
|
||||
def _get_lastChild(self):
|
||||
return None
|
||||
|
||||
def appendChild(self, node):
|
||||
""" Raises an error """
|
||||
raise xml.dom.HierarchyRequestErr(
|
||||
self.tagName + " nodes cannot have children")
|
||||
|
||||
def hasChildNodes(self):
|
||||
return False
|
||||
|
||||
def insertBefore(self, newChild, refChild):
|
||||
""" Raises an error """
|
||||
raise xml.dom.HierarchyRequestErr(
|
||||
self.tagName + " nodes do not have children")
|
||||
|
||||
def removeChild(self, oldChild):
|
||||
""" Raises an error """
|
||||
raise xml.dom.NotFoundErr(
|
||||
self.tagName + " nodes do not have children")
|
||||
|
||||
def replaceChild(self, newChild, oldChild):
|
||||
""" Raises an error """
|
||||
raise xml.dom.HierarchyRequestErr(
|
||||
self.tagName + " nodes do not have children")
|
||||
|
||||
class Text(Childless, Node):
|
||||
nodeType = Node.TEXT_NODE
|
||||
tagName = "Text"
|
||||
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
def __str__(self):
|
||||
return self.data.encode()
|
||||
|
||||
def __unicode__(self):
|
||||
return self.data
|
||||
|
||||
def toXml(self,level,f):
|
||||
""" Write XML in UTF-8 """
|
||||
if self.data:
|
||||
f.write(_escape(str(self.data).encode('utf-8')))
|
||||
|
||||
class CDATASection(Text, Childless):
|
||||
nodeType = Node.CDATA_SECTION_NODE
|
||||
|
||||
def toXml(self,level,f):
|
||||
""" Generate XML output of the node. If the text contains "]]>", then
|
||||
escape it by going out of CDATA mode (]]>), then write the string
|
||||
and then go into CDATA mode again. (<![CDATA[)
|
||||
"""
|
||||
if self.data:
|
||||
f.write('<![CDATA[%s]]>' % self.data.replace(']]>',']]>]]><![CDATA['))
|
||||
|
||||
class Element(Node):
|
||||
""" Creates a arbitrary element and is intended to be subclassed not used on its own.
|
||||
This element is the base of every element it defines a class which resembles
|
||||
a xml-element. The main advantage of this kind of implementation is that you don't
|
||||
have to create a toXML method for every different object. Every element
|
||||
consists of an attribute, optional subelements, optional text and optional cdata.
|
||||
"""
|
||||
|
||||
nodeType = Node.ELEMENT_NODE
|
||||
namespaces = {} # Due to shallow copy this is a static variable
|
||||
|
||||
_child_node_types = (Node.ELEMENT_NODE,
|
||||
Node.PROCESSING_INSTRUCTION_NODE,
|
||||
Node.COMMENT_NODE,
|
||||
Node.TEXT_NODE,
|
||||
Node.CDATA_SECTION_NODE,
|
||||
Node.ENTITY_REFERENCE_NODE)
|
||||
|
||||
def __init__(self, attributes=None, text=None, cdata=None, qname=None, qattributes=None, check_grammar=True, **args):
|
||||
if qname is not None:
|
||||
self.qname = qname
|
||||
assert(hasattr(self, 'qname'))
|
||||
self.ownerDocument = None
|
||||
self.childNodes=[]
|
||||
self.allowed_children = grammar.allowed_children.get(self.qname)
|
||||
prefix = self.get_nsprefix(self.qname[0])
|
||||
self.tagName = prefix + ":" + self.qname[1]
|
||||
if text is not None:
|
||||
self.addText(text)
|
||||
if cdata is not None:
|
||||
self.addCDATA(cdata)
|
||||
|
||||
allowed_attrs = self.allowed_attributes()
|
||||
if allowed_attrs is not None:
|
||||
allowed_args = [ a[1].lower().replace('-','') for a in allowed_attrs]
|
||||
self.attributes={}
|
||||
# Load the attributes from the 'attributes' argument
|
||||
if attributes:
|
||||
for attr, value in list(attributes.items()):
|
||||
self.setAttribute(attr, value)
|
||||
# Load the qualified attributes
|
||||
if qattributes:
|
||||
for attr, value in list(qattributes.items()):
|
||||
self.setAttrNS(attr[0], attr[1], value)
|
||||
if allowed_attrs is not None:
|
||||
# Load the attributes from the 'args' argument
|
||||
for arg in list(args.keys()):
|
||||
self.setAttribute(arg, args[arg])
|
||||
else:
|
||||
for arg in list(args.keys()): # If any attribute is allowed
|
||||
self.attributes[arg]=args[arg]
|
||||
if not check_grammar:
|
||||
return
|
||||
# Test that all mandatory attributes have been added.
|
||||
required = grammar.required_attributes.get(self.qname)
|
||||
if required:
|
||||
for r in required:
|
||||
if self.getAttrNS(r[0],r[1]) is None:
|
||||
raise AttributeError("Required attribute missing: %s in <%s>" % (r[1].lower().replace('-',''), self.tagName))
|
||||
|
||||
def get_knownns(self, prefix):
|
||||
""" Odfpy maintains a list of known namespaces. In some cases a prefix is used, and
|
||||
we need to know which namespace it resolves to.
|
||||
"""
|
||||
global nsdict
|
||||
for ns,p in list(nsdict.items()):
|
||||
if p == prefix: return ns
|
||||
return None
|
||||
|
||||
def get_nsprefix(self, namespace):
|
||||
""" Odfpy maintains a list of known namespaces. In some cases we have a namespace URL,
|
||||
and needs to look up or assign the prefix for it.
|
||||
"""
|
||||
if namespace is None: namespace = ""
|
||||
prefix = _nsassign(namespace)
|
||||
if namespace not in self.namespaces:
|
||||
self.namespaces[namespace] = prefix
|
||||
return prefix
|
||||
|
||||
def allowed_attributes(self):
|
||||
return grammar.allowed_attributes.get(self.qname)
|
||||
|
||||
def _setOwnerDoc(self, element):
|
||||
element.ownerDocument = self.ownerDocument
|
||||
for child in element.childNodes:
|
||||
self._setOwnerDoc(child)
|
||||
|
||||
def addElement(self, element, check_grammar=True):
|
||||
""" adds an element to an Element
|
||||
|
||||
Element.addElement(Element)
|
||||
"""
|
||||
if check_grammar and self.allowed_children is not None:
|
||||
if element.qname not in self.allowed_children:
|
||||
raise IllegalChild("<%s> is not allowed in <%s>" % ( element.tagName, self.tagName))
|
||||
self.appendChild(element)
|
||||
self._setOwnerDoc(element)
|
||||
if self.ownerDocument:
|
||||
self.ownerDocument.rebuild_caches(element)
|
||||
|
||||
def addText(self, text, check_grammar=True):
|
||||
""" Adds text to an element
|
||||
Setting check_grammar=False turns off grammar checking
|
||||
"""
|
||||
if check_grammar and self.qname not in grammar.allows_text:
|
||||
raise IllegalText("The <%s> element does not allow text" % self.tagName)
|
||||
else:
|
||||
if text != '':
|
||||
self.appendChild(Text(text))
|
||||
|
||||
def addCDATA(self, cdata, check_grammar=True):
|
||||
""" Adds CDATA to an element
|
||||
Setting check_grammar=False turns off grammar checking
|
||||
"""
|
||||
if check_grammar and self.qname not in grammar.allows_text:
|
||||
raise IllegalText("The <%s> element does not allow text" % self.tagName)
|
||||
else:
|
||||
self.appendChild(CDATASection(cdata))
|
||||
|
||||
def removeAttribute(self, attr, check_grammar=True):
|
||||
""" Removes an attribute by name. """
|
||||
allowed_attrs = self.allowed_attributes()
|
||||
if allowed_attrs is None:
|
||||
if type(attr) == type(()):
|
||||
prefix, localname = attr
|
||||
self.removeAttrNS(prefix, localname)
|
||||
else:
|
||||
raise AttributeError("Unable to add simple attribute - use (namespace, localpart)")
|
||||
else:
|
||||
# Construct a list of allowed arguments
|
||||
allowed_args = [ a[1].lower().replace('-','') for a in allowed_attrs]
|
||||
if check_grammar and attr not in allowed_args:
|
||||
raise AttributeError("Attribute %s is not allowed in <%s>" % ( attr, self.tagName))
|
||||
i = allowed_args.index(attr)
|
||||
self.removeAttrNS(allowed_attrs[i][0], allowed_attrs[i][1])
|
||||
|
||||
def setAttribute(self, attr, value, check_grammar=True):
|
||||
""" Add an attribute to the element
|
||||
This is sort of a convenience method. All attributes in ODF have
|
||||
namespaces. The library knows what attributes are legal and then allows
|
||||
the user to provide the attribute as a keyword argument and the
|
||||
library will add the correct namespace.
|
||||
Must overwrite, If attribute already exists.
|
||||
"""
|
||||
allowed_attrs = self.allowed_attributes()
|
||||
if allowed_attrs is None:
|
||||
if type(attr) == type(()):
|
||||
prefix, localname = attr
|
||||
self.setAttrNS(prefix, localname, value)
|
||||
else:
|
||||
raise AttributeError("Unable to add simple attribute - use (namespace, localpart)")
|
||||
else:
|
||||
# Construct a list of allowed arguments
|
||||
allowed_args = [ a[1].lower().replace('-','') for a in allowed_attrs]
|
||||
if check_grammar and attr not in allowed_args:
|
||||
raise AttributeError("Attribute %s is not allowed in <%s>" % ( attr, self.tagName))
|
||||
i = allowed_args.index(attr)
|
||||
self.setAttrNS(allowed_attrs[i][0], allowed_attrs[i][1], value)
|
||||
|
||||
def setAttrNS(self, namespace, localpart, value):
|
||||
""" Add an attribute to the element
|
||||
In case you need to add an attribute the library doesn't know about
|
||||
then you must provide the full qualified name
|
||||
It will not check that the attribute is legal according to the schema.
|
||||
Must overwrite, If attribute already exists.
|
||||
"""
|
||||
allowed_attrs = self.allowed_attributes()
|
||||
prefix = self.get_nsprefix(namespace)
|
||||
# if allowed_attrs and (namespace, localpart) not in allowed_attrs:
|
||||
# raise AttributeError, "Attribute %s:%s is not allowed in element <%s>" % ( prefix, localpart, self.tagName)
|
||||
c = AttrConverters()
|
||||
self.attributes[(namespace, localpart)] = c.convert((namespace, localpart), value, self)
|
||||
|
||||
def getAttrNS(self, namespace, localpart):
|
||||
prefix = self.get_nsprefix(namespace)
|
||||
return self.attributes.get((namespace, localpart))
|
||||
|
||||
def removeAttrNS(self, namespace, localpart):
|
||||
del self.attributes[(namespace, localpart)]
|
||||
|
||||
def getAttribute(self, attr):
|
||||
""" Get an attribute value. The method knows which namespace the attribute is in
|
||||
"""
|
||||
allowed_attrs = self.allowed_attributes()
|
||||
if allowed_attrs is None:
|
||||
if type(attr) == type(()):
|
||||
prefix, localname = attr
|
||||
return self.getAttrNS(prefix, localname)
|
||||
else:
|
||||
raise AttributeError("Unable to get simple attribute - use (namespace, localpart)")
|
||||
else:
|
||||
# Construct a list of allowed arguments
|
||||
allowed_args = [ a[1].lower().replace('-','') for a in allowed_attrs]
|
||||
i = allowed_args.index(attr)
|
||||
return self.getAttrNS(allowed_attrs[i][0], allowed_attrs[i][1])
|
||||
|
||||
def write_open_tag(self, level, f):
|
||||
f.write('<'+self.tagName)
|
||||
if level == 0:
|
||||
for namespace, prefix in list(self.namespaces.items()):
|
||||
f.write(' xmlns:' + prefix + '="'+ _escape(str(namespace))+'"')
|
||||
for qname in list(self.attributes.keys()):
|
||||
prefix = self.get_nsprefix(qname[0])
|
||||
f.write(' '+_escape(str(prefix+':'+qname[1]))+'='+_quoteattr(str(self.attributes[qname]).encode('utf-8')))
|
||||
f.write('>')
|
||||
|
||||
def write_close_tag(self, level, f):
|
||||
f.write('</'+self.tagName+'>')
|
||||
|
||||
def toXml(self, level, f):
|
||||
""" Generate XML stream out of the tree structure """
|
||||
f.write('<'+self.tagName)
|
||||
if level == 0:
|
||||
for namespace, prefix in list(self.namespaces.items()):
|
||||
f.write(' xmlns:' + prefix + '="'+ _escape(str(namespace))+'"')
|
||||
for qname in list(self.attributes.keys()):
|
||||
prefix = self.get_nsprefix(qname[0])
|
||||
f.write(' '+_escape(str(prefix+':'+qname[1]))+'='+_quoteattr(str(self.attributes[qname]).encode('utf-8')))
|
||||
if self.childNodes:
|
||||
f.write('>')
|
||||
for element in self.childNodes:
|
||||
element.toXml(level+1,f)
|
||||
f.write('</'+self.tagName+'>')
|
||||
else:
|
||||
f.write('/>')
|
||||
|
||||
def _getElementsByObj(self, obj, accumulator):
|
||||
if self.qname == obj.qname:
|
||||
accumulator.append(self)
|
||||
for e in self.childNodes:
|
||||
if e.nodeType == Node.ELEMENT_NODE:
|
||||
accumulator = e._getElementsByObj(obj, accumulator)
|
||||
return accumulator
|
||||
|
||||
def getElementsByType(self, element):
|
||||
""" Gets elements based on the type, which is function from text.py, draw.py etc. """
|
||||
obj = element(check_grammar=False)
|
||||
return self._getElementsByObj(obj,[])
|
||||
|
||||
def isInstanceOf(self, element):
|
||||
""" This is a check to see if the object is an instance of a type """
|
||||
obj = element(check_grammar=False)
|
||||
return self.qname == obj.qname
|
||||
|
||||
|
||||
@@ -0,0 +1,325 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2008 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import *
|
||||
|
||||
# Inline element don't cause a box
|
||||
# They are analogous to the HTML elements SPAN, B, I etc.
|
||||
inline_elements = (
|
||||
(TEXTNS,'a'),
|
||||
(TEXTNS,'author-initials'),
|
||||
(TEXTNS,'author-name'),
|
||||
(TEXTNS,'bibliography-mark'),
|
||||
(TEXTNS,'bookmark-ref'),
|
||||
(TEXTNS,'chapter'),
|
||||
(TEXTNS,'character-count'),
|
||||
(TEXTNS,'conditional-text'),
|
||||
(TEXTNS,'creation-date'),
|
||||
(TEXTNS,'creation-time'),
|
||||
(TEXTNS,'creator'),
|
||||
(TEXTNS,'database-display'),
|
||||
(TEXTNS,'database-name'),
|
||||
(TEXTNS,'database-next'),
|
||||
(TEXTNS,'database-row-number'),
|
||||
(TEXTNS,'database-row-select'),
|
||||
(TEXTNS,'date'),
|
||||
(TEXTNS,'dde-connection'),
|
||||
(TEXTNS,'description'),
|
||||
(TEXTNS,'editing-cycles'),
|
||||
(TEXTNS,'editing-duration'),
|
||||
(TEXTNS,'execute-macro'),
|
||||
(TEXTNS,'expression'),
|
||||
(TEXTNS,'file-name'),
|
||||
(TEXTNS,'hidden-paragraph'),
|
||||
(TEXTNS,'hidden-text'),
|
||||
(TEXTNS,'image-count'),
|
||||
(TEXTNS,'initial-creator'),
|
||||
(TEXTNS,'keywords'),
|
||||
(TEXTNS,'measure'),
|
||||
(TEXTNS,'modification-date'),
|
||||
(TEXTNS,'modification-time'),
|
||||
(TEXTNS,'note-ref'),
|
||||
(TEXTNS,'object-count'),
|
||||
(TEXTNS,'page-continuation'),
|
||||
(TEXTNS,'page-count'),
|
||||
(TEXTNS,'page-number'),
|
||||
(TEXTNS,'page-variable-get'),
|
||||
(TEXTNS,'page-variable-set'),
|
||||
(TEXTNS,'paragraph-count'),
|
||||
(TEXTNS,'placeholder'),
|
||||
(TEXTNS,'print-date'),
|
||||
(TEXTNS,'printed-by'),
|
||||
(TEXTNS,'print-time'),
|
||||
(TEXTNS,'reference-ref'),
|
||||
(TEXTNS,'ruby'),
|
||||
(TEXTNS,'ruby-base'),
|
||||
(TEXTNS,'ruby-text'),
|
||||
(TEXTNS,'script'),
|
||||
(TEXTNS,'sender-city'),
|
||||
(TEXTNS,'sender-company'),
|
||||
(TEXTNS,'sender-country'),
|
||||
(TEXTNS,'sender-email'),
|
||||
(TEXTNS,'sender-fax'),
|
||||
(TEXTNS,'sender-firstname'),
|
||||
(TEXTNS,'sender-initials'),
|
||||
(TEXTNS,'sender-lastname'),
|
||||
(TEXTNS,'sender-phone-private'),
|
||||
(TEXTNS,'sender-phone-work'),
|
||||
(TEXTNS,'sender-position'),
|
||||
(TEXTNS,'sender-postal-code'),
|
||||
(TEXTNS,'sender-state-or-province'),
|
||||
(TEXTNS,'sender-street'),
|
||||
(TEXTNS,'sender-title'),
|
||||
(TEXTNS,'sequence'),
|
||||
(TEXTNS,'sequence-ref'),
|
||||
(TEXTNS,'sheet-name'),
|
||||
(TEXTNS,'span'),
|
||||
(TEXTNS,'subject'),
|
||||
(TEXTNS,'table-count'),
|
||||
(TEXTNS,'table-formula'),
|
||||
(TEXTNS,'template-name'),
|
||||
(TEXTNS,'text-input'),
|
||||
(TEXTNS,'time'),
|
||||
(TEXTNS,'title'),
|
||||
(TEXTNS,'user-defined'),
|
||||
(TEXTNS,'user-field-get'),
|
||||
(TEXTNS,'user-field-input'),
|
||||
(TEXTNS,'variable-get'),
|
||||
(TEXTNS,'variable-input'),
|
||||
(TEXTNS,'variable-set'),
|
||||
(TEXTNS,'word-count'),
|
||||
)
|
||||
|
||||
|
||||
# It is almost impossible to determine what elements are block elements.
|
||||
# There are so many that don't fit the form
|
||||
block_elements = (
|
||||
(TEXTNS,'h'),
|
||||
(TEXTNS,'p'),
|
||||
(TEXTNS,'list'),
|
||||
(TEXTNS,'list-item'),
|
||||
(TEXTNS,'section'),
|
||||
)
|
||||
|
||||
declarative_elements = (
|
||||
(OFFICENS,'font-face-decls'),
|
||||
(PRESENTATIONNS,'date-time-decl'),
|
||||
(PRESENTATIONNS,'footer-decl'),
|
||||
(PRESENTATIONNS,'header-decl'),
|
||||
(TABLENS,'table-template'),
|
||||
(TEXTNS,'alphabetical-index-entry-template'),
|
||||
(TEXTNS,'alphabetical-index-source'),
|
||||
(TEXTNS,'bibliography-entry-template'),
|
||||
(TEXTNS,'bibliography-source'),
|
||||
(TEXTNS,'dde-connection-decls'),
|
||||
(TEXTNS,'illustration-index-entry-template'),
|
||||
(TEXTNS,'illustration-index-source'),
|
||||
(TEXTNS,'index-source-styles'),
|
||||
(TEXTNS,'index-title-template'),
|
||||
(TEXTNS,'note-continuation-notice-backward'),
|
||||
(TEXTNS,'note-continuation-notice-forward'),
|
||||
(TEXTNS,'notes-configuration'),
|
||||
(TEXTNS,'object-index-entry-template'),
|
||||
(TEXTNS,'object-index-source'),
|
||||
(TEXTNS,'sequence-decls'),
|
||||
(TEXTNS,'table-index-entry-template'),
|
||||
(TEXTNS,'table-index-source'),
|
||||
(TEXTNS,'table-of-content-entry-template'),
|
||||
(TEXTNS,'table-of-content-source'),
|
||||
(TEXTNS,'user-field-decls'),
|
||||
(TEXTNS,'user-index-entry-template'),
|
||||
(TEXTNS,'user-index-source'),
|
||||
(TEXTNS,'variable-decls'),
|
||||
)
|
||||
|
||||
empty_elements = (
|
||||
(ANIMNS,'animate'),
|
||||
(ANIMNS,'animateColor'),
|
||||
(ANIMNS,'animateMotion'),
|
||||
(ANIMNS,'animateTransform'),
|
||||
(ANIMNS,'audio'),
|
||||
(ANIMNS,'param'),
|
||||
(ANIMNS,'set'),
|
||||
(ANIMNS,'transitionFilter'),
|
||||
(CHARTNS,'categories'),
|
||||
(CHARTNS,'data-point'),
|
||||
(CHARTNS,'domain'),
|
||||
(CHARTNS,'error-indicator'),
|
||||
(CHARTNS,'floor'),
|
||||
(CHARTNS,'grid'),
|
||||
(CHARTNS,'legend'),
|
||||
(CHARTNS,'mean-value'),
|
||||
(CHARTNS,'regression-curve'),
|
||||
(CHARTNS,'stock-gain-marker'),
|
||||
(CHARTNS,'stock-loss-marker'),
|
||||
(CHARTNS,'stock-range-line'),
|
||||
(CHARTNS,'symbol-image'),
|
||||
(CHARTNS,'wall'),
|
||||
(DR3DNS,'cube'),
|
||||
(DR3DNS,'extrude'),
|
||||
(DR3DNS,'light'),
|
||||
(DR3DNS,'rotate'),
|
||||
(DR3DNS,'sphere'),
|
||||
(DRAWNS,'contour-path'),
|
||||
(DRAWNS,'contour-polygon'),
|
||||
(DRAWNS,'equation'),
|
||||
(DRAWNS,'fill-image'),
|
||||
(DRAWNS,'floating-frame'),
|
||||
(DRAWNS,'glue-point'),
|
||||
(DRAWNS,'gradient'),
|
||||
(DRAWNS,'handle'),
|
||||
(DRAWNS,'hatch'),
|
||||
(DRAWNS,'layer'),
|
||||
(DRAWNS,'marker'),
|
||||
(DRAWNS,'opacity'),
|
||||
(DRAWNS,'page-thumbnail'),
|
||||
(DRAWNS,'param'),
|
||||
(DRAWNS,'stroke-dash'),
|
||||
(FORMNS,'connection-resource'),
|
||||
(FORMNS,'list-value'),
|
||||
(FORMNS,'property'),
|
||||
(MANIFESTNS,'algorithm'),
|
||||
(MANIFESTNS,'key-derivation'),
|
||||
(METANS,'auto-reload'),
|
||||
(METANS,'document-statistic'),
|
||||
(METANS,'hyperlink-behaviour'),
|
||||
(METANS,'template'),
|
||||
(NUMBERNS,'am-pm'),
|
||||
(NUMBERNS,'boolean'),
|
||||
(NUMBERNS,'day'),
|
||||
(NUMBERNS,'day-of-week'),
|
||||
(NUMBERNS,'era'),
|
||||
(NUMBERNS,'fraction'),
|
||||
(NUMBERNS,'hours'),
|
||||
(NUMBERNS,'minutes'),
|
||||
(NUMBERNS,'month'),
|
||||
(NUMBERNS,'quarter'),
|
||||
(NUMBERNS,'scientific-number'),
|
||||
(NUMBERNS,'seconds'),
|
||||
(NUMBERNS,'text-content'),
|
||||
(NUMBERNS,'week-of-year'),
|
||||
(NUMBERNS,'year'),
|
||||
(OFFICENS,'dde-source'),
|
||||
(PRESENTATIONNS,'date-time'),
|
||||
(PRESENTATIONNS,'footer'),
|
||||
(PRESENTATIONNS,'header'),
|
||||
(PRESENTATIONNS,'placeholder'),
|
||||
(PRESENTATIONNS,'play'),
|
||||
(PRESENTATIONNS,'show'),
|
||||
(PRESENTATIONNS,'sound'),
|
||||
(SCRIPTNS,'event-listener'),
|
||||
(STYLENS,'column'),
|
||||
(STYLENS,'column-sep'),
|
||||
(STYLENS,'drop-cap'),
|
||||
(STYLENS,'footnote-sep'),
|
||||
(STYLENS,'list-level-properties'),
|
||||
(STYLENS,'map'),
|
||||
(STYLENS,'ruby-properties'),
|
||||
(STYLENS,'table-column-properties'),
|
||||
(STYLENS,'tab-stop'),
|
||||
(STYLENS,'text-properties'),
|
||||
(SVGNS,'definition-src'),
|
||||
(SVGNS,'font-face-format'),
|
||||
(SVGNS,'font-face-name'),
|
||||
(SVGNS,'stop'),
|
||||
(TABLENS,'body'),
|
||||
(TABLENS,'cell-address'),
|
||||
(TABLENS,'cell-range-source'),
|
||||
(TABLENS,'change-deletion'),
|
||||
(TABLENS,'consolidation'),
|
||||
(TABLENS,'database-source-query'),
|
||||
(TABLENS,'database-source-sql'),
|
||||
(TABLENS,'database-source-table'),
|
||||
(TABLENS,'data-pilot-display-info'),
|
||||
(TABLENS,'data-pilot-field-reference'),
|
||||
(TABLENS,'data-pilot-group-member'),
|
||||
(TABLENS,'data-pilot-layout-info'),
|
||||
(TABLENS,'data-pilot-member'),
|
||||
(TABLENS,'data-pilot-sort-info'),
|
||||
(TABLENS,'data-pilot-subtotal'),
|
||||
(TABLENS,'dependency'),
|
||||
(TABLENS,'error-macro'),
|
||||
(TABLENS,'even-columns'),
|
||||
(TABLENS,'even-rows'),
|
||||
(TABLENS,'filter-condition'),
|
||||
(TABLENS,'first-column'),
|
||||
(TABLENS,'first-row'),
|
||||
(TABLENS,'highlighted-range'),
|
||||
(TABLENS,'insertion-cut-off'),
|
||||
(TABLENS,'iteration'),
|
||||
(TABLENS,'label-range'),
|
||||
(TABLENS,'last-column'),
|
||||
(TABLENS,'last-row'),
|
||||
(TABLENS,'movement-cut-off'),
|
||||
(TABLENS,'named-expression'),
|
||||
(TABLENS,'named-range'),
|
||||
(TABLENS,'null-date'),
|
||||
(TABLENS,'odd-columns'),
|
||||
(TABLENS,'odd-rows'),
|
||||
(TABLENS,'operation'),
|
||||
(TABLENS,'scenario'),
|
||||
(TABLENS,'sort-by'),
|
||||
(TABLENS,'sort-groups'),
|
||||
(TABLENS,'source-range-address'),
|
||||
(TABLENS,'source-service'),
|
||||
(TABLENS,'subtotal-field'),
|
||||
(TABLENS,'table-column'),
|
||||
(TABLENS,'table-source'),
|
||||
(TABLENS,'target-range-address'),
|
||||
(TEXTNS,'alphabetical-index-auto-mark-file'),
|
||||
(TEXTNS,'alphabetical-index-mark'),
|
||||
(TEXTNS,'alphabetical-index-mark-end'),
|
||||
(TEXTNS,'alphabetical-index-mark-start'),
|
||||
(TEXTNS,'bookmark'),
|
||||
(TEXTNS,'bookmark-end'),
|
||||
(TEXTNS,'bookmark-start'),
|
||||
(TEXTNS,'change'),
|
||||
(TEXTNS,'change-end'),
|
||||
(TEXTNS,'change-start'),
|
||||
(TEXTNS,'dde-connection-decl'),
|
||||
(TEXTNS,'index-entry-bibliography'),
|
||||
(TEXTNS,'index-entry-chapter'),
|
||||
(TEXTNS,'index-entry-link-end'),
|
||||
(TEXTNS,'index-entry-link-start'),
|
||||
(TEXTNS,'index-entry-page-number'),
|
||||
(TEXTNS,'index-entry-tab-stop'),
|
||||
(TEXTNS,'index-entry-text'),
|
||||
(TEXTNS,'index-source-style'),
|
||||
(TEXTNS,'line-break'),
|
||||
(TEXTNS,'page'),
|
||||
(TEXTNS,'reference-mark'),
|
||||
(TEXTNS,'reference-mark-end'),
|
||||
(TEXTNS,'reference-mark-start'),
|
||||
(TEXTNS,'s'),
|
||||
(TEXTNS,'section-source'),
|
||||
(TEXTNS,'sequence-decl'),
|
||||
(TEXTNS,'soft-page-break'),
|
||||
(TEXTNS,'sort-key'),
|
||||
(TEXTNS,'tab'),
|
||||
(TEXTNS,'toc-mark'),
|
||||
(TEXTNS,'toc-mark-end'),
|
||||
(TEXTNS,'toc-mark-start'),
|
||||
(TEXTNS,'user-field-decl'),
|
||||
(TEXTNS,'user-index-mark'),
|
||||
(TEXTNS,'user-index-mark-end'),
|
||||
(TEXTNS,'user-index-mark-start'),
|
||||
(TEXTNS,'variable-decl')
|
||||
)
|
||||
@@ -0,0 +1,115 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import FORMNS
|
||||
from .element import Element
|
||||
|
||||
|
||||
# Autogenerated
|
||||
def Button(**args):
|
||||
return Element(qname = (FORMNS,'button'), **args)
|
||||
|
||||
def Checkbox(**args):
|
||||
return Element(qname = (FORMNS,'checkbox'), **args)
|
||||
|
||||
def Column(**args):
|
||||
return Element(qname = (FORMNS,'column'), **args)
|
||||
|
||||
def Combobox(**args):
|
||||
return Element(qname = (FORMNS,'combobox'), **args)
|
||||
|
||||
def ConnectionResource(**args):
|
||||
return Element(qname = (FORMNS,'connection-resource'), **args)
|
||||
|
||||
def Date(**args):
|
||||
return Element(qname = (FORMNS,'date'), **args)
|
||||
|
||||
def File(**args):
|
||||
return Element(qname = (FORMNS,'file'), **args)
|
||||
|
||||
def FixedText(**args):
|
||||
return Element(qname = (FORMNS,'fixed-text'), **args)
|
||||
|
||||
def Form(**args):
|
||||
return Element(qname = (FORMNS,'form'), **args)
|
||||
|
||||
def FormattedText(**args):
|
||||
return Element(qname = (FORMNS,'formatted-text'), **args)
|
||||
|
||||
def Frame(**args):
|
||||
return Element(qname = (FORMNS,'frame'), **args)
|
||||
|
||||
def GenericControl(**args):
|
||||
return Element(qname = (FORMNS,'generic-control'), **args)
|
||||
|
||||
def Grid(**args):
|
||||
return Element(qname = (FORMNS,'grid'), **args)
|
||||
|
||||
def Hidden(**args):
|
||||
return Element(qname = (FORMNS,'hidden'), **args)
|
||||
|
||||
def Image(**args):
|
||||
return Element(qname = (FORMNS,'image'), **args)
|
||||
|
||||
def ImageFrame(**args):
|
||||
return Element(qname = (FORMNS,'image-frame'), **args)
|
||||
|
||||
def Item(**args):
|
||||
return Element(qname = (FORMNS,'item'), **args)
|
||||
|
||||
def ListProperty(**args):
|
||||
return Element(qname = (FORMNS,'list-property'), **args)
|
||||
|
||||
def ListValue(**args):
|
||||
return Element(qname = (FORMNS,'list-value'), **args)
|
||||
|
||||
def Listbox(**args):
|
||||
return Element(qname = (FORMNS,'listbox'), **args)
|
||||
|
||||
def Number(**args):
|
||||
return Element(qname = (FORMNS,'number'), **args)
|
||||
|
||||
def Option(**args):
|
||||
return Element(qname = (FORMNS,'option'), **args)
|
||||
|
||||
def Password(**args):
|
||||
return Element(qname = (FORMNS,'password'), **args)
|
||||
|
||||
def Properties(**args):
|
||||
return Element(qname = (FORMNS,'properties'), **args)
|
||||
|
||||
def Property(**args):
|
||||
return Element(qname = (FORMNS,'property'), **args)
|
||||
|
||||
def Radio(**args):
|
||||
return Element(qname = (FORMNS,'radio'), **args)
|
||||
|
||||
def Text(**args):
|
||||
return Element(qname = (FORMNS,'text'), **args)
|
||||
|
||||
def Textarea(**args):
|
||||
return Element(qname = (FORMNS,'textarea'), **args)
|
||||
|
||||
def Time(**args):
|
||||
return Element(qname = (FORMNS,'time'), **args)
|
||||
|
||||
def ValueRange(**args):
|
||||
return Element(qname = (FORMNS,'value-range'), **args)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2007-2008 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
# This script is to be embedded in opendocument.py later
|
||||
# The purpose is to read an ODT/ODP/ODS file and create the datastructure
|
||||
# in memory. The user should then be able to make operations and then save
|
||||
# the structure again.
|
||||
|
||||
from xml.sax import make_parser,handler
|
||||
from xml.sax.xmlreader import InputSource
|
||||
import xml.sax.saxutils
|
||||
from .element import Element
|
||||
from .namespaces import OFFICENS
|
||||
from io import StringIO
|
||||
|
||||
#
|
||||
# Parse the XML files
|
||||
#
|
||||
class LoadParser(handler.ContentHandler):
|
||||
""" Extract headings from content.xml of an ODT file """
|
||||
triggers = (
|
||||
(OFFICENS, 'automatic-styles'), (OFFICENS, 'body'),
|
||||
(OFFICENS, 'font-face-decls'), (OFFICENS, 'master-styles'),
|
||||
(OFFICENS, 'meta'), (OFFICENS, 'scripts'),
|
||||
(OFFICENS, 'settings'), (OFFICENS, 'styles') )
|
||||
|
||||
def __init__(self, document):
|
||||
self.doc = document
|
||||
self.data = []
|
||||
self.level = 0
|
||||
self.parse = False
|
||||
|
||||
def characters(self, data):
|
||||
if self.parse == False:
|
||||
return
|
||||
self.data.append(data)
|
||||
|
||||
def startElementNS(self, tag, qname, attrs):
|
||||
if tag in self.triggers:
|
||||
self.parse = True
|
||||
if self.doc._parsing != "styles.xml" and tag == (OFFICENS, 'font-face-decls'):
|
||||
self.parse = False
|
||||
if self.parse == False:
|
||||
return
|
||||
|
||||
self.level = self.level + 1
|
||||
# Add any accumulated text content
|
||||
content = ''.join(self.data)
|
||||
if len(content.strip()) > 0:
|
||||
self.parent.addText(content, check_grammar=False)
|
||||
self.data = []
|
||||
# Create the element
|
||||
attrdict = {}
|
||||
for (att,value) in list(attrs.items()):
|
||||
attrdict[att] = value
|
||||
try:
|
||||
e = Element(qname = tag, qattributes=attrdict, check_grammar=False)
|
||||
self.curr = e
|
||||
except AttributeError as v:
|
||||
print("Error: %s" % v)
|
||||
|
||||
if tag == (OFFICENS, 'automatic-styles'):
|
||||
e = self.doc.automaticstyles
|
||||
elif tag == (OFFICENS, 'body'):
|
||||
e = self.doc.body
|
||||
elif tag == (OFFICENS, 'master-styles'):
|
||||
e = self.doc.masterstyles
|
||||
elif tag == (OFFICENS, 'meta'):
|
||||
e = self.doc.meta
|
||||
elif tag == (OFFICENS,'scripts'):
|
||||
e = self.doc.scripts
|
||||
elif tag == (OFFICENS,'settings'):
|
||||
e = self.doc.settings
|
||||
elif tag == (OFFICENS,'styles'):
|
||||
e = self.doc.styles
|
||||
elif self.doc._parsing == "styles.xml" and tag == (OFFICENS, 'font-face-decls'):
|
||||
e = self.doc.fontfacedecls
|
||||
elif hasattr(self,'parent'):
|
||||
self.parent.addElement(e, check_grammar=False)
|
||||
self.parent = e
|
||||
|
||||
|
||||
def endElementNS(self, tag, qname):
|
||||
if self.parse == False:
|
||||
return
|
||||
self.level = self.level - 1
|
||||
str = ''.join(self.data)
|
||||
if len(str.strip()) > 0:
|
||||
self.curr.addText(str, check_grammar=False)
|
||||
self.data = []
|
||||
self.curr = self.curr.parentNode
|
||||
self.parent = self.curr
|
||||
if tag in self.triggers:
|
||||
self.parse = False
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
#
|
||||
|
||||
from .namespaces import MANIFESTNS
|
||||
from .element import Element
|
||||
|
||||
# Autogenerated
|
||||
def Manifest(**args):
|
||||
return Element(qname = (MANIFESTNS,'manifest'), **args)
|
||||
|
||||
def FileEntry(**args):
|
||||
return Element(qname = (MANIFESTNS,'file-entry'), **args)
|
||||
|
||||
def EncryptionData(**args):
|
||||
return Element(qname = (MANIFESTNS,'encryption-data'), **args)
|
||||
|
||||
def Algorithm(**args):
|
||||
return Element(qname = (MANIFESTNS,'algorithm'), **args)
|
||||
|
||||
def KeyDerivation(**args):
|
||||
return Element(qname = (MANIFESTNS,'key-derivation'), **args)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import MATHNS
|
||||
from .element import Element
|
||||
|
||||
# ODF 1.0 section 12.5
|
||||
# Mathematical content is represented by MathML 2.0
|
||||
|
||||
# Autogenerated
|
||||
def Math(**args):
|
||||
return Element(qname = (MATHNS,'math'), **args)
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import METANS
|
||||
from .element import Element
|
||||
|
||||
# Autogenerated
|
||||
def AutoReload(**args):
|
||||
return Element(qname = (METANS,'auto-reload'), **args)
|
||||
|
||||
def CreationDate(**args):
|
||||
return Element(qname = (METANS,'creation-date'), **args)
|
||||
|
||||
def DateString(**args):
|
||||
return Element(qname = (METANS,'date-string'), **args)
|
||||
|
||||
def DocumentStatistic(**args):
|
||||
return Element(qname = (METANS,'document-statistic'), **args)
|
||||
|
||||
def EditingCycles(**args):
|
||||
return Element(qname = (METANS,'editing-cycles'), **args)
|
||||
|
||||
def EditingDuration(**args):
|
||||
return Element(qname = (METANS,'editing-duration'), **args)
|
||||
|
||||
def Generator(**args):
|
||||
return Element(qname = (METANS,'generator'), **args)
|
||||
|
||||
def HyperlinkBehaviour(**args):
|
||||
return Element(qname = (METANS,'hyperlink-behaviour'), **args)
|
||||
|
||||
def InitialCreator(**args):
|
||||
return Element(qname = (METANS,'initial-creator'), **args)
|
||||
|
||||
def Keyword(**args):
|
||||
return Element(qname = (METANS,'keyword'), **args)
|
||||
|
||||
def PrintDate(**args):
|
||||
return Element(qname = (METANS,'print-date'), **args)
|
||||
|
||||
def PrintedBy(**args):
|
||||
return Element(qname = (METANS,'printed-by'), **args)
|
||||
|
||||
def Template(**args):
|
||||
return Element(qname = (METANS,'template'), **args)
|
||||
|
||||
def UserDefined(**args):
|
||||
return Element(qname = (METANS,'user-defined'), **args)
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2010 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
TOOLSVERSION = "ODFPY/0.9.3"
|
||||
|
||||
ANIMNS = "urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
|
||||
DBNS = "urn:oasis:names:tc:opendocument:xmlns:database:1.0"
|
||||
CHARTNS = "urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
CONFIGNS = "urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
#DBNS = u"http://openoffice.org/2004/database"
|
||||
DCNS = "http://purl.org/dc/elements/1.1/"
|
||||
DOMNS = "http://www.w3.org/2001/xml-events"
|
||||
DR3DNS = "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
DRAWNS = "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
FIELDNS = "urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0"
|
||||
FONS = "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
FORMNS = "urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
GRDDLNS = "http://www.w3.org/2003/g/data-view#"
|
||||
KOFFICENS = "http://www.koffice.org/2005/"
|
||||
MANIFESTNS = "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"
|
||||
MATHNS = "http://www.w3.org/1998/Math/MathML"
|
||||
METANS = "urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
NUMBERNS = "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
OFFICENS = "urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
OFNS = "urn:oasis:names:tc:opendocument:xmlns:of:1.2"
|
||||
OOONS = "http://openoffice.org/2004/office"
|
||||
OOOWNS = "http://openoffice.org/2004/writer"
|
||||
OOOCNS = "http://openoffice.org/2004/calc"
|
||||
PRESENTATIONNS = "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
|
||||
RDFANS = "http://docs.oasis-open.org/opendocument/meta/rdfa#"
|
||||
RPTNS = "http://openoffice.org/2005/report"
|
||||
SCRIPTNS = "urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
SMILNS = "urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
|
||||
STYLENS = "urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
SVGNS = "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
TABLENS = "urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
TEXTNS = "urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
XFORMSNS = "http://www.w3.org/2002/xforms"
|
||||
XLINKNS = "http://www.w3.org/1999/xlink"
|
||||
XMLNS = "http://www.w3.org/XML/1998/namespace"
|
||||
XSDNS = "http://www.w3.org/2001/XMLSchema"
|
||||
XSINS = "http://www.w3.org/2001/XMLSchema-instance"
|
||||
|
||||
nsdict = {
|
||||
ANIMNS: 'anim',
|
||||
CHARTNS: 'chart',
|
||||
CONFIGNS: 'config',
|
||||
DBNS: 'db',
|
||||
DCNS: 'dc',
|
||||
DOMNS: 'dom',
|
||||
DR3DNS: 'dr3d',
|
||||
DRAWNS: 'draw',
|
||||
FIELDNS: 'field',
|
||||
FONS: 'fo',
|
||||
FORMNS: 'form',
|
||||
GRDDLNS: 'grddl',
|
||||
KOFFICENS: 'koffice',
|
||||
MANIFESTNS: 'manifest',
|
||||
MATHNS: 'math',
|
||||
METANS: 'meta',
|
||||
NUMBERNS: 'number',
|
||||
OFFICENS: 'office',
|
||||
OFNS: 'of',
|
||||
OOONS: 'ooo',
|
||||
OOOWNS: 'ooow',
|
||||
OOOCNS: 'oooc',
|
||||
PRESENTATIONNS: 'presentation',
|
||||
RDFANS: 'rdfa',
|
||||
RPTNS: 'rpt',
|
||||
SCRIPTNS: 'script',
|
||||
SMILNS: 'smil',
|
||||
STYLENS: 'style',
|
||||
SVGNS: 'svg',
|
||||
TABLENS: 'table',
|
||||
TEXTNS: 'text',
|
||||
XFORMSNS: 'xforms',
|
||||
XLINKNS: 'xlink',
|
||||
XMLNS: 'xml',
|
||||
XSDNS: 'xsd',
|
||||
XSINS: 'xsi',
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import NUMBERNS
|
||||
from .element import Element
|
||||
from .style import StyleElement
|
||||
|
||||
|
||||
# Autogenerated
|
||||
def AmPm(**args):
|
||||
return Element(qname = (NUMBERNS,'am-pm'), **args)
|
||||
|
||||
def Boolean(**args):
|
||||
return Element(qname = (NUMBERNS,'boolean'), **args)
|
||||
|
||||
def BooleanStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'boolean-style'), **args)
|
||||
|
||||
def CurrencyStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'currency-style'), **args)
|
||||
|
||||
def CurrencySymbol(**args):
|
||||
return Element(qname = (NUMBERNS,'currency-symbol'), **args)
|
||||
|
||||
def DateStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'date-style'), **args)
|
||||
|
||||
def Day(**args):
|
||||
return Element(qname = (NUMBERNS,'day'), **args)
|
||||
|
||||
def DayOfWeek(**args):
|
||||
return Element(qname = (NUMBERNS,'day-of-week'), **args)
|
||||
|
||||
def EmbeddedText(**args):
|
||||
return Element(qname = (NUMBERNS,'embedded-text'), **args)
|
||||
|
||||
def Era(**args):
|
||||
return Element(qname = (NUMBERNS,'era'), **args)
|
||||
|
||||
def Fraction(**args):
|
||||
return Element(qname = (NUMBERNS,'fraction'), **args)
|
||||
|
||||
def Hours(**args):
|
||||
return Element(qname = (NUMBERNS,'hours'), **args)
|
||||
|
||||
def Minutes(**args):
|
||||
return Element(qname = (NUMBERNS,'minutes'), **args)
|
||||
|
||||
def Month(**args):
|
||||
return Element(qname = (NUMBERNS,'month'), **args)
|
||||
|
||||
def Number(**args):
|
||||
return Element(qname = (NUMBERNS,'number'), **args)
|
||||
|
||||
def NumberStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'number-style'), **args)
|
||||
|
||||
def PercentageStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'percentage-style'), **args)
|
||||
|
||||
def Quarter(**args):
|
||||
return Element(qname = (NUMBERNS,'quarter'), **args)
|
||||
|
||||
def ScientificNumber(**args):
|
||||
return Element(qname = (NUMBERNS,'scientific-number'), **args)
|
||||
|
||||
def Seconds(**args):
|
||||
return Element(qname = (NUMBERNS,'seconds'), **args)
|
||||
|
||||
def Text(**args):
|
||||
return Element(qname = (NUMBERNS,'text'), **args)
|
||||
|
||||
def TextContent(**args):
|
||||
return Element(qname = (NUMBERNS,'text-content'), **args)
|
||||
|
||||
def TextStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'text-style'), **args)
|
||||
|
||||
def TimeStyle(**args):
|
||||
return StyleElement(qname = (NUMBERNS,'time-style'), **args)
|
||||
|
||||
def WeekOfYear(**args):
|
||||
return Element(qname = (NUMBERNS,'week-of-year'), **args)
|
||||
|
||||
def Year(**args):
|
||||
return Element(qname = (NUMBERNS,'year'), **args)
|
||||
|
||||
@@ -0,0 +1,579 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2008 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# See http://trac.edgewall.org/wiki/WikiFormatting
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
import sys, zipfile, xml.dom.minidom
|
||||
from .namespaces import nsdict
|
||||
from .elementtypes import *
|
||||
|
||||
IGNORED_TAGS = [
|
||||
'draw:a'
|
||||
'draw:g',
|
||||
'draw:line',
|
||||
'draw:object-ole',
|
||||
'office:annotation',
|
||||
'presentation:notes',
|
||||
'svg:desc',
|
||||
] + [ nsdict[item[0]]+":"+item[1] for item in empty_elements]
|
||||
|
||||
INLINE_TAGS = [ nsdict[item[0]]+":"+item[1] for item in inline_elements]
|
||||
|
||||
|
||||
class TextProps:
|
||||
""" Holds properties for a text style. """
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.italic = False
|
||||
self.bold = False
|
||||
self.fixed = False
|
||||
self.underlined = False
|
||||
self.strikethrough = False
|
||||
self.superscript = False
|
||||
self.subscript = False
|
||||
|
||||
def setItalic(self, value):
|
||||
if value == "italic":
|
||||
self.italic = True
|
||||
elif value == "normal":
|
||||
self.italic = False
|
||||
|
||||
def setBold(self, value):
|
||||
if value == "bold":
|
||||
self.bold = True
|
||||
elif value == "normal":
|
||||
self.bold = False
|
||||
|
||||
def setFixed(self, value):
|
||||
self.fixed = value
|
||||
|
||||
def setUnderlined(self, value):
|
||||
if value and value != "none":
|
||||
self.underlined = True
|
||||
|
||||
def setStrikethrough(self, value):
|
||||
if value and value != "none":
|
||||
self.strikethrough = True
|
||||
|
||||
def setPosition(self, value):
|
||||
if value is None or value == '':
|
||||
return
|
||||
posisize = value.split(' ')
|
||||
textpos = posisize[0]
|
||||
if textpos.find('%') == -1:
|
||||
if textpos == "sub":
|
||||
self.superscript = False
|
||||
self.subscript = True
|
||||
elif textpos == "super":
|
||||
self.superscript = True
|
||||
self.subscript = False
|
||||
else:
|
||||
itextpos = int(textpos[:textpos.find('%')])
|
||||
if itextpos > 10:
|
||||
self.superscript = False
|
||||
self.subscript = True
|
||||
elif itextpos < -10:
|
||||
self.superscript = True
|
||||
self.subscript = False
|
||||
|
||||
def __str__(self):
|
||||
|
||||
return "[italic=%s, bold=i%s, fixed=%s]" % (str(self.italic),
|
||||
str(self.bold),
|
||||
str(self.fixed))
|
||||
|
||||
class ParagraphProps:
|
||||
""" Holds properties of a paragraph style. """
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.blockquote = False
|
||||
self.headingLevel = 0
|
||||
self.code = False
|
||||
self.title = False
|
||||
self.indented = 0
|
||||
|
||||
def setIndented(self, value):
|
||||
self.indented = value
|
||||
|
||||
def setHeading(self, level):
|
||||
self.headingLevel = level
|
||||
|
||||
def setTitle(self, value):
|
||||
self.title = value
|
||||
|
||||
def setCode(self, value):
|
||||
self.code = value
|
||||
|
||||
|
||||
def __str__(self):
|
||||
|
||||
return "[bq=%s, h=%d, code=%s]" % (str(self.blockquote),
|
||||
self.headingLevel,
|
||||
str(self.code))
|
||||
|
||||
|
||||
class ListProperties:
|
||||
""" Holds properties for a list style. """
|
||||
|
||||
def __init__(self):
|
||||
self.ordered = False
|
||||
|
||||
def setOrdered(self, value):
|
||||
self.ordered = value
|
||||
|
||||
|
||||
|
||||
class ODF2MoinMoin(object):
|
||||
|
||||
|
||||
def __init__(self, filepath):
|
||||
self.footnotes = []
|
||||
self.footnoteCounter = 0
|
||||
self.textStyles = {"Standard": TextProps()}
|
||||
self.paragraphStyles = {"Standard": ParagraphProps()}
|
||||
self.listStyles = {}
|
||||
self.fixedFonts = []
|
||||
self.hasTitle = 0
|
||||
self.lastsegment = None
|
||||
|
||||
# Tags
|
||||
self.elements = {
|
||||
'draw:page': self.textToString,
|
||||
'draw:frame': self.textToString,
|
||||
'draw:image': self.draw_image,
|
||||
'draw:text-box': self.textToString,
|
||||
'text:a': self.text_a,
|
||||
'text:note': self.text_note,
|
||||
}
|
||||
for tag in IGNORED_TAGS:
|
||||
self.elements[tag] = self.do_nothing
|
||||
|
||||
for tag in INLINE_TAGS:
|
||||
self.elements[tag] = self.inline_markup
|
||||
self.elements['text:line-break'] = self.text_line_break
|
||||
self.elements['text:s'] = self.text_s
|
||||
self.elements['text:tab'] = self.text_tab
|
||||
|
||||
self.load(filepath)
|
||||
|
||||
def processFontDeclarations(self, fontDecl):
|
||||
""" Extracts necessary font information from a font-declaration
|
||||
element.
|
||||
"""
|
||||
for fontFace in fontDecl.getElementsByTagName("style:font-face"):
|
||||
if fontFace.getAttribute("style:font-pitch") == "fixed":
|
||||
self.fixedFonts.append(fontFace.getAttribute("style:name"))
|
||||
|
||||
|
||||
|
||||
def extractTextProperties(self, style, parent=None):
|
||||
""" Extracts text properties from a style element. """
|
||||
|
||||
textProps = TextProps()
|
||||
|
||||
if parent:
|
||||
parentProp = self.textStyles.get(parent, None)
|
||||
if parentProp:
|
||||
textProp = parentProp
|
||||
|
||||
textPropEl = style.getElementsByTagName("style:text-properties")
|
||||
if not textPropEl: return textProps
|
||||
|
||||
textPropEl = textPropEl[0]
|
||||
|
||||
textProps.setItalic(textPropEl.getAttribute("fo:font-style"))
|
||||
textProps.setBold(textPropEl.getAttribute("fo:font-weight"))
|
||||
textProps.setUnderlined(textPropEl.getAttribute("style:text-underline-style"))
|
||||
textProps.setStrikethrough(textPropEl.getAttribute("style:text-line-through-style"))
|
||||
textProps.setPosition(textPropEl.getAttribute("style:text-position"))
|
||||
|
||||
if textPropEl.getAttribute("style:font-name") in self.fixedFonts:
|
||||
textProps.setFixed(True)
|
||||
|
||||
return textProps
|
||||
|
||||
def extractParagraphProperties(self, style, parent=None):
|
||||
""" Extracts paragraph properties from a style element. """
|
||||
|
||||
paraProps = ParagraphProps()
|
||||
|
||||
name = style.getAttribute("style:name")
|
||||
|
||||
if name.startswith("Heading_20_"):
|
||||
level = name[11:]
|
||||
try:
|
||||
level = int(level)
|
||||
paraProps.setHeading(level)
|
||||
except:
|
||||
level = 0
|
||||
|
||||
if name == "Title":
|
||||
paraProps.setTitle(True)
|
||||
|
||||
paraPropEl = style.getElementsByTagName("style:paragraph-properties")
|
||||
if paraPropEl:
|
||||
paraPropEl = paraPropEl[0]
|
||||
leftMargin = paraPropEl.getAttribute("fo:margin-left")
|
||||
if leftMargin:
|
||||
try:
|
||||
leftMargin = float(leftMargin[:-2])
|
||||
if leftMargin > 0.01:
|
||||
paraProps.setIndented(True)
|
||||
except:
|
||||
pass
|
||||
|
||||
textProps = self.extractTextProperties(style)
|
||||
if textProps.fixed:
|
||||
paraProps.setCode(True)
|
||||
|
||||
return paraProps
|
||||
|
||||
|
||||
def processStyles(self, styleElements):
|
||||
""" Runs through "style" elements extracting necessary information.
|
||||
"""
|
||||
|
||||
for style in styleElements:
|
||||
|
||||
name = style.getAttribute("style:name")
|
||||
|
||||
if name == "Standard": continue
|
||||
|
||||
family = style.getAttribute("style:family")
|
||||
parent = style.getAttribute("style:parent-style-name")
|
||||
|
||||
if family == "text":
|
||||
self.textStyles[name] = self.extractTextProperties(style, parent)
|
||||
|
||||
elif family == "paragraph":
|
||||
self.paragraphStyles[name] = \
|
||||
self.extractParagraphProperties(style, parent)
|
||||
self.textStyles[name] = self.extractTextProperties(style, parent)
|
||||
|
||||
def processListStyles(self, listStyleElements):
|
||||
|
||||
for style in listStyleElements:
|
||||
name = style.getAttribute("style:name")
|
||||
|
||||
prop = ListProperties()
|
||||
if style.hasChildNodes():
|
||||
subitems = [el for el in style.childNodes
|
||||
if el.nodeType == xml.dom.Node.ELEMENT_NODE
|
||||
and el.tagName == "text:list-level-style-number"]
|
||||
if len(subitems) > 0:
|
||||
prop.setOrdered(True)
|
||||
|
||||
self.listStyles[name] = prop
|
||||
|
||||
|
||||
def load(self, filepath):
|
||||
""" Loads an ODT file. """
|
||||
|
||||
zip = zipfile.ZipFile(filepath)
|
||||
|
||||
styles_doc = xml.dom.minidom.parseString(zip.read("styles.xml"))
|
||||
fontfacedecls = styles_doc.getElementsByTagName("office:font-face-decls")
|
||||
if fontfacedecls:
|
||||
self.processFontDeclarations(fontfacedecls[0])
|
||||
self.processStyles(styles_doc.getElementsByTagName("style:style"))
|
||||
self.processListStyles(styles_doc.getElementsByTagName("text:list-style"))
|
||||
|
||||
self.content = xml.dom.minidom.parseString(zip.read("content.xml"))
|
||||
fontfacedecls = self.content.getElementsByTagName("office:font-face-decls")
|
||||
if fontfacedecls:
|
||||
self.processFontDeclarations(fontfacedecls[0])
|
||||
|
||||
self.processStyles(self.content.getElementsByTagName("style:style"))
|
||||
self.processListStyles(self.content.getElementsByTagName("text:list-style"))
|
||||
|
||||
def compressCodeBlocks(self, text):
|
||||
""" Removes extra blank lines from code blocks. """
|
||||
|
||||
return text
|
||||
lines = text.split("\n")
|
||||
buffer = []
|
||||
numLines = len(lines)
|
||||
for i in range(numLines):
|
||||
|
||||
if (lines[i].strip() or i == numLines-1 or i == 0 or
|
||||
not ( lines[i-1].startswith(" ")
|
||||
and lines[i+1].startswith(" ") ) ):
|
||||
buffer.append("\n" + lines[i])
|
||||
|
||||
return ''.join(buffer)
|
||||
|
||||
#-----------------------------------
|
||||
def do_nothing(self, node):
|
||||
return ''
|
||||
|
||||
def draw_image(self, node):
|
||||
"""
|
||||
"""
|
||||
|
||||
link = node.getAttribute("xlink:href")
|
||||
if link and link[:2] == './': # Indicates a sub-object, which isn't supported
|
||||
return "%s\n" % link
|
||||
if link and link[:9] == 'Pictures/':
|
||||
link = link[9:]
|
||||
return "[[Image(%s)]]\n" % link
|
||||
|
||||
def text_a(self, node):
|
||||
text = self.textToString(node)
|
||||
link = node.getAttribute("xlink:href")
|
||||
if link.strip() == text.strip():
|
||||
return "[%s] " % link.strip()
|
||||
else:
|
||||
return "[%s %s] " % (link.strip(), text.strip())
|
||||
|
||||
|
||||
def text_line_break(self, node):
|
||||
return "[[BR]]"
|
||||
|
||||
def text_note(self, node):
|
||||
cite = (node.getElementsByTagName("text:note-citation")[0]
|
||||
.childNodes[0].nodeValue)
|
||||
body = (node.getElementsByTagName("text:note-body")[0]
|
||||
.childNodes[0])
|
||||
self.footnotes.append((cite, self.textToString(body)))
|
||||
return "^%s^" % cite
|
||||
|
||||
def text_s(self, node):
|
||||
try:
|
||||
num = int(node.getAttribute("text:c"))
|
||||
return " "*num
|
||||
except:
|
||||
return " "
|
||||
|
||||
def text_tab(self, node):
|
||||
return " "
|
||||
|
||||
def inline_markup(self, node):
|
||||
text = self.textToString(node)
|
||||
|
||||
if not text.strip():
|
||||
return '' # don't apply styles to white space
|
||||
|
||||
styleName = node.getAttribute("text:style-name")
|
||||
style = self.textStyles.get(styleName, TextProps())
|
||||
|
||||
if style.fixed:
|
||||
return "`" + text + "`"
|
||||
|
||||
mark = []
|
||||
if style:
|
||||
if style.italic:
|
||||
mark.append("''")
|
||||
if style.bold:
|
||||
mark.append("'''")
|
||||
if style.underlined:
|
||||
mark.append("__")
|
||||
if style.strikethrough:
|
||||
mark.append("~~")
|
||||
if style.superscript:
|
||||
mark.append("^")
|
||||
if style.subscript:
|
||||
mark.append(",,")
|
||||
revmark = mark[:]
|
||||
revmark.reverse()
|
||||
return "%s%s%s" % (''.join(mark), text, ''.join(revmark))
|
||||
|
||||
#-----------------------------------
|
||||
def listToString(self, listElement, indent = 0):
|
||||
|
||||
self.lastsegment = listElement.tagName
|
||||
buffer = []
|
||||
|
||||
styleName = listElement.getAttribute("text:style-name")
|
||||
props = self.listStyles.get(styleName, ListProperties())
|
||||
|
||||
i = 0
|
||||
for item in listElement.childNodes:
|
||||
buffer.append(" "*indent)
|
||||
i += 1
|
||||
if props.ordered:
|
||||
number = str(i)
|
||||
number = " " + number + ". "
|
||||
buffer.append(" 1. ")
|
||||
else:
|
||||
buffer.append(" * ")
|
||||
subitems = [el for el in item.childNodes
|
||||
if el.tagName in ["text:p", "text:h", "text:list"]]
|
||||
for subitem in subitems:
|
||||
if subitem.tagName == "text:list":
|
||||
buffer.append("\n")
|
||||
buffer.append(self.listToString(subitem, indent+3))
|
||||
else:
|
||||
buffer.append(self.paragraphToString(subitem, indent+3))
|
||||
self.lastsegment = subitem.tagName
|
||||
self.lastsegment = item.tagName
|
||||
buffer.append("\n")
|
||||
|
||||
return ''.join(buffer)
|
||||
|
||||
def tableToString(self, tableElement):
|
||||
""" MoinMoin uses || to delimit table cells
|
||||
"""
|
||||
|
||||
self.lastsegment = tableElement.tagName
|
||||
buffer = []
|
||||
|
||||
for item in tableElement.childNodes:
|
||||
self.lastsegment = item.tagName
|
||||
if item.tagName == "table:table-header-rows":
|
||||
buffer.append(self.tableToString(item))
|
||||
if item.tagName == "table:table-row":
|
||||
buffer.append("\n||")
|
||||
for cell in item.childNodes:
|
||||
buffer.append(self.inline_markup(cell))
|
||||
buffer.append("||")
|
||||
self.lastsegment = cell.tagName
|
||||
return ''.join(buffer)
|
||||
|
||||
|
||||
def toString(self):
|
||||
""" Converts the document to a string.
|
||||
FIXME: Result from second call differs from first call
|
||||
"""
|
||||
body = self.content.getElementsByTagName("office:body")[0]
|
||||
text = body.childNodes[0]
|
||||
|
||||
buffer = []
|
||||
|
||||
paragraphs = [el for el in text.childNodes
|
||||
if el.tagName in ["draw:page", "text:p", "text:h","text:section",
|
||||
"text:list", "table:table"]]
|
||||
|
||||
for paragraph in paragraphs:
|
||||
if paragraph.tagName == "text:list":
|
||||
text = self.listToString(paragraph)
|
||||
elif paragraph.tagName == "text:section":
|
||||
text = self.textToString(paragraph)
|
||||
elif paragraph.tagName == "table:table":
|
||||
text = self.tableToString(paragraph)
|
||||
else:
|
||||
text = self.paragraphToString(paragraph)
|
||||
if text:
|
||||
buffer.append(text)
|
||||
|
||||
if self.footnotes:
|
||||
|
||||
buffer.append("----")
|
||||
for cite, body in self.footnotes:
|
||||
buffer.append("%s: %s" % (cite, body))
|
||||
|
||||
|
||||
buffer.append("")
|
||||
return self.compressCodeBlocks('\n'.join(buffer))
|
||||
|
||||
|
||||
def textToString(self, element):
|
||||
|
||||
buffer = []
|
||||
|
||||
for node in element.childNodes:
|
||||
|
||||
if node.nodeType == xml.dom.Node.TEXT_NODE:
|
||||
buffer.append(node.nodeValue)
|
||||
|
||||
elif node.nodeType == xml.dom.Node.ELEMENT_NODE:
|
||||
tag = node.tagName
|
||||
|
||||
if tag in ("draw:text-box", "draw:frame"):
|
||||
buffer.append(self.textToString(node))
|
||||
|
||||
elif tag in ("text:p", "text:h"):
|
||||
text = self.paragraphToString(node)
|
||||
if text:
|
||||
buffer.append(text)
|
||||
elif tag == "text:list":
|
||||
buffer.append(self.listToString(node))
|
||||
else:
|
||||
method = self.elements.get(tag)
|
||||
if method:
|
||||
buffer.append(method(node))
|
||||
else:
|
||||
buffer.append(" {" + tag + "} ")
|
||||
|
||||
return ''.join(buffer)
|
||||
|
||||
def paragraphToString(self, paragraph, indent = 0):
|
||||
|
||||
dummyParaProps = ParagraphProps()
|
||||
|
||||
style_name = paragraph.getAttribute("text:style-name")
|
||||
paraProps = self.paragraphStyles.get(style_name, dummyParaProps)
|
||||
text = self.inline_markup(paragraph)
|
||||
|
||||
if paraProps and not paraProps.code:
|
||||
text = text.strip()
|
||||
|
||||
if paragraph.tagName == "text:p" and self.lastsegment == "text:p":
|
||||
text = "\n" + text
|
||||
|
||||
self.lastsegment = paragraph.tagName
|
||||
|
||||
if paraProps.title:
|
||||
self.hasTitle = 1
|
||||
return "= " + text + " =\n"
|
||||
|
||||
outlinelevel = paragraph.getAttribute("text:outline-level")
|
||||
if outlinelevel:
|
||||
|
||||
level = int(outlinelevel)
|
||||
if self.hasTitle: level += 1
|
||||
|
||||
if level >= 1:
|
||||
return "=" * level + " " + text + " " + "=" * level + "\n"
|
||||
|
||||
elif paraProps.code:
|
||||
return "{{{\n" + text + "\n}}}\n"
|
||||
|
||||
if paraProps.indented:
|
||||
return self.wrapParagraph(text, indent = indent, blockquote = True)
|
||||
|
||||
else:
|
||||
return self.wrapParagraph(text, indent = indent)
|
||||
|
||||
|
||||
def wrapParagraph(self, text, indent = 0, blockquote=False):
|
||||
|
||||
counter = 0
|
||||
buffer = []
|
||||
LIMIT = 50
|
||||
|
||||
if blockquote:
|
||||
buffer.append(" ")
|
||||
|
||||
return ''.join(buffer) + text
|
||||
# Unused from here
|
||||
for token in text.split():
|
||||
|
||||
if counter > LIMIT - indent:
|
||||
buffer.append("\n" + " "*indent)
|
||||
if blockquote:
|
||||
buffer.append(" ")
|
||||
counter = 0
|
||||
|
||||
buffer.append(token + " ")
|
||||
counter += len(token)
|
||||
|
||||
return ''.join(buffer)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
# This script lists the content of the manifest.xml file
|
||||
import zipfile
|
||||
from xml.sax import make_parser,handler
|
||||
from xml.sax.xmlreader import InputSource
|
||||
import xml.sax.saxutils
|
||||
from io import StringIO
|
||||
|
||||
MANIFESTNS="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# ODFMANIFESTHANDLER
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
class ODFManifestHandler(handler.ContentHandler):
|
||||
""" The ODFManifestHandler parses a manifest file and produces a list of
|
||||
content """
|
||||
|
||||
def __init__(self):
|
||||
self.manifest = {}
|
||||
|
||||
# Tags
|
||||
# FIXME: Also handle encryption data
|
||||
self.elements = {
|
||||
(MANIFESTNS, 'file-entry'): (self.s_file_entry, self.donothing),
|
||||
}
|
||||
|
||||
def handle_starttag(self, tag, method, attrs):
|
||||
method(tag,attrs)
|
||||
|
||||
def handle_endtag(self, tag, method):
|
||||
method(tag)
|
||||
|
||||
def startElementNS(self, tag, qname, attrs):
|
||||
method = self.elements.get(tag, (None, None))[0]
|
||||
if method:
|
||||
self.handle_starttag(tag, method, attrs)
|
||||
else:
|
||||
self.unknown_starttag(tag,attrs)
|
||||
|
||||
def endElementNS(self, tag, qname):
|
||||
method = self.elements.get(tag, (None, None))[1]
|
||||
if method:
|
||||
self.handle_endtag(tag, method)
|
||||
else:
|
||||
self.unknown_endtag(tag)
|
||||
|
||||
def unknown_starttag(self, tag, attrs):
|
||||
pass
|
||||
|
||||
def unknown_endtag(self, tag):
|
||||
pass
|
||||
|
||||
def donothing(self, tag, attrs=None):
|
||||
pass
|
||||
|
||||
def s_file_entry(self, tag, attrs):
|
||||
m = attrs.get((MANIFESTNS, 'media-type'),"application/octet-stream")
|
||||
p = attrs.get((MANIFESTNS, 'full-path'))
|
||||
self.manifest[p] = { 'media-type':m, 'full-path':p }
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Reading the file
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
def manifestlist(manifestxml):
|
||||
odhandler = ODFManifestHandler()
|
||||
parser = make_parser()
|
||||
parser.setFeature(handler.feature_namespaces, 1)
|
||||
parser.setContentHandler(odhandler)
|
||||
parser.setErrorHandler(handler.ErrorHandler())
|
||||
|
||||
inpsrc = InputSource()
|
||||
inpsrc.setByteStream(StringIO(manifestxml))
|
||||
parser.parse(inpsrc)
|
||||
|
||||
return odhandler.manifest
|
||||
|
||||
def odfmanifest(odtfile):
|
||||
z = zipfile.ZipFile(odtfile)
|
||||
manifest = z.read('META-INF/manifest.xml')
|
||||
z.close()
|
||||
return manifestlist(manifest)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
result = odfmanifest(sys.argv[1])
|
||||
for file in list(result.values()):
|
||||
print("%-40s %-40s" % (file['media-type'], file['full-path']))
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import OFFICENS
|
||||
from .element import Element
|
||||
from .draw import StyleRefElement
|
||||
|
||||
# Autogenerated
|
||||
def Annotation(**args):
|
||||
return StyleRefElement(qname = (OFFICENS,'annotation'), **args)
|
||||
|
||||
def AutomaticStyles(**args):
|
||||
return Element(qname = (OFFICENS, 'automatic-styles'), **args)
|
||||
|
||||
def BinaryData(**args):
|
||||
return Element(qname = (OFFICENS,'binary-data'), **args)
|
||||
|
||||
def Body(**args):
|
||||
return Element(qname = (OFFICENS, 'body'), **args)
|
||||
|
||||
def ChangeInfo(**args):
|
||||
return Element(qname = (OFFICENS,'change-info'), **args)
|
||||
|
||||
def Chart(**args):
|
||||
return Element(qname = (OFFICENS,'chart'), **args)
|
||||
|
||||
def DdeSource(**args):
|
||||
return Element(qname = (OFFICENS,'dde-source'), **args)
|
||||
|
||||
def Document(version="1.1", **args):
|
||||
return Element(qname = (OFFICENS,'document'), version=version, **args)
|
||||
|
||||
def DocumentContent(version="1.1", **args):
|
||||
return Element(qname = (OFFICENS, 'document-content'), version=version, **args)
|
||||
|
||||
def DocumentMeta(version="1.1", **args):
|
||||
return Element(qname = (OFFICENS, 'document-meta'), version=version, **args)
|
||||
|
||||
def DocumentSettings(version="1.1", **args):
|
||||
return Element(qname = (OFFICENS, 'document-settings'), version=version, **args)
|
||||
|
||||
def DocumentStyles(version="1.1", **args):
|
||||
return Element(qname = (OFFICENS, 'document-styles'), version=version, **args)
|
||||
|
||||
def Drawing(**args):
|
||||
return Element(qname = (OFFICENS,'drawing'), **args)
|
||||
|
||||
def EventListeners(**args):
|
||||
return Element(qname = (OFFICENS,'event-listeners'), **args)
|
||||
|
||||
def FontFaceDecls(**args):
|
||||
return Element(qname = (OFFICENS, 'font-face-decls'), **args)
|
||||
|
||||
def Forms(**args):
|
||||
return Element(qname = (OFFICENS,'forms'), **args)
|
||||
|
||||
def Image(**args):
|
||||
return Element(qname = (OFFICENS,'image'), **args)
|
||||
|
||||
def MasterStyles(**args):
|
||||
return Element(qname = (OFFICENS, 'master-styles'), **args)
|
||||
|
||||
def Meta(**args):
|
||||
return Element(qname = (OFFICENS, 'meta'), **args)
|
||||
|
||||
def Presentation(**args):
|
||||
return Element(qname = (OFFICENS,'presentation'), **args)
|
||||
|
||||
def Script(**args):
|
||||
return Element(qname = (OFFICENS, 'script'), **args)
|
||||
|
||||
def Scripts(**args):
|
||||
return Element(qname = (OFFICENS, 'scripts'), **args)
|
||||
|
||||
def Settings(**args):
|
||||
return Element(qname = (OFFICENS, 'settings'), **args)
|
||||
|
||||
def Spreadsheet(**args):
|
||||
return Element(qname = (OFFICENS, 'spreadsheet'), **args)
|
||||
|
||||
def Styles(**args):
|
||||
return Element(qname = (OFFICENS, 'styles'), **args)
|
||||
|
||||
def Text(**args):
|
||||
return Element(qname = (OFFICENS, 'text'), **args)
|
||||
|
||||
# Autogenerated end
|
||||
@@ -0,0 +1,654 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2010 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
__doc__="""Use OpenDocument to generate your documents."""
|
||||
|
||||
import zipfile, time, sys, mimetypes, copy
|
||||
from io import StringIO
|
||||
from .namespaces import *
|
||||
from . import manifest, meta
|
||||
from .office import *
|
||||
from . import element
|
||||
from .attrconverters import make_NCName
|
||||
from xml.sax.xmlreader import InputSource
|
||||
from .odfmanifest import manifestlist
|
||||
|
||||
__version__= TOOLSVERSION
|
||||
|
||||
_XMLPROLOGUE = "<?xml version='1.0' encoding='UTF-8'?>\n"
|
||||
|
||||
UNIXPERMS = 0o100644 << 16 # -rw-r--r--
|
||||
|
||||
IS_FILENAME = 0
|
||||
IS_IMAGE = 1
|
||||
# We need at least Python 2.2
|
||||
assert sys.version_info[0]>=2 and sys.version_info[1] >= 2
|
||||
|
||||
#sys.setrecursionlimit(100)
|
||||
#The recursion limit is set conservative so mistakes like
|
||||
# s=content() s.addElement(s) won't eat up too much processor time.
|
||||
|
||||
odmimetypes = {
|
||||
'application/vnd.oasis.opendocument.text': '.odt',
|
||||
'application/vnd.oasis.opendocument.text-template': '.ott',
|
||||
'application/vnd.oasis.opendocument.graphics': '.odg',
|
||||
'application/vnd.oasis.opendocument.graphics-template': '.otg',
|
||||
'application/vnd.oasis.opendocument.presentation': '.odp',
|
||||
'application/vnd.oasis.opendocument.presentation-template': '.otp',
|
||||
'application/vnd.oasis.opendocument.spreadsheet': '.ods',
|
||||
'application/vnd.oasis.opendocument.spreadsheet-template': '.ots',
|
||||
'application/vnd.oasis.opendocument.chart': '.odc',
|
||||
'application/vnd.oasis.opendocument.chart-template': '.otc',
|
||||
'application/vnd.oasis.opendocument.image': '.odi',
|
||||
'application/vnd.oasis.opendocument.image-template': '.oti',
|
||||
'application/vnd.oasis.opendocument.formula': '.odf',
|
||||
'application/vnd.oasis.opendocument.formula-template': '.otf',
|
||||
'application/vnd.oasis.opendocument.text-master': '.odm',
|
||||
'application/vnd.oasis.opendocument.text-web': '.oth',
|
||||
}
|
||||
|
||||
class OpaqueObject:
|
||||
def __init__(self, filename, mediatype, content=None):
|
||||
self.mediatype = mediatype
|
||||
self.filename = filename
|
||||
self.content = content
|
||||
|
||||
class OpenDocument:
|
||||
""" A class to hold the content of an OpenDocument document
|
||||
Use the xml method to write the XML
|
||||
source to the screen or to a file
|
||||
d = OpenDocument(mimetype)
|
||||
fd.write(d.xml())
|
||||
"""
|
||||
thumbnail = None
|
||||
|
||||
def __init__(self, mimetype, add_generator=True):
|
||||
self.mimetype = mimetype
|
||||
self.childobjects = []
|
||||
self._extra = []
|
||||
self.folder = "" # Always empty for toplevel documents
|
||||
self.topnode = Document(mimetype=self.mimetype)
|
||||
self.topnode.ownerDocument = self
|
||||
|
||||
self.clear_caches()
|
||||
|
||||
self.Pictures = {}
|
||||
self.meta = Meta()
|
||||
self.topnode.addElement(self.meta)
|
||||
if add_generator:
|
||||
self.meta.addElement(meta.Generator(text=TOOLSVERSION))
|
||||
self.scripts = Scripts()
|
||||
self.topnode.addElement(self.scripts)
|
||||
self.fontfacedecls = FontFaceDecls()
|
||||
self.topnode.addElement(self.fontfacedecls)
|
||||
self.settings = Settings()
|
||||
self.topnode.addElement(self.settings)
|
||||
self.styles = Styles()
|
||||
self.topnode.addElement(self.styles)
|
||||
self.automaticstyles = AutomaticStyles()
|
||||
self.topnode.addElement(self.automaticstyles)
|
||||
self.masterstyles = MasterStyles()
|
||||
self.topnode.addElement(self.masterstyles)
|
||||
self.body = Body()
|
||||
self.topnode.addElement(self.body)
|
||||
|
||||
def rebuild_caches(self, node=None):
|
||||
if node is None: node = self.topnode
|
||||
self.build_caches(node)
|
||||
for e in node.childNodes:
|
||||
if e.nodeType == element.Node.ELEMENT_NODE:
|
||||
self.rebuild_caches(e)
|
||||
|
||||
def clear_caches(self):
|
||||
self.element_dict = {}
|
||||
self._styles_dict = {}
|
||||
self._styles_ooo_fix = {}
|
||||
|
||||
def build_caches(self, element):
|
||||
""" Called from element.py
|
||||
"""
|
||||
if element.qname not in self.element_dict:
|
||||
self.element_dict[element.qname] = []
|
||||
self.element_dict[element.qname].append(element)
|
||||
if element.qname == (STYLENS, 'style'):
|
||||
self.__register_stylename(element) # Add to style dictionary
|
||||
styleref = element.getAttrNS(TEXTNS,'style-name')
|
||||
if styleref is not None and styleref in self._styles_ooo_fix:
|
||||
element.setAttrNS(TEXTNS,'style-name', self._styles_ooo_fix[styleref])
|
||||
|
||||
def __register_stylename(self, element):
|
||||
''' Register a style. But there are three style dictionaries:
|
||||
office:styles, office:automatic-styles and office:master-styles
|
||||
Chapter 14
|
||||
'''
|
||||
name = element.getAttrNS(STYLENS, 'name')
|
||||
if name is None:
|
||||
return
|
||||
if element.parentNode.qname in ((OFFICENS,'styles'), (OFFICENS,'automatic-styles')):
|
||||
if name in self._styles_dict:
|
||||
newname = 'M'+name # Rename style
|
||||
self._styles_ooo_fix[name] = newname
|
||||
# From here on all references to the old name will refer to the new one
|
||||
name = newname
|
||||
element.setAttrNS(STYLENS, 'name', name)
|
||||
self._styles_dict[name] = element
|
||||
|
||||
def toXml(self, filename=''):
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
self.body.toXml(0, xml)
|
||||
if not filename:
|
||||
return xml.getvalue()
|
||||
else:
|
||||
f=file(filename,'w')
|
||||
f.write(xml.getvalue())
|
||||
f.close()
|
||||
|
||||
def xml(self):
|
||||
""" Generates the full document as an XML file
|
||||
Always written as a bytestream in UTF-8 encoding
|
||||
"""
|
||||
self.__replaceGenerator()
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
self.topnode.toXml(0, xml)
|
||||
return xml.getvalue()
|
||||
|
||||
|
||||
def contentxml(self):
|
||||
""" Generates the content.xml file
|
||||
Always written as a bytestream in UTF-8 encoding
|
||||
"""
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
x = DocumentContent()
|
||||
x.write_open_tag(0, xml)
|
||||
if self.scripts.hasChildNodes():
|
||||
self.scripts.toXml(1, xml)
|
||||
if self.fontfacedecls.hasChildNodes():
|
||||
self.fontfacedecls.toXml(1, xml)
|
||||
a = AutomaticStyles()
|
||||
stylelist = self._used_auto_styles([self.styles, self.automaticstyles, self.body])
|
||||
if len(stylelist) > 0:
|
||||
a.write_open_tag(1, xml)
|
||||
for s in stylelist:
|
||||
s.toXml(2, xml)
|
||||
a.write_close_tag(1, xml)
|
||||
else:
|
||||
a.toXml(1, xml)
|
||||
self.body.toXml(1, xml)
|
||||
x.write_close_tag(0, xml)
|
||||
return xml.getvalue()
|
||||
|
||||
def __manifestxml(self):
|
||||
""" Generates the manifest.xml file
|
||||
The self.manifest isn't avaible unless the document is being saved
|
||||
"""
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
self.manifest.toXml(0,xml)
|
||||
return xml.getvalue()
|
||||
|
||||
def metaxml(self):
|
||||
""" Generates the meta.xml file """
|
||||
self.__replaceGenerator()
|
||||
x = DocumentMeta()
|
||||
x.addElement(self.meta)
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
x.toXml(0,xml)
|
||||
return xml.getvalue()
|
||||
|
||||
def settingsxml(self):
|
||||
""" Generates the settings.xml file """
|
||||
x = DocumentSettings()
|
||||
x.addElement(self.settings)
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
x.toXml(0,xml)
|
||||
return xml.getvalue()
|
||||
|
||||
def _parseoneelement(self, top, stylenamelist):
|
||||
""" Finds references to style objects in master-styles
|
||||
and add the style name to the style list if not already there.
|
||||
Recursive
|
||||
"""
|
||||
for e in top.childNodes:
|
||||
if e.nodeType == element.Node.ELEMENT_NODE:
|
||||
for styleref in ( (DRAWNS,'style-name'),
|
||||
(DRAWNS,'text-style-name'),
|
||||
(PRESENTATIONNS,'style-name'),
|
||||
(STYLENS,'data-style-name'),
|
||||
(STYLENS,'list-style-name'),
|
||||
(STYLENS,'page-layout-name'),
|
||||
(STYLENS,'style-name'),
|
||||
(TABLENS,'default-cell-style-name'),
|
||||
(TABLENS,'style-name'),
|
||||
(TEXTNS,'style-name') ):
|
||||
if e.getAttrNS(styleref[0],styleref[1]):
|
||||
stylename = e.getAttrNS(styleref[0],styleref[1])
|
||||
if stylename not in stylenamelist:
|
||||
stylenamelist.append(stylename)
|
||||
stylenamelist = self._parseoneelement(e, stylenamelist)
|
||||
return stylenamelist
|
||||
|
||||
def _used_auto_styles(self, segments):
|
||||
""" Loop through the masterstyles elements, and find the automatic
|
||||
styles that are used. These will be added to the automatic-styles
|
||||
element in styles.xml
|
||||
"""
|
||||
stylenamelist = []
|
||||
for top in segments:
|
||||
stylenamelist = self._parseoneelement(top, stylenamelist)
|
||||
stylelist = []
|
||||
for e in self.automaticstyles.childNodes:
|
||||
if e.getAttrNS(STYLENS,'name') in stylenamelist:
|
||||
stylelist.append(e)
|
||||
return stylelist
|
||||
|
||||
def stylesxml(self):
|
||||
""" Generates the styles.xml file """
|
||||
xml=StringIO()
|
||||
xml.write(_XMLPROLOGUE)
|
||||
x = DocumentStyles()
|
||||
x.write_open_tag(0, xml)
|
||||
if self.fontfacedecls.hasChildNodes():
|
||||
self.fontfacedecls.toXml(1, xml)
|
||||
self.styles.toXml(1, xml)
|
||||
a = AutomaticStyles()
|
||||
a.write_open_tag(1, xml)
|
||||
for s in self._used_auto_styles([self.masterstyles]):
|
||||
s.toXml(2, xml)
|
||||
a.write_close_tag(1, xml)
|
||||
if self.masterstyles.hasChildNodes():
|
||||
self.masterstyles.toXml(1, xml)
|
||||
x.write_close_tag(0, xml)
|
||||
return xml.getvalue()
|
||||
|
||||
def addPicture(self, filename, mediatype=None, content=None):
|
||||
""" Add a picture
|
||||
It uses the same convention as OOo, in that it saves the picture in
|
||||
the zipfile in the subdirectory 'Pictures'
|
||||
If passed a file ptr, mediatype must be set
|
||||
"""
|
||||
if content is None:
|
||||
if mediatype is None:
|
||||
mediatype, encoding = mimetypes.guess_type(filename)
|
||||
if mediatype is None:
|
||||
mediatype = ''
|
||||
try: ext = filename[filename.rindex('.'):]
|
||||
except: ext=''
|
||||
else:
|
||||
ext = mimetypes.guess_extension(mediatype)
|
||||
manifestfn = "Pictures/%0.0f%s" % ((time.time()*10000000000), ext)
|
||||
self.Pictures[manifestfn] = (IS_FILENAME, filename, mediatype)
|
||||
else:
|
||||
manifestfn = filename
|
||||
self.Pictures[manifestfn] = (IS_IMAGE, content, mediatype)
|
||||
return manifestfn
|
||||
|
||||
def addPictureFromFile(self, filename, mediatype=None):
|
||||
""" Add a picture
|
||||
It uses the same convention as OOo, in that it saves the picture in
|
||||
the zipfile in the subdirectory 'Pictures'.
|
||||
If mediatype is not given, it will be guessed from the filename
|
||||
extension.
|
||||
"""
|
||||
if mediatype is None:
|
||||
mediatype, encoding = mimetypes.guess_type(filename)
|
||||
if mediatype is None:
|
||||
mediatype = ''
|
||||
try: ext = filename[filename.rindex('.'):]
|
||||
except ValueError: ext=''
|
||||
else:
|
||||
ext = mimetypes.guess_extension(mediatype)
|
||||
manifestfn = "Pictures/%0.0f%s" % ((time.time()*10000000000), ext)
|
||||
self.Pictures[manifestfn] = (IS_FILENAME, filename, mediatype)
|
||||
return manifestfn
|
||||
|
||||
def addPictureFromString(self, content, mediatype):
|
||||
""" Add a picture
|
||||
It uses the same convention as OOo, in that it saves the picture in
|
||||
the zipfile in the subdirectory 'Pictures'. The content variable
|
||||
is a string that contains the binary image data. The mediatype
|
||||
indicates the image format.
|
||||
"""
|
||||
ext = mimetypes.guess_extension(mediatype)
|
||||
manifestfn = "Pictures/%0.0f%s" % ((time.time()*10000000000), ext)
|
||||
self.Pictures[manifestfn] = (IS_IMAGE, content, mediatype)
|
||||
return manifestfn
|
||||
|
||||
def addThumbnail(self, filecontent=None):
|
||||
""" Add a fixed thumbnail
|
||||
The thumbnail in the library is big, so this is pretty useless.
|
||||
"""
|
||||
if filecontent is None:
|
||||
from . import thumbnail
|
||||
self.thumbnail = thumbnail.thumbnail()
|
||||
else:
|
||||
self.thumbnail = filecontent
|
||||
|
||||
def addObject(self, document, objectname=None):
|
||||
""" Adds an object (subdocument). The object must be an OpenDocument class
|
||||
The return value will be the folder in the zipfile the object is stored in
|
||||
"""
|
||||
self.childobjects.append(document)
|
||||
if objectname is None:
|
||||
document.folder = "%s/Object %d" % (self.folder, len(self.childobjects))
|
||||
else:
|
||||
document.folder = objectname
|
||||
return ".%s" % document.folder
|
||||
|
||||
def _savePictures(self, object, folder):
|
||||
hasPictures = False
|
||||
for arcname, picturerec in list(object.Pictures.items()):
|
||||
what_it_is, fileobj, mediatype = picturerec
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="%s%s" % ( folder ,arcname), mediatype=mediatype))
|
||||
hasPictures = True
|
||||
if what_it_is == IS_FILENAME:
|
||||
self._z.write(fileobj, arcname, zipfile.ZIP_STORED)
|
||||
else:
|
||||
zi = zipfile.ZipInfo(str(arcname), self._now)
|
||||
zi.compress_type = zipfile.ZIP_STORED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, fileobj)
|
||||
# According to section 17.7.3 in ODF 1.1, the pictures folder should not have a manifest entry
|
||||
# if hasPictures:
|
||||
# self.manifest.addElement(manifest.FileEntry(fullpath="%sPictures/" % folder, mediatype=""))
|
||||
# Look in subobjects
|
||||
subobjectnum = 1
|
||||
for subobject in object.childobjects:
|
||||
self._savePictures(subobject,'%sObject %d/' % (folder, subobjectnum))
|
||||
subobjectnum += 1
|
||||
|
||||
def __replaceGenerator(self):
|
||||
""" Section 3.1.1: The application MUST NOT export the original identifier
|
||||
belonging to the application that created the document.
|
||||
"""
|
||||
for m in self.meta.childNodes[:]:
|
||||
if m.qname == (METANS, 'generator'):
|
||||
self.meta.removeChild(m)
|
||||
self.meta.addElement(meta.Generator(text=TOOLSVERSION))
|
||||
|
||||
def save(self, outputfile, addsuffix=False):
|
||||
""" Save the document under the filename.
|
||||
If the filename is '-' then save to stdout
|
||||
"""
|
||||
if outputfile == '-':
|
||||
outputfp = zipfile.ZipFile(sys.stdout,"w")
|
||||
else:
|
||||
if addsuffix:
|
||||
outputfile = outputfile + odmimetypes.get(self.mimetype,'.xxx')
|
||||
outputfp = zipfile.ZipFile(outputfile, "w")
|
||||
self.__zipwrite(outputfp)
|
||||
outputfp.close()
|
||||
|
||||
def write(self, outputfp):
|
||||
""" User API to write the ODF file to an open file descriptor
|
||||
Writes the ZIP format
|
||||
"""
|
||||
zipoutputfp = zipfile.ZipFile(outputfp,"w")
|
||||
self.__zipwrite(zipoutputfp)
|
||||
|
||||
def __zipwrite(self, outputfp):
|
||||
""" Write the document to an open file pointer
|
||||
This is where the real work is done
|
||||
"""
|
||||
self._z = outputfp
|
||||
self._now = time.localtime()[:6]
|
||||
self.manifest = manifest.Manifest()
|
||||
|
||||
# Write mimetype
|
||||
zi = zipfile.ZipInfo('mimetype', self._now)
|
||||
zi.compress_type = zipfile.ZIP_STORED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, self.mimetype)
|
||||
|
||||
self._saveXmlObjects(self,"")
|
||||
|
||||
# Write pictures
|
||||
self._savePictures(self,"")
|
||||
|
||||
# Write the thumbnail
|
||||
if self.thumbnail is not None:
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="Thumbnails/", mediatype=''))
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="Thumbnails/thumbnail.png", mediatype=''))
|
||||
zi = zipfile.ZipInfo("Thumbnails/thumbnail.png", self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, self.thumbnail)
|
||||
|
||||
# Write any extra files
|
||||
for op in self._extra:
|
||||
if op.filename == "META-INF/documentsignatures.xml": continue # Don't save signatures
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath=op.filename, mediatype=op.mediatype))
|
||||
zi = zipfile.ZipInfo(op.filename.encode('utf-8'), self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
if op.content is not None:
|
||||
self._z.writestr(zi, op.content)
|
||||
# Write manifest
|
||||
zi = zipfile.ZipInfo("META-INF/manifest.xml", self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, self.__manifestxml() )
|
||||
del self._z
|
||||
del self._now
|
||||
del self.manifest
|
||||
|
||||
|
||||
def _saveXmlObjects(self, object, folder):
|
||||
if self == object:
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="/", mediatype=object.mimetype))
|
||||
else:
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath=folder, mediatype=object.mimetype))
|
||||
# Write styles
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="%sstyles.xml" % folder, mediatype="text/xml"))
|
||||
zi = zipfile.ZipInfo("%sstyles.xml" % folder, self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, object.stylesxml() )
|
||||
|
||||
# Write content
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="%scontent.xml" % folder, mediatype="text/xml"))
|
||||
zi = zipfile.ZipInfo("%scontent.xml" % folder, self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, object.contentxml() )
|
||||
|
||||
# Write settings
|
||||
if object.settings.hasChildNodes():
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="%ssettings.xml" % folder, mediatype="text/xml"))
|
||||
zi = zipfile.ZipInfo("%ssettings.xml" % folder, self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, object.settingsxml() )
|
||||
|
||||
# Write meta
|
||||
if self == object:
|
||||
self.manifest.addElement(manifest.FileEntry(fullpath="meta.xml", mediatype="text/xml"))
|
||||
zi = zipfile.ZipInfo("meta.xml", self._now)
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = UNIXPERMS
|
||||
self._z.writestr(zi, object.metaxml() )
|
||||
|
||||
# Write subobjects
|
||||
subobjectnum = 1
|
||||
for subobject in object.childobjects:
|
||||
self._saveXmlObjects(subobject, '%sObject %d/' % (folder, subobjectnum))
|
||||
subobjectnum += 1
|
||||
|
||||
# Document's DOM methods
|
||||
def createElement(self, element):
|
||||
""" Inconvenient interface to create an element, but follows XML-DOM.
|
||||
Does not allow attributes as argument, therefore can't check grammar.
|
||||
"""
|
||||
return element(check_grammar=False)
|
||||
|
||||
def createTextNode(self, data):
|
||||
""" Method to create a text node """
|
||||
return element.Text(data)
|
||||
|
||||
def createCDATASection(self, data):
|
||||
""" Method to create a CDATA section """
|
||||
return element.CDATASection(cdata)
|
||||
|
||||
def getMediaType(self):
|
||||
""" Returns the media type """
|
||||
return self.mimetype
|
||||
|
||||
def getStyleByName(self, name):
|
||||
""" Finds a style object based on the name """
|
||||
ncname = make_NCName(name)
|
||||
if self._styles_dict == {}:
|
||||
self.rebuild_caches()
|
||||
return self._styles_dict.get(ncname, None)
|
||||
|
||||
def getElementsByType(self, element):
|
||||
""" Gets elements based on the type, which is function from text.py, draw.py etc. """
|
||||
obj = element(check_grammar=False)
|
||||
if self.element_dict == {}:
|
||||
self.rebuild_caches()
|
||||
return self.element_dict.get(obj.qname, [])
|
||||
|
||||
# Convenience functions
|
||||
def OpenDocumentChart():
|
||||
""" Creates a chart document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.chart')
|
||||
doc.chart = Chart()
|
||||
doc.body.addElement(doc.chart)
|
||||
return doc
|
||||
|
||||
def OpenDocumentDrawing():
|
||||
""" Creates a drawing document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.graphics')
|
||||
doc.drawing = Drawing()
|
||||
doc.body.addElement(doc.drawing)
|
||||
return doc
|
||||
|
||||
def OpenDocumentImage():
|
||||
""" Creates an image document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.image')
|
||||
doc.image = Image()
|
||||
doc.body.addElement(doc.image)
|
||||
return doc
|
||||
|
||||
def OpenDocumentPresentation():
|
||||
""" Creates a presentation document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.presentation')
|
||||
doc.presentation = Presentation()
|
||||
doc.body.addElement(doc.presentation)
|
||||
return doc
|
||||
|
||||
def OpenDocumentSpreadsheet():
|
||||
""" Creates a spreadsheet document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.spreadsheet')
|
||||
doc.spreadsheet = Spreadsheet()
|
||||
doc.body.addElement(doc.spreadsheet)
|
||||
return doc
|
||||
|
||||
def OpenDocumentText():
|
||||
""" Creates a text document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.text')
|
||||
doc.text = Text()
|
||||
doc.body.addElement(doc.text)
|
||||
return doc
|
||||
|
||||
def OpenDocumentTextMaster():
|
||||
""" Creates a text master document """
|
||||
doc = OpenDocument('application/vnd.oasis.opendocument.text-master')
|
||||
doc.text = Text()
|
||||
doc.body.addElement(doc.text)
|
||||
return doc
|
||||
|
||||
def __loadxmlparts(z, manifest, doc, objectpath):
|
||||
from .load import LoadParser
|
||||
from xml.sax import make_parser, handler
|
||||
|
||||
for xmlfile in (objectpath+'settings.xml', objectpath+'meta.xml', objectpath+'content.xml', objectpath+'styles.xml'):
|
||||
if xmlfile not in manifest:
|
||||
continue
|
||||
try:
|
||||
xmlpart = z.read(xmlfile)
|
||||
doc._parsing = xmlfile
|
||||
|
||||
parser = make_parser()
|
||||
parser.setFeature(handler.feature_namespaces, 1)
|
||||
parser.setContentHandler(LoadParser(doc))
|
||||
parser.setErrorHandler(handler.ErrorHandler())
|
||||
|
||||
inpsrc = InputSource()
|
||||
inpsrc.setByteStream(StringIO(xmlpart))
|
||||
parser.parse(inpsrc)
|
||||
del doc._parsing
|
||||
except KeyError as v: pass
|
||||
|
||||
def load(odffile):
|
||||
""" Load an ODF file into memory
|
||||
Returns a reference to the structure
|
||||
"""
|
||||
z = zipfile.ZipFile(odffile)
|
||||
mimetype = z.read('mimetype')
|
||||
doc = OpenDocument(mimetype, add_generator=False)
|
||||
|
||||
# Look in the manifest file to see if which of the four files there are
|
||||
manifestpart = z.read('META-INF/manifest.xml')
|
||||
manifest = manifestlist(manifestpart)
|
||||
__loadxmlparts(z, manifest, doc, '')
|
||||
for mentry,mvalue in list(manifest.items()):
|
||||
if mentry[:9] == "Pictures/" and len(mentry) > 9:
|
||||
doc.addPicture(mvalue['full-path'], mvalue['media-type'], z.read(mentry))
|
||||
elif mentry == "Thumbnails/thumbnail.png":
|
||||
doc.addThumbnail(z.read(mentry))
|
||||
elif mentry in ('settings.xml', 'meta.xml', 'content.xml', 'styles.xml'):
|
||||
pass
|
||||
# Load subobjects into structure
|
||||
elif mentry[:7] == "Object " and len(mentry) < 11 and mentry[-1] == "/":
|
||||
subdoc = OpenDocument(mvalue['media-type'], add_generator=False)
|
||||
doc.addObject(subdoc, "/" + mentry[:-1])
|
||||
__loadxmlparts(z, manifest, subdoc, mentry)
|
||||
elif mentry[:7] == "Object ":
|
||||
pass # Don't load subobjects as opaque objects
|
||||
else:
|
||||
if mvalue['full-path'][-1] == '/':
|
||||
doc._extra.append(OpaqueObject(mvalue['full-path'], mvalue['media-type'], None))
|
||||
else:
|
||||
doc._extra.append(OpaqueObject(mvalue['full-path'], mvalue['media-type'], z.read(mentry)))
|
||||
# Add the SUN junk here to the struct somewhere
|
||||
# It is cached data, so it can be out-of-date
|
||||
z.close()
|
||||
b = doc.getElementsByType(Body)
|
||||
if mimetype[:39] == 'application/vnd.oasis.opendocument.text':
|
||||
doc.text = b[0].firstChild
|
||||
elif mimetype[:43] == 'application/vnd.oasis.opendocument.graphics':
|
||||
doc.graphics = b[0].firstChild
|
||||
elif mimetype[:47] == 'application/vnd.oasis.opendocument.presentation':
|
||||
doc.presentation = b[0].firstChild
|
||||
elif mimetype[:46] == 'application/vnd.oasis.opendocument.spreadsheet':
|
||||
doc.spreadsheet = b[0].firstChild
|
||||
elif mimetype[:40] == 'application/vnd.oasis.opendocument.chart':
|
||||
doc.chart = b[0].firstChild
|
||||
elif mimetype[:40] == 'application/vnd.oasis.opendocument.image':
|
||||
doc.image = b[0].firstChild
|
||||
elif mimetype[:42] == 'application/vnd.oasis.opendocument.formula':
|
||||
doc.formula = b[0].firstChild
|
||||
return doc
|
||||
|
||||
# vim: set expandtab sw=4 :
|
||||
@@ -0,0 +1,85 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import PRESENTATIONNS
|
||||
from .element import Element
|
||||
|
||||
# ODF 1.0 section 9.6 and 9.7
|
||||
# Autogenerated
|
||||
def AnimationGroup(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'animation-group'), **args)
|
||||
|
||||
def Animations(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'animations'), **args)
|
||||
|
||||
def DateTime(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'date-time'), **args)
|
||||
|
||||
def DateTimeDecl(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'date-time-decl'), **args)
|
||||
|
||||
def Dim(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'dim'), **args)
|
||||
|
||||
def EventListener(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'event-listener'), **args)
|
||||
|
||||
def Footer(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'footer'), **args)
|
||||
|
||||
def FooterDecl(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'footer-decl'), **args)
|
||||
|
||||
def Header(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'header'), **args)
|
||||
|
||||
def HeaderDecl(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'header-decl'), **args)
|
||||
|
||||
def HideShape(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'hide-shape'), **args)
|
||||
|
||||
def HideText(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'hide-text'), **args)
|
||||
|
||||
def Notes(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'notes'), **args)
|
||||
|
||||
def Placeholder(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'placeholder'), **args)
|
||||
|
||||
def Play(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'play'), **args)
|
||||
|
||||
def Settings(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'settings'), **args)
|
||||
|
||||
def Show(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'show'), **args)
|
||||
|
||||
def ShowShape(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'show-shape'), **args)
|
||||
|
||||
def ShowText(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'show-text'), **args)
|
||||
|
||||
def Sound(**args):
|
||||
return Element(qname = (PRESENTATIONNS,'sound'), **args)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import SCRIPTNS
|
||||
from .element import Element
|
||||
|
||||
# ODF 1.0 section 12.4.1
|
||||
# The <script:event-listener> element binds an event to a macro.
|
||||
|
||||
# Autogenerated
|
||||
def EventListener(**args):
|
||||
return Element(qname = (SCRIPTNS,'event-listener'), **args)
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import STYLENS
|
||||
from .element import Element
|
||||
|
||||
def StyleElement(**args):
|
||||
e = Element(**args)
|
||||
if args.get('check_grammar', True) == True:
|
||||
if 'displayname' not in args:
|
||||
e.setAttrNS(STYLENS,'display-name', args.get('name'))
|
||||
return e
|
||||
|
||||
# Autogenerated
|
||||
def BackgroundImage(**args):
|
||||
return Element(qname = (STYLENS,'background-image'), **args)
|
||||
|
||||
def ChartProperties(**args):
|
||||
return Element(qname = (STYLENS,'chart-properties'), **args)
|
||||
|
||||
def Column(**args):
|
||||
return Element(qname = (STYLENS,'column'), **args)
|
||||
|
||||
def ColumnSep(**args):
|
||||
return Element(qname = (STYLENS,'column-sep'), **args)
|
||||
|
||||
def Columns(**args):
|
||||
return Element(qname = (STYLENS,'columns'), **args)
|
||||
|
||||
def DefaultStyle(**args):
|
||||
return Element(qname = (STYLENS,'default-style'), **args)
|
||||
|
||||
def DrawingPageProperties(**args):
|
||||
return Element(qname = (STYLENS,'drawing-page-properties'), **args)
|
||||
|
||||
def DropCap(**args):
|
||||
return Element(qname = (STYLENS,'drop-cap'), **args)
|
||||
|
||||
def FontFace(**args):
|
||||
return Element(qname = (STYLENS,'font-face'), **args)
|
||||
|
||||
def Footer(**args):
|
||||
return Element(qname = (STYLENS,'footer'), **args)
|
||||
|
||||
def FooterLeft(**args):
|
||||
return Element(qname = (STYLENS,'footer-left'), **args)
|
||||
|
||||
def FooterStyle(**args):
|
||||
return Element(qname = (STYLENS,'footer-style'), **args)
|
||||
|
||||
def FootnoteSep(**args):
|
||||
return Element(qname = (STYLENS,'footnote-sep'), **args)
|
||||
|
||||
def GraphicProperties(**args):
|
||||
return Element(qname = (STYLENS,'graphic-properties'), **args)
|
||||
|
||||
def HandoutMaster(**args):
|
||||
return Element(qname = (STYLENS,'handout-master'), **args)
|
||||
|
||||
def Header(**args):
|
||||
return Element(qname = (STYLENS,'header'), **args)
|
||||
|
||||
def HeaderFooterProperties(**args):
|
||||
return Element(qname = (STYLENS,'header-footer-properties'), **args)
|
||||
|
||||
def HeaderLeft(**args):
|
||||
return Element(qname = (STYLENS,'header-left'), **args)
|
||||
|
||||
def HeaderStyle(**args):
|
||||
return Element(qname = (STYLENS,'header-style'), **args)
|
||||
|
||||
def ListLevelProperties(**args):
|
||||
return Element(qname = (STYLENS,'list-level-properties'), **args)
|
||||
|
||||
def Map(**args):
|
||||
return Element(qname = (STYLENS,'map'), **args)
|
||||
|
||||
def MasterPage(**args):
|
||||
return StyleElement(qname = (STYLENS,'master-page'), **args)
|
||||
|
||||
def PageLayout(**args):
|
||||
return Element(qname = (STYLENS,'page-layout'), **args)
|
||||
|
||||
def PageLayoutProperties(**args):
|
||||
return Element(qname = (STYLENS,'page-layout-properties'), **args)
|
||||
|
||||
def ParagraphProperties(**args):
|
||||
return Element(qname = (STYLENS,'paragraph-properties'), **args)
|
||||
|
||||
def PresentationPageLayout(**args):
|
||||
return StyleElement(qname = (STYLENS,'presentation-page-layout'), **args)
|
||||
|
||||
def RegionCenter(**args):
|
||||
return Element(qname = (STYLENS,'region-center'), **args)
|
||||
|
||||
def RegionLeft(**args):
|
||||
return Element(qname = (STYLENS,'region-left'), **args)
|
||||
|
||||
def RegionRight(**args):
|
||||
return Element(qname = (STYLENS,'region-right'), **args)
|
||||
|
||||
def RubyProperties(**args):
|
||||
return Element(qname = (STYLENS,'ruby-properties'), **args)
|
||||
|
||||
def SectionProperties(**args):
|
||||
return Element(qname = (STYLENS,'section-properties'), **args)
|
||||
|
||||
def Style(**args):
|
||||
return StyleElement(qname = (STYLENS,'style'), **args)
|
||||
|
||||
def TabStop(**args):
|
||||
return Element(qname = (STYLENS,'tab-stop'), **args)
|
||||
|
||||
def TabStops(**args):
|
||||
return Element(qname = (STYLENS,'tab-stops'), **args)
|
||||
|
||||
def TableCellProperties(**args):
|
||||
return Element(qname = (STYLENS,'table-cell-properties'), **args)
|
||||
|
||||
def TableColumnProperties(**args):
|
||||
return Element(qname = (STYLENS,'table-column-properties'), **args)
|
||||
|
||||
def TableProperties(**args):
|
||||
return Element(qname = (STYLENS,'table-properties'), **args)
|
||||
|
||||
def TableRowProperties(**args):
|
||||
return Element(qname = (STYLENS,'table-row-properties'), **args)
|
||||
|
||||
def TextProperties(**args):
|
||||
return Element(qname = (STYLENS,'text-properties'), **args)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import SVGNS
|
||||
from .element import Element
|
||||
from .draw import DrawElement
|
||||
|
||||
# Autogenerated
|
||||
def DefinitionSrc(**args):
|
||||
return Element(qname = (SVGNS,'definition-src'), **args)
|
||||
|
||||
def Desc(**args):
|
||||
return Element(qname = (SVGNS,'desc'), **args)
|
||||
|
||||
def FontFaceFormat(**args):
|
||||
return Element(qname = (SVGNS,'font-face-format'), **args)
|
||||
|
||||
def FontFaceName(**args):
|
||||
return Element(qname = (SVGNS,'font-face-name'), **args)
|
||||
|
||||
def FontFaceSrc(**args):
|
||||
return Element(qname = (SVGNS,'font-face-src'), **args)
|
||||
|
||||
def FontFaceUri(**args):
|
||||
return Element(qname = (SVGNS,'font-face-uri'), **args)
|
||||
|
||||
def Lineargradient(**args):
|
||||
return DrawElement(qname = (SVGNS,'linearGradient'), **args)
|
||||
|
||||
def Radialgradient(**args):
|
||||
return DrawElement(qname = (SVGNS,'radialGradient'), **args)
|
||||
|
||||
def Stop(**args):
|
||||
return Element(qname = (SVGNS,'stop'), **args)
|
||||
|
||||
def Title(**args):
|
||||
return Element(qname = (SVGNS,'title'), **args)
|
||||
@@ -0,0 +1,307 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import TABLENS
|
||||
from .element import Element
|
||||
|
||||
|
||||
# Autogenerated
|
||||
def Body(**args):
|
||||
return Element(qname = (TABLENS,'body'), **args)
|
||||
|
||||
def CalculationSettings(**args):
|
||||
return Element(qname = (TABLENS,'calculation-settings'), **args)
|
||||
|
||||
def CellAddress(**args):
|
||||
return Element(qname = (TABLENS,'cell-address'), **args)
|
||||
|
||||
def CellContentChange(**args):
|
||||
return Element(qname = (TABLENS,'cell-content-change'), **args)
|
||||
|
||||
def CellContentDeletion(**args):
|
||||
return Element(qname = (TABLENS,'cell-content-deletion'), **args)
|
||||
|
||||
def CellRangeSource(**args):
|
||||
return Element(qname = (TABLENS,'cell-range-source'), **args)
|
||||
|
||||
def ChangeDeletion(**args):
|
||||
return Element(qname = (TABLENS,'change-deletion'), **args)
|
||||
|
||||
def ChangeTrackTableCell(**args):
|
||||
return Element(qname = (TABLENS,'change-track-table-cell'), **args)
|
||||
|
||||
def Consolidation(**args):
|
||||
return Element(qname = (TABLENS,'consolidation'), **args)
|
||||
|
||||
def ContentValidation(**args):
|
||||
return Element(qname = (TABLENS,'content-validation'), **args)
|
||||
|
||||
def ContentValidations(**args):
|
||||
return Element(qname = (TABLENS,'content-validations'), **args)
|
||||
|
||||
def CoveredTableCell(**args):
|
||||
return Element(qname = (TABLENS,'covered-table-cell'), **args)
|
||||
|
||||
def CutOffs(**args):
|
||||
return Element(qname = (TABLENS,'cut-offs'), **args)
|
||||
|
||||
def DataPilotDisplayInfo(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-display-info'), **args)
|
||||
|
||||
def DataPilotField(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-field'), **args)
|
||||
|
||||
def DataPilotFieldReference(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-field-reference'), **args)
|
||||
|
||||
def DataPilotGroup(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-group'), **args)
|
||||
|
||||
def DataPilotGroupMember(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-group-member'), **args)
|
||||
|
||||
def DataPilotGroups(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-groups'), **args)
|
||||
|
||||
def DataPilotLayoutInfo(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-layout-info'), **args)
|
||||
|
||||
def DataPilotLevel(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-level'), **args)
|
||||
|
||||
def DataPilotMember(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-member'), **args)
|
||||
|
||||
def DataPilotMembers(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-members'), **args)
|
||||
|
||||
def DataPilotSortInfo(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-sort-info'), **args)
|
||||
|
||||
def DataPilotSubtotal(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-subtotal'), **args)
|
||||
|
||||
def DataPilotSubtotals(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-subtotals'), **args)
|
||||
|
||||
def DataPilotTable(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-table'), **args)
|
||||
|
||||
def DataPilotTables(**args):
|
||||
return Element(qname = (TABLENS,'data-pilot-tables'), **args)
|
||||
|
||||
def DatabaseRange(**args):
|
||||
return Element(qname = (TABLENS,'database-range'), **args)
|
||||
|
||||
def DatabaseRanges(**args):
|
||||
return Element(qname = (TABLENS,'database-ranges'), **args)
|
||||
|
||||
def DatabaseSourceQuery(**args):
|
||||
return Element(qname = (TABLENS,'database-source-query'), **args)
|
||||
|
||||
def DatabaseSourceSql(**args):
|
||||
return Element(qname = (TABLENS,'database-source-sql'), **args)
|
||||
|
||||
def DatabaseSourceTable(**args):
|
||||
return Element(qname = (TABLENS,'database-source-table'), **args)
|
||||
|
||||
def DdeLink(**args):
|
||||
return Element(qname = (TABLENS,'dde-link'), **args)
|
||||
|
||||
def DdeLinks(**args):
|
||||
return Element(qname = (TABLENS,'dde-links'), **args)
|
||||
|
||||
def Deletion(**args):
|
||||
return Element(qname = (TABLENS,'deletion'), **args)
|
||||
|
||||
def Deletions(**args):
|
||||
return Element(qname = (TABLENS,'deletions'), **args)
|
||||
|
||||
def Dependencies(**args):
|
||||
return Element(qname = (TABLENS,'dependencies'), **args)
|
||||
|
||||
def Dependency(**args):
|
||||
return Element(qname = (TABLENS,'dependency'), **args)
|
||||
|
||||
def Detective(**args):
|
||||
return Element(qname = (TABLENS,'detective'), **args)
|
||||
|
||||
def ErrorMacro(**args):
|
||||
return Element(qname = (TABLENS,'error-macro'), **args)
|
||||
|
||||
def ErrorMessage(**args):
|
||||
return Element(qname = (TABLENS,'error-message'), **args)
|
||||
|
||||
def EvenColumns(**args):
|
||||
return Element(qname = (TABLENS,'even-columns'), **args)
|
||||
|
||||
def EvenRows(**args):
|
||||
return Element(qname = (TABLENS,'even-rows'), **args)
|
||||
|
||||
def Filter(**args):
|
||||
return Element(qname = (TABLENS,'filter'), **args)
|
||||
|
||||
def FilterAnd(**args):
|
||||
return Element(qname = (TABLENS,'filter-and'), **args)
|
||||
|
||||
def FilterCondition(**args):
|
||||
return Element(qname = (TABLENS,'filter-condition'), **args)
|
||||
|
||||
def FilterOr(**args):
|
||||
return Element(qname = (TABLENS,'filter-or'), **args)
|
||||
|
||||
def FirstColumn(**args):
|
||||
return Element(qname = (TABLENS,'first-column'), **args)
|
||||
|
||||
def FirstRow(**args):
|
||||
return Element(qname = (TABLENS,'first-row'), **args)
|
||||
|
||||
def HelpMessage(**args):
|
||||
return Element(qname = (TABLENS,'help-message'), **args)
|
||||
|
||||
def HighlightedRange(**args):
|
||||
return Element(qname = (TABLENS,'highlighted-range'), **args)
|
||||
|
||||
def Insertion(**args):
|
||||
return Element(qname = (TABLENS,'insertion'), **args)
|
||||
|
||||
def InsertionCutOff(**args):
|
||||
return Element(qname = (TABLENS,'insertion-cut-off'), **args)
|
||||
|
||||
def Iteration(**args):
|
||||
return Element(qname = (TABLENS,'iteration'), **args)
|
||||
|
||||
def LabelRange(**args):
|
||||
return Element(qname = (TABLENS,'label-range'), **args)
|
||||
|
||||
def LabelRanges(**args):
|
||||
return Element(qname = (TABLENS,'label-ranges'), **args)
|
||||
|
||||
def LastColumn(**args):
|
||||
return Element(qname = (TABLENS,'last-column'), **args)
|
||||
|
||||
def LastRow(**args):
|
||||
return Element(qname = (TABLENS,'last-row'), **args)
|
||||
|
||||
def Movement(**args):
|
||||
return Element(qname = (TABLENS,'movement'), **args)
|
||||
|
||||
def MovementCutOff(**args):
|
||||
return Element(qname = (TABLENS,'movement-cut-off'), **args)
|
||||
|
||||
def NamedExpression(**args):
|
||||
return Element(qname = (TABLENS,'named-expression'), **args)
|
||||
|
||||
def NamedExpressions(**args):
|
||||
return Element(qname = (TABLENS,'named-expressions'), **args)
|
||||
|
||||
def NamedRange(**args):
|
||||
return Element(qname = (TABLENS,'named-range'), **args)
|
||||
|
||||
def NullDate(**args):
|
||||
return Element(qname = (TABLENS,'null-date'), **args)
|
||||
|
||||
def OddColumns(**args):
|
||||
return Element(qname = (TABLENS,'odd-columns'), **args)
|
||||
|
||||
def OddRows(**args):
|
||||
return Element(qname = (TABLENS,'odd-rows'), **args)
|
||||
|
||||
def Operation(**args):
|
||||
return Element(qname = (TABLENS,'operation'), **args)
|
||||
|
||||
def Previous(**args):
|
||||
return Element(qname = (TABLENS,'previous'), **args)
|
||||
|
||||
def Scenario(**args):
|
||||
return Element(qname = (TABLENS,'scenario'), **args)
|
||||
|
||||
def Shapes(**args):
|
||||
return Element(qname = (TABLENS,'shapes'), **args)
|
||||
|
||||
def Sort(**args):
|
||||
return Element(qname = (TABLENS,'sort'), **args)
|
||||
|
||||
def SortBy(**args):
|
||||
return Element(qname = (TABLENS,'sort-by'), **args)
|
||||
|
||||
def SortGroups(**args):
|
||||
return Element(qname = (TABLENS,'sort-groups'), **args)
|
||||
|
||||
def SourceCellRange(**args):
|
||||
return Element(qname = (TABLENS,'source-cell-range'), **args)
|
||||
|
||||
def SourceRangeAddress(**args):
|
||||
return Element(qname = (TABLENS,'source-range-address'), **args)
|
||||
|
||||
def SourceService(**args):
|
||||
return Element(qname = (TABLENS,'source-service'), **args)
|
||||
|
||||
def SubtotalField(**args):
|
||||
return Element(qname = (TABLENS,'subtotal-field'), **args)
|
||||
|
||||
def SubtotalRule(**args):
|
||||
return Element(qname = (TABLENS,'subtotal-rule'), **args)
|
||||
|
||||
def SubtotalRules(**args):
|
||||
return Element(qname = (TABLENS,'subtotal-rules'), **args)
|
||||
|
||||
def Table(**args):
|
||||
return Element(qname = (TABLENS,'table'), **args)
|
||||
|
||||
def TableCell(**args):
|
||||
return Element(qname = (TABLENS,'table-cell'), **args)
|
||||
|
||||
def TableColumn(**args):
|
||||
return Element(qname = (TABLENS,'table-column'), **args)
|
||||
|
||||
def TableColumnGroup(**args):
|
||||
return Element(qname = (TABLENS,'table-column-group'), **args)
|
||||
|
||||
def TableColumns(**args):
|
||||
return Element(qname = (TABLENS,'table-columns'), **args)
|
||||
|
||||
def TableHeaderColumns(**args):
|
||||
return Element(qname = (TABLENS,'table-header-columns'), **args)
|
||||
|
||||
def TableHeaderRows(**args):
|
||||
return Element(qname = (TABLENS,'table-header-rows'), **args)
|
||||
|
||||
def TableRow(**args):
|
||||
return Element(qname = (TABLENS,'table-row'), **args)
|
||||
|
||||
def TableRowGroup(**args):
|
||||
return Element(qname = (TABLENS,'table-row-group'), **args)
|
||||
|
||||
def TableRows(**args):
|
||||
return Element(qname = (TABLENS,'table-rows'), **args)
|
||||
|
||||
def TableSource(**args):
|
||||
return Element(qname = (TABLENS,'table-source'), **args)
|
||||
|
||||
def TableTemplate(**args):
|
||||
return Element(qname = (TABLENS,'table-template'), **args)
|
||||
|
||||
def TargetRangeAddress(**args):
|
||||
return Element(qname = (TABLENS,'target-range-address'), **args)
|
||||
|
||||
def TrackedChanges(**args):
|
||||
return Element(qname = (TABLENS,'tracked-changes'), **args)
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Create and extract text from ODF, handling whitespace correctly.
|
||||
# Copyright (C) 2008 J. David Eisenberg
|
||||
#
|
||||
# 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 2 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, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
|
||||
"""
|
||||
Class for handling whitespace properly in OpenDocument.
|
||||
|
||||
While it is possible to use getTextContent() and setTextContent()
|
||||
to extract or create ODF content, these won't extract or create
|
||||
the appropriate <text:s>, <text:tab>, or <text:line-break>
|
||||
elements. This module takes care of that problem.
|
||||
"""
|
||||
|
||||
from odf.element import Node
|
||||
import odf.opendocument
|
||||
from odf.text import S,LineBreak,Tab
|
||||
|
||||
class WhitespaceText(object):
|
||||
|
||||
def __init__(self):
|
||||
self.textBuffer = []
|
||||
self.spaceCount = 0
|
||||
|
||||
def addTextToElement(self, odfElement, s):
|
||||
""" Process an input string, inserting
|
||||
<text:tab> elements for '\t',
|
||||
<text:line-break> elements for '\n', and
|
||||
<text:s> elements for runs of more than one blank.
|
||||
These will be added to the given element.
|
||||
"""
|
||||
i = 0
|
||||
ch = ' '
|
||||
|
||||
# When we encounter a tab or newline, we can immediately
|
||||
# dump any accumulated text and then emit the appropriate
|
||||
# ODF element.
|
||||
#
|
||||
# When we encounter a space, we add it to the text buffer,
|
||||
# and then collect more spaces. If there are more spaces
|
||||
# after the first one, we dump the text buffer and then
|
||||
# then emit the appropriate <text:s> element.
|
||||
|
||||
while i < len(s):
|
||||
ch = s[i]
|
||||
if ch == '\t':
|
||||
self._emitTextBuffer(odfElement)
|
||||
odfElement.addElement(Tab())
|
||||
i += 1
|
||||
elif ch == '\n':
|
||||
self._emitTextBuffer(odfElement);
|
||||
odfElement.addElement(LineBreak())
|
||||
i += 1
|
||||
elif ch == ' ':
|
||||
self.textBuffer.append(' ')
|
||||
i += 1
|
||||
self.spaceCount = 0
|
||||
while i < len(s) and (s[i] == ' '):
|
||||
self.spaceCount += 1
|
||||
i += 1
|
||||
if self.spaceCount > 0:
|
||||
self._emitTextBuffer(odfElement)
|
||||
self._emitSpaces(odfElement)
|
||||
else:
|
||||
self.textBuffer.append(ch)
|
||||
i += 1
|
||||
|
||||
self._emitTextBuffer(odfElement)
|
||||
|
||||
def _emitTextBuffer(self, odfElement):
|
||||
""" Creates a Text Node whose contents are the current textBuffer.
|
||||
Side effect: clears the text buffer.
|
||||
"""
|
||||
if len(self.textBuffer) > 0:
|
||||
odfElement.addText(''.join(self.textBuffer))
|
||||
self.textBuffer = []
|
||||
|
||||
|
||||
def _emitSpaces(self, odfElement):
|
||||
""" Creates a <text:s> element for the current spaceCount.
|
||||
Side effect: sets spaceCount back to zero
|
||||
"""
|
||||
if self.spaceCount > 0:
|
||||
spaceElement = S(c=self.spaceCount)
|
||||
odfElement.addElement(spaceElement)
|
||||
self.spaceCount = 0
|
||||
|
||||
def addTextToElement(odfElement, s):
|
||||
wst = WhitespaceText()
|
||||
wst.addTextToElement(odfElement, s)
|
||||
|
||||
def extractText(odfElement):
|
||||
""" Extract text content from an Element, with whitespace represented
|
||||
properly. Returns the text, with tabs, spaces, and newlines
|
||||
correctly evaluated. This method recursively descends through the
|
||||
children of the given element, accumulating text and "unwrapping"
|
||||
<text:s>, <text:tab>, and <text:line-break> elements along the way.
|
||||
"""
|
||||
result = [];
|
||||
|
||||
if len(odfElement.childNodes) != 0:
|
||||
for child in odfElement.childNodes:
|
||||
if child.nodeType == Node.TEXT_NODE:
|
||||
result.append(child.data)
|
||||
elif child.nodeType == Node.ELEMENT_NODE:
|
||||
subElement = child
|
||||
tagName = subElement.qname;
|
||||
if tagName == ("urn:oasis:names:tc:opendocument:xmlns:text:1.0", "line-break"):
|
||||
result.append("\n")
|
||||
elif tagName == ("urn:oasis:names:tc:opendocument:xmlns:text:1.0", "tab"):
|
||||
result.append("\t")
|
||||
elif tagName == ("urn:oasis:names:tc:opendocument:xmlns:text:1.0", "s"):
|
||||
c = subElement.getAttribute('c')
|
||||
if c:
|
||||
spaceCount = int(c)
|
||||
else:
|
||||
spaceCount = 1
|
||||
|
||||
result.append(" " * spaceCount)
|
||||
else:
|
||||
result.append(extractText(subElement))
|
||||
return ''.join(result)
|
||||
@@ -0,0 +1,562 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import TEXTNS
|
||||
from .element import Element
|
||||
from .style import StyleElement
|
||||
|
||||
# Autogenerated
|
||||
def A(**args):
|
||||
return Element(qname = (TEXTNS,'a'), **args)
|
||||
|
||||
def AlphabeticalIndex(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index'), **args)
|
||||
|
||||
def AlphabeticalIndexAutoMarkFile(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index-auto-mark-file'), **args)
|
||||
|
||||
def AlphabeticalIndexEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index-entry-template'), **args)
|
||||
|
||||
def AlphabeticalIndexMark(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index-mark'), **args)
|
||||
|
||||
def AlphabeticalIndexMarkEnd(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index-mark-end'), **args)
|
||||
|
||||
def AlphabeticalIndexMarkStart(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index-mark-start'), **args)
|
||||
|
||||
def AlphabeticalIndexSource(**args):
|
||||
return Element(qname = (TEXTNS,'alphabetical-index-source'), **args)
|
||||
|
||||
def AuthorInitials(**args):
|
||||
return Element(qname = (TEXTNS,'author-initials'), **args)
|
||||
|
||||
def AuthorName(**args):
|
||||
return Element(qname = (TEXTNS,'author-name'), **args)
|
||||
|
||||
def Bibliography(**args):
|
||||
return Element(qname = (TEXTNS,'bibliography'), **args)
|
||||
|
||||
def BibliographyConfiguration(**args):
|
||||
return Element(qname = (TEXTNS,'bibliography-configuration'), **args)
|
||||
|
||||
def BibliographyEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'bibliography-entry-template'), **args)
|
||||
|
||||
def BibliographyMark(**args):
|
||||
return Element(qname = (TEXTNS,'bibliography-mark'), **args)
|
||||
|
||||
def BibliographySource(**args):
|
||||
return Element(qname = (TEXTNS,'bibliography-source'), **args)
|
||||
|
||||
def Bookmark(**args):
|
||||
return Element(qname = (TEXTNS,'bookmark'), **args)
|
||||
|
||||
def BookmarkEnd(**args):
|
||||
return Element(qname = (TEXTNS,'bookmark-end'), **args)
|
||||
|
||||
def BookmarkRef(**args):
|
||||
return Element(qname = (TEXTNS,'bookmark-ref'), **args)
|
||||
|
||||
def BookmarkStart(**args):
|
||||
return Element(qname = (TEXTNS,'bookmark-start'), **args)
|
||||
|
||||
def Change(**args):
|
||||
return Element(qname = (TEXTNS,'change'), **args)
|
||||
|
||||
def ChangeEnd(**args):
|
||||
return Element(qname = (TEXTNS,'change-end'), **args)
|
||||
|
||||
def ChangeStart(**args):
|
||||
return Element(qname = (TEXTNS,'change-start'), **args)
|
||||
|
||||
def ChangedRegion(**args):
|
||||
return Element(qname = (TEXTNS,'changed-region'), **args)
|
||||
|
||||
def Chapter(**args):
|
||||
return Element(qname = (TEXTNS,'chapter'), **args)
|
||||
|
||||
def CharacterCount(**args):
|
||||
return Element(qname = (TEXTNS,'character-count'), **args)
|
||||
|
||||
def ConditionalText(**args):
|
||||
return Element(qname = (TEXTNS,'conditional-text'), **args)
|
||||
|
||||
def CreationDate(**args):
|
||||
return Element(qname = (TEXTNS,'creation-date'), **args)
|
||||
|
||||
def CreationTime(**args):
|
||||
return Element(qname = (TEXTNS,'creation-time'), **args)
|
||||
|
||||
def Creator(**args):
|
||||
return Element(qname = (TEXTNS,'creator'), **args)
|
||||
|
||||
def DatabaseDisplay(**args):
|
||||
return Element(qname = (TEXTNS,'database-display'), **args)
|
||||
|
||||
def DatabaseName(**args):
|
||||
return Element(qname = (TEXTNS,'database-name'), **args)
|
||||
|
||||
def DatabaseNext(**args):
|
||||
return Element(qname = (TEXTNS,'database-next'), **args)
|
||||
|
||||
def DatabaseRowNumber(**args):
|
||||
return Element(qname = (TEXTNS,'database-row-number'), **args)
|
||||
|
||||
def DatabaseRowSelect(**args):
|
||||
return Element(qname = (TEXTNS,'database-row-select'), **args)
|
||||
|
||||
def Date(**args):
|
||||
return Element(qname = (TEXTNS,'date'), **args)
|
||||
|
||||
def DdeConnection(**args):
|
||||
return Element(qname = (TEXTNS,'dde-connection'), **args)
|
||||
|
||||
def DdeConnectionDecl(**args):
|
||||
return Element(qname = (TEXTNS,'dde-connection-decl'), **args)
|
||||
|
||||
def DdeConnectionDecls(**args):
|
||||
return Element(qname = (TEXTNS,'dde-connection-decls'), **args)
|
||||
|
||||
def Deletion(**args):
|
||||
return Element(qname = (TEXTNS,'deletion'), **args)
|
||||
|
||||
def Description(**args):
|
||||
return Element(qname = (TEXTNS,'description'), **args)
|
||||
|
||||
def EditingCycles(**args):
|
||||
return Element(qname = (TEXTNS,'editing-cycles'), **args)
|
||||
|
||||
def EditingDuration(**args):
|
||||
return Element(qname = (TEXTNS,'editing-duration'), **args)
|
||||
|
||||
def ExecuteMacro(**args):
|
||||
return Element(qname = (TEXTNS,'execute-macro'), **args)
|
||||
|
||||
def Expression(**args):
|
||||
return Element(qname = (TEXTNS,'expression'), **args)
|
||||
|
||||
def FileName(**args):
|
||||
return Element(qname = (TEXTNS,'file-name'), **args)
|
||||
|
||||
def FormatChange(**args):
|
||||
return Element(qname = (TEXTNS,'format-change'), **args)
|
||||
|
||||
def H(**args):
|
||||
return Element(qname = (TEXTNS, 'h'), **args)
|
||||
|
||||
def HiddenParagraph(**args):
|
||||
return Element(qname = (TEXTNS,'hidden-paragraph'), **args)
|
||||
|
||||
def HiddenText(**args):
|
||||
return Element(qname = (TEXTNS,'hidden-text'), **args)
|
||||
|
||||
def IllustrationIndex(**args):
|
||||
return Element(qname = (TEXTNS,'illustration-index'), **args)
|
||||
|
||||
def IllustrationIndexEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'illustration-index-entry-template'), **args)
|
||||
|
||||
def IllustrationIndexSource(**args):
|
||||
return Element(qname = (TEXTNS,'illustration-index-source'), **args)
|
||||
|
||||
def ImageCount(**args):
|
||||
return Element(qname = (TEXTNS,'image-count'), **args)
|
||||
|
||||
def IndexBody(**args):
|
||||
return Element(qname = (TEXTNS,'index-body'), **args)
|
||||
|
||||
def IndexEntryBibliography(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-bibliography'), **args)
|
||||
|
||||
def IndexEntryChapter(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-chapter'), **args)
|
||||
|
||||
def IndexEntryLinkEnd(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-link-end'), **args)
|
||||
|
||||
def IndexEntryLinkStart(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-link-start'), **args)
|
||||
|
||||
def IndexEntryPageNumber(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-page-number'), **args)
|
||||
|
||||
def IndexEntrySpan(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-span'), **args)
|
||||
|
||||
def IndexEntryTabStop(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-tab-stop'), **args)
|
||||
|
||||
def IndexEntryText(**args):
|
||||
return Element(qname = (TEXTNS,'index-entry-text'), **args)
|
||||
|
||||
def IndexSourceStyle(**args):
|
||||
return Element(qname = (TEXTNS,'index-source-style'), **args)
|
||||
|
||||
def IndexSourceStyles(**args):
|
||||
return Element(qname = (TEXTNS,'index-source-styles'), **args)
|
||||
|
||||
def IndexTitle(**args):
|
||||
return Element(qname = (TEXTNS,'index-title'), **args)
|
||||
|
||||
def IndexTitleTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'index-title-template'), **args)
|
||||
|
||||
def InitialCreator(**args):
|
||||
return Element(qname = (TEXTNS,'initial-creator'), **args)
|
||||
|
||||
def Insertion(**args):
|
||||
return Element(qname = (TEXTNS,'insertion'), **args)
|
||||
|
||||
def Keywords(**args):
|
||||
return Element(qname = (TEXTNS,'keywords'), **args)
|
||||
|
||||
def LineBreak(**args):
|
||||
return Element(qname = (TEXTNS,'line-break'), **args)
|
||||
|
||||
def LinenumberingConfiguration(**args):
|
||||
return Element(qname = (TEXTNS,'linenumbering-configuration'), **args)
|
||||
|
||||
def LinenumberingSeparator(**args):
|
||||
return Element(qname = (TEXTNS,'linenumbering-separator'), **args)
|
||||
|
||||
def List(**args):
|
||||
return Element(qname = (TEXTNS,'list'), **args)
|
||||
|
||||
def ListHeader(**args):
|
||||
return Element(qname = (TEXTNS,'list-header'), **args)
|
||||
|
||||
def ListItem(**args):
|
||||
return Element(qname = (TEXTNS,'list-item'), **args)
|
||||
|
||||
def ListLevelStyleBullet(**args):
|
||||
return Element(qname = (TEXTNS,'list-level-style-bullet'), **args)
|
||||
|
||||
def ListLevelStyleImage(**args):
|
||||
return Element(qname = (TEXTNS,'list-level-style-image'), **args)
|
||||
|
||||
def ListLevelStyleNumber(**args):
|
||||
return Element(qname = (TEXTNS,'list-level-style-number'), **args)
|
||||
|
||||
def ListStyle(**args):
|
||||
return StyleElement(qname = (TEXTNS,'list-style'), **args)
|
||||
|
||||
def Measure(**args):
|
||||
return Element(qname = (TEXTNS,'measure'), **args)
|
||||
|
||||
def ModificationDate(**args):
|
||||
return Element(qname = (TEXTNS,'modification-date'), **args)
|
||||
|
||||
def ModificationTime(**args):
|
||||
return Element(qname = (TEXTNS,'modification-time'), **args)
|
||||
|
||||
def Note(**args):
|
||||
return Element(qname = (TEXTNS,'note'), **args)
|
||||
|
||||
def NoteBody(**args):
|
||||
return Element(qname = (TEXTNS,'note-body'), **args)
|
||||
|
||||
def NoteCitation(**args):
|
||||
return Element(qname = (TEXTNS,'note-citation'), **args)
|
||||
|
||||
def NoteContinuationNoticeBackward(**args):
|
||||
return Element(qname = (TEXTNS,'note-continuation-notice-backward'), **args)
|
||||
|
||||
def NoteContinuationNoticeForward(**args):
|
||||
return Element(qname = (TEXTNS,'note-continuation-notice-forward'), **args)
|
||||
|
||||
def NoteRef(**args):
|
||||
return Element(qname = (TEXTNS,'note-ref'), **args)
|
||||
|
||||
def NotesConfiguration(**args):
|
||||
return Element(qname = (TEXTNS,'notes-configuration'), **args)
|
||||
|
||||
def Number(**args):
|
||||
return Element(qname = (TEXTNS,'number'), **args)
|
||||
|
||||
def NumberedParagraph(**args):
|
||||
return Element(qname = (TEXTNS,'numbered-paragraph'), **args)
|
||||
|
||||
def ObjectCount(**args):
|
||||
return Element(qname = (TEXTNS,'object-count'), **args)
|
||||
|
||||
def ObjectIndex(**args):
|
||||
return Element(qname = (TEXTNS,'object-index'), **args)
|
||||
|
||||
def ObjectIndexEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'object-index-entry-template'), **args)
|
||||
|
||||
def ObjectIndexSource(**args):
|
||||
return Element(qname = (TEXTNS,'object-index-source'), **args)
|
||||
|
||||
def OutlineLevelStyle(**args):
|
||||
return Element(qname = (TEXTNS,'outline-level-style'), **args)
|
||||
|
||||
def OutlineStyle(**args):
|
||||
return Element(qname = (TEXTNS,'outline-style'), **args)
|
||||
|
||||
def P(**args):
|
||||
return Element(qname = (TEXTNS, 'p'), **args)
|
||||
|
||||
def Page(**args):
|
||||
return Element(qname = (TEXTNS,'page'), **args)
|
||||
|
||||
def PageContinuation(**args):
|
||||
return Element(qname = (TEXTNS,'page-continuation'), **args)
|
||||
|
||||
def PageCount(**args):
|
||||
return Element(qname = (TEXTNS,'page-count'), **args)
|
||||
|
||||
def PageNumber(**args):
|
||||
return Element(qname = (TEXTNS,'page-number'), **args)
|
||||
|
||||
def PageSequence(**args):
|
||||
return Element(qname = (TEXTNS,'page-sequence'), **args)
|
||||
|
||||
def PageVariableGet(**args):
|
||||
return Element(qname = (TEXTNS,'page-variable-get'), **args)
|
||||
|
||||
def PageVariableSet(**args):
|
||||
return Element(qname = (TEXTNS,'page-variable-set'), **args)
|
||||
|
||||
def ParagraphCount(**args):
|
||||
return Element(qname = (TEXTNS,'paragraph-count'), **args)
|
||||
|
||||
def Placeholder(**args):
|
||||
return Element(qname = (TEXTNS,'placeholder'), **args)
|
||||
|
||||
def PrintDate(**args):
|
||||
return Element(qname = (TEXTNS,'print-date'), **args)
|
||||
|
||||
def PrintTime(**args):
|
||||
return Element(qname = (TEXTNS,'print-time'), **args)
|
||||
|
||||
def PrintedBy(**args):
|
||||
return Element(qname = (TEXTNS,'printed-by'), **args)
|
||||
|
||||
def ReferenceMark(**args):
|
||||
return Element(qname = (TEXTNS,'reference-mark'), **args)
|
||||
|
||||
def ReferenceMarkEnd(**args):
|
||||
return Element(qname = (TEXTNS,'reference-mark-end'), **args)
|
||||
|
||||
def ReferenceMarkStart(**args):
|
||||
return Element(qname = (TEXTNS,'reference-mark-start'), **args)
|
||||
|
||||
def ReferenceRef(**args):
|
||||
return Element(qname = (TEXTNS,'reference-ref'), **args)
|
||||
|
||||
def Ruby(**args):
|
||||
return Element(qname = (TEXTNS,'ruby'), **args)
|
||||
|
||||
def RubyBase(**args):
|
||||
return Element(qname = (TEXTNS,'ruby-base'), **args)
|
||||
|
||||
def RubyText(**args):
|
||||
return Element(qname = (TEXTNS,'ruby-text'), **args)
|
||||
|
||||
def S(**args):
|
||||
return Element(qname = (TEXTNS,'s'), **args)
|
||||
|
||||
def Script(**args):
|
||||
return Element(qname = (TEXTNS,'script'), **args)
|
||||
|
||||
def Section(**args):
|
||||
return Element(qname = (TEXTNS,'section'), **args)
|
||||
|
||||
def SectionSource(**args):
|
||||
return Element(qname = (TEXTNS,'section-source'), **args)
|
||||
|
||||
def SenderCity(**args):
|
||||
return Element(qname = (TEXTNS,'sender-city'), **args)
|
||||
|
||||
def SenderCompany(**args):
|
||||
return Element(qname = (TEXTNS,'sender-company'), **args)
|
||||
|
||||
def SenderCountry(**args):
|
||||
return Element(qname = (TEXTNS,'sender-country'), **args)
|
||||
|
||||
def SenderEmail(**args):
|
||||
return Element(qname = (TEXTNS,'sender-email'), **args)
|
||||
|
||||
def SenderFax(**args):
|
||||
return Element(qname = (TEXTNS,'sender-fax'), **args)
|
||||
|
||||
def SenderFirstname(**args):
|
||||
return Element(qname = (TEXTNS,'sender-firstname'), **args)
|
||||
|
||||
def SenderInitials(**args):
|
||||
return Element(qname = (TEXTNS,'sender-initials'), **args)
|
||||
|
||||
def SenderLastname(**args):
|
||||
return Element(qname = (TEXTNS,'sender-lastname'), **args)
|
||||
|
||||
def SenderPhonePrivate(**args):
|
||||
return Element(qname = (TEXTNS,'sender-phone-private'), **args)
|
||||
|
||||
def SenderPhoneWork(**args):
|
||||
return Element(qname = (TEXTNS,'sender-phone-work'), **args)
|
||||
|
||||
def SenderPosition(**args):
|
||||
return Element(qname = (TEXTNS,'sender-position'), **args)
|
||||
|
||||
def SenderPostalCode(**args):
|
||||
return Element(qname = (TEXTNS,'sender-postal-code'), **args)
|
||||
|
||||
def SenderStateOrProvince(**args):
|
||||
return Element(qname = (TEXTNS,'sender-state-or-province'), **args)
|
||||
|
||||
def SenderStreet(**args):
|
||||
return Element(qname = (TEXTNS,'sender-street'), **args)
|
||||
|
||||
def SenderTitle(**args):
|
||||
return Element(qname = (TEXTNS,'sender-title'), **args)
|
||||
|
||||
def Sequence(**args):
|
||||
return Element(qname = (TEXTNS,'sequence'), **args)
|
||||
|
||||
def SequenceDecl(**args):
|
||||
return Element(qname = (TEXTNS,'sequence-decl'), **args)
|
||||
|
||||
def SequenceDecls(**args):
|
||||
return Element(qname = (TEXTNS,'sequence-decls'), **args)
|
||||
|
||||
def SequenceRef(**args):
|
||||
return Element(qname = (TEXTNS,'sequence-ref'), **args)
|
||||
|
||||
def SheetName(**args):
|
||||
return Element(qname = (TEXTNS,'sheet-name'), **args)
|
||||
|
||||
def SoftPageBreak(**args):
|
||||
return Element(qname = (TEXTNS,'soft-page-break'), **args)
|
||||
|
||||
def SortKey(**args):
|
||||
return Element(qname = (TEXTNS,'sort-key'), **args)
|
||||
|
||||
def Span(**args):
|
||||
return Element(qname = (TEXTNS,'span'), **args)
|
||||
|
||||
def Subject(**args):
|
||||
return Element(qname = (TEXTNS,'subject'), **args)
|
||||
|
||||
def Tab(**args):
|
||||
return Element(qname = (TEXTNS,'tab'), **args)
|
||||
|
||||
def TableCount(**args):
|
||||
return Element(qname = (TEXTNS,'table-count'), **args)
|
||||
|
||||
def TableFormula(**args):
|
||||
return Element(qname = (TEXTNS,'table-formula'), **args)
|
||||
|
||||
def TableIndex(**args):
|
||||
return Element(qname = (TEXTNS,'table-index'), **args)
|
||||
|
||||
def TableIndexEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'table-index-entry-template'), **args)
|
||||
|
||||
def TableIndexSource(**args):
|
||||
return Element(qname = (TEXTNS,'table-index-source'), **args)
|
||||
|
||||
def TableOfContent(**args):
|
||||
return Element(qname = (TEXTNS,'table-of-content'), **args)
|
||||
|
||||
def TableOfContentEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'table-of-content-entry-template'), **args)
|
||||
|
||||
def TableOfContentSource(**args):
|
||||
return Element(qname = (TEXTNS,'table-of-content-source'), **args)
|
||||
|
||||
def TemplateName(**args):
|
||||
return Element(qname = (TEXTNS,'template-name'), **args)
|
||||
|
||||
def TextInput(**args):
|
||||
return Element(qname = (TEXTNS,'text-input'), **args)
|
||||
|
||||
def Time(**args):
|
||||
return Element(qname = (TEXTNS,'time'), **args)
|
||||
|
||||
def Title(**args):
|
||||
return Element(qname = (TEXTNS,'title'), **args)
|
||||
|
||||
def TocMark(**args):
|
||||
return Element(qname = (TEXTNS,'toc-mark'), **args)
|
||||
|
||||
def TocMarkEnd(**args):
|
||||
return Element(qname = (TEXTNS,'toc-mark-end'), **args)
|
||||
|
||||
def TocMarkStart(**args):
|
||||
return Element(qname = (TEXTNS,'toc-mark-start'), **args)
|
||||
|
||||
def TrackedChanges(**args):
|
||||
return Element(qname = (TEXTNS,'tracked-changes'), **args)
|
||||
|
||||
def UserDefined(**args):
|
||||
return Element(qname = (TEXTNS,'user-defined'), **args)
|
||||
|
||||
def UserFieldDecl(**args):
|
||||
return Element(qname = (TEXTNS,'user-field-decl'), **args)
|
||||
|
||||
def UserFieldDecls(**args):
|
||||
return Element(qname = (TEXTNS,'user-field-decls'), **args)
|
||||
|
||||
def UserFieldGet(**args):
|
||||
return Element(qname = (TEXTNS,'user-field-get'), **args)
|
||||
|
||||
def UserFieldInput(**args):
|
||||
return Element(qname = (TEXTNS,'user-field-input'), **args)
|
||||
|
||||
def UserIndex(**args):
|
||||
return Element(qname = (TEXTNS,'user-index'), **args)
|
||||
|
||||
def UserIndexEntryTemplate(**args):
|
||||
return Element(qname = (TEXTNS,'user-index-entry-template'), **args)
|
||||
|
||||
def UserIndexMark(**args):
|
||||
return Element(qname = (TEXTNS,'user-index-mark'), **args)
|
||||
|
||||
def UserIndexMarkEnd(**args):
|
||||
return Element(qname = (TEXTNS,'user-index-mark-end'), **args)
|
||||
|
||||
def UserIndexMarkStart(**args):
|
||||
return Element(qname = (TEXTNS,'user-index-mark-start'), **args)
|
||||
|
||||
def UserIndexSource(**args):
|
||||
return Element(qname = (TEXTNS,'user-index-source'), **args)
|
||||
|
||||
def VariableDecl(**args):
|
||||
return Element(qname = (TEXTNS,'variable-decl'), **args)
|
||||
|
||||
def VariableDecls(**args):
|
||||
return Element(qname = (TEXTNS,'variable-decls'), **args)
|
||||
|
||||
def VariableGet(**args):
|
||||
return Element(qname = (TEXTNS,'variable-get'), **args)
|
||||
|
||||
def VariableInput(**args):
|
||||
return Element(qname = (TEXTNS,'variable-input'), **args)
|
||||
|
||||
def VariableSet(**args):
|
||||
return Element(qname = (TEXTNS,'variable-set'), **args)
|
||||
|
||||
def WordCount(**args):
|
||||
return Element(qname = (TEXTNS,'word-count'), **args)
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# This contains a 128x128 px thumbnail in PNG format
|
||||
# Taken from http://www.zwahlendesign.ch/en/node/20
|
||||
# openoffice_icons/openoffice_icons_linux/openoffice11.png
|
||||
# License: Freeware
|
||||
import base64
|
||||
|
||||
iconstr = """\
|
||||
iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAAG0OVFdAAAABGdBTUEAANbY1E9YMgAAABl0RVh0
|
||||
U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAFoHSURBVHjaYvz//z8DJQAggFhu3LiBU1JI
|
||||
SOiPmJgYM7IYUD0jMh8ggFhAhKamJuOHDx/+8fPz4zQsMTGRYf78+RjiAAHEBCJOnTr1HZvmN2/e
|
||||
MDAyQiycOXMmw5MnTxhmzZoViqwGIIAYrl+/DqKM/6OBNWvWgOmvX7/+37Rp0/8jR478//fv3/+f
|
||||
P3/+h+phPHHixH+AAIK75D8WMGnSpP8vXrz4//v37/9///6Fi4MMALruf3Bw8H+AAAJp5rQrOoeh
|
||||
edmyZWAbgd77f/bsWTAbBoB6JOpbmkF0OkAAgcLgO8gUYCCCnSIlJQWmw8LCGA4cOAAOAyMjI3hY
|
||||
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+/QFG/hxgwrwJa/BCzYSVHt8YEDd/DtqpDYAAYqRTIgOd
|
||||
PK4FxAbQhiEb2iAGbCADdo4NrBsECnhRINYMzp3Y85LRnA09crFaCGyti39aCLq1eCG0aH8IzZmw
|
||||
7dKkXMkKPqBJSkoqRFhYuB/Y0BN8+vTpdGBVcBOYGH5CzXsNjfg3aIkKI+IH2y1tAAFEr7VY7NCZ
|
||||
QtAqYg5o4MPOyP8JzfF/YH1dpICDHWEDOrBfPyavevojlmCsx32DLif/d6Pr4vYtB5dDc/ljIot2
|
||||
fIAJ6nbQhcZmQJwKxCsZIMviGdByPnJdjzNxDbYEABBAQ+Hwf0ZoogHvSIpMiut+KlCgDCnaTwCL
|
||||
9jpyi3ZiSy/QbijQETrC0ATMA3XTD6SBnY9ILXy8JctgSwAAATSULgIC5UTQZhR5aJXCBA3852QW
|
||||
7cSEDTM0AYBKIW4oZmVAHJ4Ji/gfxJYwgy0BAATQULo69ic0sl9DI+Y/NND/0qiR9R+amGAN0p/Q
|
||||
CGeAjdwhVVv/GQb3GhacACCAWIbY1bGwCKEL0NTU/A+1jxGaABiRIvs/NEcP6du0AAIMANtMxR3x
|
||||
N38FAAAAAElFTkSuQmCC\
|
||||
"""
|
||||
|
||||
def thumbnail():
|
||||
icon = base64.decodestring(iconstr)
|
||||
return icon
|
||||
|
||||
if __name__ == "__main__":
|
||||
icon = thumbnail()
|
||||
f = file("thumbnail.png","wb")
|
||||
f.write(icon)
|
||||
f.close()
|
||||
@@ -0,0 +1,169 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2009 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This is free software. You may redistribute it under the terms
|
||||
# of the Apache license and the GNU General Public License Version
|
||||
# 2 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, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s): Michael Howitz, gocept gmbh & co. kg
|
||||
#
|
||||
# $Id: userfield.py 447 2008-07-10 20:01:30Z roug $
|
||||
|
||||
"""Class to show and manipulate user fields in odf documents."""
|
||||
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
from odf.text import UserFieldDecl
|
||||
from odf.namespaces import OFFICENS
|
||||
from odf.opendocument import load
|
||||
|
||||
OUTENCODING = "utf-8"
|
||||
|
||||
|
||||
# OpenDocument v.1.0 section 6.7.1
|
||||
VALUE_TYPES = {
|
||||
'float': (OFFICENS, 'value'),
|
||||
'percentage': (OFFICENS, 'value'),
|
||||
'currency': (OFFICENS, 'value'),
|
||||
'date': (OFFICENS, 'date-value'),
|
||||
'time': (OFFICENS, 'time-value'),
|
||||
'boolean': (OFFICENS, 'boolean-value'),
|
||||
'string': (OFFICENS, 'string-value'),
|
||||
}
|
||||
|
||||
|
||||
class UserFields(object):
|
||||
"""List, view and manipulate user fields."""
|
||||
|
||||
# these attributes can be a filename or a file like object
|
||||
src_file = None
|
||||
dest_file = None
|
||||
|
||||
def __init__(self, src=None, dest=None):
|
||||
"""Constructor
|
||||
|
||||
src ... source document name, file like object or None for stdin
|
||||
dest ... destination document name, file like object or None for stdout
|
||||
|
||||
"""
|
||||
self.src_file = src
|
||||
self.dest_file = dest
|
||||
self.document = None
|
||||
|
||||
def loaddoc(self):
|
||||
if isinstance(self.src_file, str):
|
||||
# src_file is a filename, check if it is a zip-file
|
||||
if not zipfile.is_zipfile(self.src_file):
|
||||
raise TypeError("%s is no odt file." % self.src_file)
|
||||
elif self.src_file is None:
|
||||
# use stdin if no file given
|
||||
self.src_file = sys.stdin
|
||||
|
||||
self.document = load(self.src_file)
|
||||
|
||||
def savedoc(self):
|
||||
# write output
|
||||
if self.dest_file is None:
|
||||
# use stdout if no filename given
|
||||
self.document.save('-')
|
||||
else:
|
||||
self.document.save(self.dest_file)
|
||||
|
||||
def list_fields(self):
|
||||
"""List (extract) all known user-fields.
|
||||
|
||||
Returns list of user-field names.
|
||||
|
||||
"""
|
||||
return [x[0] for x in self.list_fields_and_values()]
|
||||
|
||||
def list_fields_and_values(self, field_names=None):
|
||||
"""List (extract) user-fields with type and value.
|
||||
|
||||
field_names ... list of field names to show or None for all.
|
||||
|
||||
Returns list of tuples (<field name>, <field type>, <value>).
|
||||
|
||||
"""
|
||||
self.loaddoc()
|
||||
found_fields = []
|
||||
all_fields = self.document.getElementsByType(UserFieldDecl)
|
||||
for f in all_fields:
|
||||
value_type = f.getAttribute('valuetype')
|
||||
if value_type == 'string':
|
||||
value = f.getAttribute('stringvalue')
|
||||
else:
|
||||
value = f.getAttribute('value')
|
||||
field_name = f.getAttribute('name')
|
||||
|
||||
if field_names is None or field_name in field_names:
|
||||
found_fields.append((field_name.encode(OUTENCODING),
|
||||
value_type.encode(OUTENCODING),
|
||||
value.encode(OUTENCODING)))
|
||||
return found_fields
|
||||
|
||||
def list_values(self, field_names):
|
||||
"""Extract the contents of given field names from the file.
|
||||
|
||||
field_names ... list of field names
|
||||
|
||||
Returns list of field values.
|
||||
|
||||
"""
|
||||
return [x[2] for x in self.list_fields_and_values(field_names)]
|
||||
|
||||
def get(self, field_name):
|
||||
"""Extract the contents of this field from the file.
|
||||
|
||||
Returns field value or None if field does not exist.
|
||||
|
||||
"""
|
||||
values = self.list_values([field_name])
|
||||
if not values:
|
||||
return None
|
||||
return values[0]
|
||||
|
||||
def get_type_and_value(self, field_name):
|
||||
"""Extract the type and contents of this field from the file.
|
||||
|
||||
Returns tuple (<type>, <field-value>) or None if field does not exist.
|
||||
|
||||
"""
|
||||
fields = self.list_fields_and_values([field_name])
|
||||
if not fields:
|
||||
return None
|
||||
field_name, value_type, value = fields[0]
|
||||
return value_type, value
|
||||
|
||||
def update(self, data):
|
||||
"""Set the value of user fields. The field types will be the same.
|
||||
|
||||
data ... dict, with field name as key, field value as value
|
||||
|
||||
Returns None
|
||||
|
||||
"""
|
||||
self.loaddoc()
|
||||
all_fields = self.document.getElementsByType(UserFieldDecl)
|
||||
for f in all_fields:
|
||||
field_name = f.getAttribute('name')
|
||||
if field_name in data:
|
||||
value_type = f.getAttribute('valuetype')
|
||||
value = data.get(field_name)
|
||||
if value_type == 'string':
|
||||
f.setAttribute('stringvalue', value)
|
||||
else:
|
||||
f.setAttribute('value', value)
|
||||
self.savedoc()
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
from .namespaces import XFORMSNS
|
||||
from .element import Element
|
||||
|
||||
# ODF 1.0 section 11.2
|
||||
# XForms is designed to be embedded in another XML format.
|
||||
# Autogenerated
|
||||
def Model(**args):
|
||||
return Element(qname = (XFORMSNS,'model'), **args)
|
||||
|
||||
def Instance(**args):
|
||||
return Element(qname = (XFORMSNS,'instance'), **args)
|
||||
|
||||
def Bind(**args):
|
||||
return Element(qname = (XFORMSNS,'bind'), **args)
|
||||
@@ -0,0 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from .core import loads, dumps, JSONError
|
||||
|
||||
|
||||
__all__ = ('loads', 'dumps', 'JSONError')
|
||||
|
||||
|
||||
__version__ = '0.1.2'
|
||||
__author__ = 'Kenneth Reitz'
|
||||
__license__ = 'MIT'
|
||||
@@ -0,0 +1,93 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
omijson.core
|
||||
~~~~~~~~~~~~
|
||||
|
||||
This module provides the core omnijson functionality.
|
||||
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
engine = None
|
||||
_engine = None
|
||||
|
||||
|
||||
options = [
|
||||
['ujson', 'loads', 'dumps', (ValueError,)],
|
||||
['yajl', 'loads', 'dumps', (TypeError, ValueError)],
|
||||
['jsonlib2', 'read', 'write', (ValueError,)],
|
||||
['jsonlib', 'read', 'write', (ValueError,)],
|
||||
['simplejson', 'loads', 'dumps', (TypeError, ValueError)],
|
||||
['json', 'loads', 'dumps', (TypeError, ValueError)],
|
||||
['simplejson_from_packages', 'loads', 'dumps', (ValueError,)],
|
||||
]
|
||||
|
||||
|
||||
def _import(engine):
|
||||
try:
|
||||
if '_from_' in engine:
|
||||
engine, package = engine.split('_from_')
|
||||
m = __import__(package, globals(), locals(), [engine], -1)
|
||||
return getattr(m, engine)
|
||||
|
||||
return __import__(engine)
|
||||
|
||||
except ImportError:
|
||||
return False
|
||||
|
||||
|
||||
def loads(s, **kwargs):
|
||||
"""Loads JSON object."""
|
||||
|
||||
try:
|
||||
return _engine[0](s)
|
||||
|
||||
except:
|
||||
# crazy 2/3 exception hack
|
||||
# http://www.voidspace.org.uk/python/weblog/arch_d7_2010_03_20.shtml
|
||||
|
||||
ExceptionClass, why = sys.exc_info()[:2]
|
||||
|
||||
if any([(issubclass(ExceptionClass, e)) for e in _engine[2]]):
|
||||
raise JSONError(why)
|
||||
else:
|
||||
raise why
|
||||
|
||||
|
||||
def dumps(o, **kwargs):
|
||||
"""Dumps JSON object."""
|
||||
|
||||
try:
|
||||
return _engine[1](o)
|
||||
|
||||
except:
|
||||
ExceptionClass, why = sys.exc_info()[:2]
|
||||
|
||||
if any([(issubclass(ExceptionClass, e)) for e in _engine[2]]):
|
||||
raise JSONError(why)
|
||||
else:
|
||||
raise why
|
||||
|
||||
|
||||
class JSONError(ValueError):
|
||||
"""JSON Failed."""
|
||||
|
||||
|
||||
# ------
|
||||
# Magic!
|
||||
# ------
|
||||
|
||||
|
||||
for e in options:
|
||||
|
||||
__engine = _import(e[0])
|
||||
|
||||
if __engine:
|
||||
engine, _engine = e[0], e[1:4]
|
||||
|
||||
for i in (0, 1):
|
||||
_engine[i] = getattr(__engine, _engine[i])
|
||||
|
||||
break
|
||||
@@ -0,0 +1,438 @@
|
||||
r"""JSON (JavaScript Object Notation) <http://json.org> is a subset of
|
||||
JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data
|
||||
interchange format.
|
||||
|
||||
:mod:`simplejson` exposes an API familiar to users of the standard library
|
||||
:mod:`marshal` and :mod:`pickle` modules. It is the externally maintained
|
||||
version of the :mod:`json` library contained in Python 2.6, but maintains
|
||||
compatibility with Python 2.4 and Python 2.5 and (currently) has
|
||||
significant performance advantages, even without using the optional C
|
||||
extension for speedups.
|
||||
|
||||
Encoding basic Python object hierarchies::
|
||||
|
||||
>>> import simplejson as json
|
||||
>>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
|
||||
'["foo", {"bar": ["baz", null, 1.0, 2]}]'
|
||||
>>> print json.dumps("\"foo\bar")
|
||||
"\"foo\bar"
|
||||
>>> print json.dumps(u'\u1234')
|
||||
"\u1234"
|
||||
>>> print json.dumps('\\')
|
||||
"\\"
|
||||
>>> print json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True)
|
||||
{"a": 0, "b": 0, "c": 0}
|
||||
>>> from StringIO import StringIO
|
||||
>>> io = StringIO()
|
||||
>>> json.dump(['streaming API'], io)
|
||||
>>> io.getvalue()
|
||||
'["streaming API"]'
|
||||
|
||||
Compact encoding::
|
||||
|
||||
>>> import simplejson as json
|
||||
>>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',',':'))
|
||||
'[1,2,3,{"4":5,"6":7}]'
|
||||
|
||||
Pretty printing::
|
||||
|
||||
>>> import simplejson as json
|
||||
>>> s = json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=' ')
|
||||
>>> print '\n'.join([l.rstrip() for l in s.splitlines()])
|
||||
{
|
||||
"4": 5,
|
||||
"6": 7
|
||||
}
|
||||
|
||||
Decoding JSON::
|
||||
|
||||
>>> import simplejson as json
|
||||
>>> obj = [u'foo', {u'bar': [u'baz', None, 1.0, 2]}]
|
||||
>>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]') == obj
|
||||
True
|
||||
>>> json.loads('"\\"foo\\bar"') == u'"foo\x08ar'
|
||||
True
|
||||
>>> from StringIO import StringIO
|
||||
>>> io = StringIO('["streaming API"]')
|
||||
>>> json.load(io)[0] == 'streaming API'
|
||||
True
|
||||
|
||||
Specializing JSON object decoding::
|
||||
|
||||
>>> import simplejson as json
|
||||
>>> def as_complex(dct):
|
||||
... if '__complex__' in dct:
|
||||
... return complex(dct['real'], dct['imag'])
|
||||
... return dct
|
||||
...
|
||||
>>> json.loads('{"__complex__": true, "real": 1, "imag": 2}',
|
||||
... object_hook=as_complex)
|
||||
(1+2j)
|
||||
>>> from decimal import Decimal
|
||||
>>> json.loads('1.1', parse_float=Decimal) == Decimal('1.1')
|
||||
True
|
||||
|
||||
Specializing JSON object encoding::
|
||||
|
||||
>>> import simplejson as json
|
||||
>>> def encode_complex(obj):
|
||||
... if isinstance(obj, complex):
|
||||
... return [obj.real, obj.imag]
|
||||
... raise TypeError(repr(o) + " is not JSON serializable")
|
||||
...
|
||||
>>> json.dumps(2 + 1j, default=encode_complex)
|
||||
'[2.0, 1.0]'
|
||||
>>> json.JSONEncoder(default=encode_complex).encode(2 + 1j)
|
||||
'[2.0, 1.0]'
|
||||
>>> ''.join(json.JSONEncoder(default=encode_complex).iterencode(2 + 1j))
|
||||
'[2.0, 1.0]'
|
||||
|
||||
|
||||
Using simplejson.tool from the shell to validate and pretty-print::
|
||||
|
||||
$ echo '{"json":"obj"}' | python -m simplejson.tool
|
||||
{
|
||||
"json": "obj"
|
||||
}
|
||||
$ echo '{ 1.2:3.4}' | python -m simplejson.tool
|
||||
Expecting property name: line 1 column 2 (char 2)
|
||||
"""
|
||||
__version__ = '2.1.6'
|
||||
__all__ = [
|
||||
'dump', 'dumps', 'load', 'loads',
|
||||
'JSONDecoder', 'JSONDecodeError', 'JSONEncoder',
|
||||
'OrderedDict',
|
||||
]
|
||||
|
||||
__author__ = 'Bob Ippolito <bob@redivi.com>'
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
from decoder import JSONDecoder, JSONDecodeError
|
||||
from encoder import JSONEncoder
|
||||
def _import_OrderedDict():
|
||||
import collections
|
||||
try:
|
||||
return collections.OrderedDict
|
||||
except AttributeError:
|
||||
import ordered_dict
|
||||
return ordered_dict.OrderedDict
|
||||
OrderedDict = _import_OrderedDict()
|
||||
|
||||
def _import_c_make_encoder():
|
||||
try:
|
||||
from simplejson._speedups import make_encoder
|
||||
return make_encoder
|
||||
except ImportError:
|
||||
return None
|
||||
|
||||
_default_encoder = JSONEncoder(
|
||||
skipkeys=False,
|
||||
ensure_ascii=True,
|
||||
check_circular=True,
|
||||
allow_nan=True,
|
||||
indent=None,
|
||||
separators=None,
|
||||
encoding='utf-8',
|
||||
default=None,
|
||||
use_decimal=False,
|
||||
)
|
||||
|
||||
def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
|
||||
allow_nan=True, cls=None, indent=None, separators=None,
|
||||
encoding='utf-8', default=None, use_decimal=False, **kw):
|
||||
"""Serialize ``obj`` as a JSON formatted stream to ``fp`` (a
|
||||
``.write()``-supporting file-like object).
|
||||
|
||||
If ``skipkeys`` is true then ``dict`` keys that are not basic types
|
||||
(``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``)
|
||||
will be skipped instead of raising a ``TypeError``.
|
||||
|
||||
If ``ensure_ascii`` is false, then the some chunks written to ``fp``
|
||||
may be ``unicode`` instances, subject to normal Python ``str`` to
|
||||
``unicode`` coercion rules. Unless ``fp.write()`` explicitly
|
||||
understands ``unicode`` (as in ``codecs.getwriter()``) this is likely
|
||||
to cause an error.
|
||||
|
||||
If ``check_circular`` is false, then the circular reference check
|
||||
for container types will be skipped and a circular reference will
|
||||
result in an ``OverflowError`` (or worse).
|
||||
|
||||
If ``allow_nan`` is false, then it will be a ``ValueError`` to
|
||||
serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``)
|
||||
in strict compliance of the JSON specification, instead of using the
|
||||
JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).
|
||||
|
||||
If *indent* is a string, then JSON array elements and object members
|
||||
will be pretty-printed with a newline followed by that string repeated
|
||||
for each level of nesting. ``None`` (the default) selects the most compact
|
||||
representation without any newlines. For backwards compatibility with
|
||||
versions of simplejson earlier than 2.1.0, an integer is also accepted
|
||||
and is converted to a string with that many spaces.
|
||||
|
||||
If ``separators`` is an ``(item_separator, dict_separator)`` tuple
|
||||
then it will be used instead of the default ``(', ', ': ')`` separators.
|
||||
``(',', ':')`` is the most compact JSON representation.
|
||||
|
||||
``encoding`` is the character encoding for str instances, default is UTF-8.
|
||||
|
||||
``default(obj)`` is a function that should return a serializable version
|
||||
of obj or raise TypeError. The default simply raises TypeError.
|
||||
|
||||
If *use_decimal* is true (default: ``False``) then decimal.Decimal
|
||||
will be natively serialized to JSON with full precision.
|
||||
|
||||
To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
|
||||
``.default()`` method to serialize additional types), specify it with
|
||||
the ``cls`` kwarg.
|
||||
|
||||
"""
|
||||
# cached encoder
|
||||
if (not skipkeys and ensure_ascii and
|
||||
check_circular and allow_nan and
|
||||
cls is None and indent is None and separators is None and
|
||||
encoding == 'utf-8' and default is None and not use_decimal
|
||||
and not kw):
|
||||
iterable = _default_encoder.iterencode(obj)
|
||||
else:
|
||||
if cls is None:
|
||||
cls = JSONEncoder
|
||||
iterable = cls(skipkeys=skipkeys, ensure_ascii=ensure_ascii,
|
||||
check_circular=check_circular, allow_nan=allow_nan, indent=indent,
|
||||
separators=separators, encoding=encoding,
|
||||
default=default, use_decimal=use_decimal, **kw).iterencode(obj)
|
||||
# could accelerate with writelines in some versions of Python, at
|
||||
# a debuggability cost
|
||||
for chunk in iterable:
|
||||
fp.write(chunk)
|
||||
|
||||
|
||||
def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True,
|
||||
allow_nan=True, cls=None, indent=None, separators=None,
|
||||
encoding='utf-8', default=None, use_decimal=False, **kw):
|
||||
"""Serialize ``obj`` to a JSON formatted ``str``.
|
||||
|
||||
If ``skipkeys`` is false then ``dict`` keys that are not basic types
|
||||
(``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``)
|
||||
will be skipped instead of raising a ``TypeError``.
|
||||
|
||||
If ``ensure_ascii`` is false, then the return value will be a
|
||||
``unicode`` instance subject to normal Python ``str`` to ``unicode``
|
||||
coercion rules instead of being escaped to an ASCII ``str``.
|
||||
|
||||
If ``check_circular`` is false, then the circular reference check
|
||||
for container types will be skipped and a circular reference will
|
||||
result in an ``OverflowError`` (or worse).
|
||||
|
||||
If ``allow_nan`` is false, then it will be a ``ValueError`` to
|
||||
serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in
|
||||
strict compliance of the JSON specification, instead of using the
|
||||
JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).
|
||||
|
||||
If ``indent`` is a string, then JSON array elements and object members
|
||||
will be pretty-printed with a newline followed by that string repeated
|
||||
for each level of nesting. ``None`` (the default) selects the most compact
|
||||
representation without any newlines. For backwards compatibility with
|
||||
versions of simplejson earlier than 2.1.0, an integer is also accepted
|
||||
and is converted to a string with that many spaces.
|
||||
|
||||
If ``separators`` is an ``(item_separator, dict_separator)`` tuple
|
||||
then it will be used instead of the default ``(', ', ': ')`` separators.
|
||||
``(',', ':')`` is the most compact JSON representation.
|
||||
|
||||
``encoding`` is the character encoding for str instances, default is UTF-8.
|
||||
|
||||
``default(obj)`` is a function that should return a serializable version
|
||||
of obj or raise TypeError. The default simply raises TypeError.
|
||||
|
||||
If *use_decimal* is true (default: ``False``) then decimal.Decimal
|
||||
will be natively serialized to JSON with full precision.
|
||||
|
||||
To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
|
||||
``.default()`` method to serialize additional types), specify it with
|
||||
the ``cls`` kwarg.
|
||||
|
||||
"""
|
||||
# cached encoder
|
||||
if (not skipkeys and ensure_ascii and
|
||||
check_circular and allow_nan and
|
||||
cls is None and indent is None and separators is None and
|
||||
encoding == 'utf-8' and default is None and not use_decimal
|
||||
and not kw):
|
||||
return _default_encoder.encode(obj)
|
||||
if cls is None:
|
||||
cls = JSONEncoder
|
||||
return cls(
|
||||
skipkeys=skipkeys, ensure_ascii=ensure_ascii,
|
||||
check_circular=check_circular, allow_nan=allow_nan, indent=indent,
|
||||
separators=separators, encoding=encoding, default=default,
|
||||
use_decimal=use_decimal, **kw).encode(obj)
|
||||
|
||||
|
||||
_default_decoder = JSONDecoder(encoding=None, object_hook=None,
|
||||
object_pairs_hook=None)
|
||||
|
||||
|
||||
def load(fp, encoding=None, cls=None, object_hook=None, parse_float=None,
|
||||
parse_int=None, parse_constant=None, object_pairs_hook=None,
|
||||
use_decimal=False, **kw):
|
||||
"""Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
|
||||
a JSON document) to a Python object.
|
||||
|
||||
*encoding* determines the encoding used to interpret any
|
||||
:class:`str` objects decoded by this instance (``'utf-8'`` by
|
||||
default). It has no effect when decoding :class:`unicode` objects.
|
||||
|
||||
Note that currently only encodings that are a superset of ASCII work,
|
||||
strings of other encodings should be passed in as :class:`unicode`.
|
||||
|
||||
*object_hook*, if specified, will be called with the result of every
|
||||
JSON object decoded and its return value will be used in place of the
|
||||
given :class:`dict`. This can be used to provide custom
|
||||
deserializations (e.g. to support JSON-RPC class hinting).
|
||||
|
||||
*object_pairs_hook* is an optional function that will be called with
|
||||
the result of any object literal decode with an ordered list of pairs.
|
||||
The return value of *object_pairs_hook* will be used instead of the
|
||||
:class:`dict`. This feature can be used to implement custom decoders
|
||||
that rely on the order that the key and value pairs are decoded (for
|
||||
example, :func:`collections.OrderedDict` will remember the order of
|
||||
insertion). If *object_hook* is also defined, the *object_pairs_hook*
|
||||
takes priority.
|
||||
|
||||
*parse_float*, if specified, will be called with the string of every
|
||||
JSON float to be decoded. By default, this is equivalent to
|
||||
``float(num_str)``. This can be used to use another datatype or parser
|
||||
for JSON floats (e.g. :class:`decimal.Decimal`).
|
||||
|
||||
*parse_int*, if specified, will be called with the string of every
|
||||
JSON int to be decoded. By default, this is equivalent to
|
||||
``int(num_str)``. This can be used to use another datatype or parser
|
||||
for JSON integers (e.g. :class:`float`).
|
||||
|
||||
*parse_constant*, if specified, will be called with one of the
|
||||
following strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This
|
||||
can be used to raise an exception if invalid JSON numbers are
|
||||
encountered.
|
||||
|
||||
If *use_decimal* is true (default: ``False``) then it implies
|
||||
parse_float=decimal.Decimal for parity with ``dump``.
|
||||
|
||||
To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
|
||||
kwarg.
|
||||
|
||||
"""
|
||||
return loads(fp.read(),
|
||||
encoding=encoding, cls=cls, object_hook=object_hook,
|
||||
parse_float=parse_float, parse_int=parse_int,
|
||||
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook,
|
||||
use_decimal=use_decimal, **kw)
|
||||
|
||||
|
||||
def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None,
|
||||
parse_int=None, parse_constant=None, object_pairs_hook=None,
|
||||
use_decimal=False, **kw):
|
||||
"""Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON
|
||||
document) to a Python object.
|
||||
|
||||
*encoding* determines the encoding used to interpret any
|
||||
:class:`str` objects decoded by this instance (``'utf-8'`` by
|
||||
default). It has no effect when decoding :class:`unicode` objects.
|
||||
|
||||
Note that currently only encodings that are a superset of ASCII work,
|
||||
strings of other encodings should be passed in as :class:`unicode`.
|
||||
|
||||
*object_hook*, if specified, will be called with the result of every
|
||||
JSON object decoded and its return value will be used in place of the
|
||||
given :class:`dict`. This can be used to provide custom
|
||||
deserializations (e.g. to support JSON-RPC class hinting).
|
||||
|
||||
*object_pairs_hook* is an optional function that will be called with
|
||||
the result of any object literal decode with an ordered list of pairs.
|
||||
The return value of *object_pairs_hook* will be used instead of the
|
||||
:class:`dict`. This feature can be used to implement custom decoders
|
||||
that rely on the order that the key and value pairs are decoded (for
|
||||
example, :func:`collections.OrderedDict` will remember the order of
|
||||
insertion). If *object_hook* is also defined, the *object_pairs_hook*
|
||||
takes priority.
|
||||
|
||||
*parse_float*, if specified, will be called with the string of every
|
||||
JSON float to be decoded. By default, this is equivalent to
|
||||
``float(num_str)``. This can be used to use another datatype or parser
|
||||
for JSON floats (e.g. :class:`decimal.Decimal`).
|
||||
|
||||
*parse_int*, if specified, will be called with the string of every
|
||||
JSON int to be decoded. By default, this is equivalent to
|
||||
``int(num_str)``. This can be used to use another datatype or parser
|
||||
for JSON integers (e.g. :class:`float`).
|
||||
|
||||
*parse_constant*, if specified, will be called with one of the
|
||||
following strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This
|
||||
can be used to raise an exception if invalid JSON numbers are
|
||||
encountered.
|
||||
|
||||
If *use_decimal* is true (default: ``False``) then it implies
|
||||
parse_float=decimal.Decimal for parity with ``dump``.
|
||||
|
||||
To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
|
||||
kwarg.
|
||||
|
||||
"""
|
||||
if (cls is None and encoding is None and object_hook is None and
|
||||
parse_int is None and parse_float is None and
|
||||
parse_constant is None and object_pairs_hook is None
|
||||
and not use_decimal and not kw):
|
||||
return _default_decoder.decode(s)
|
||||
if cls is None:
|
||||
cls = JSONDecoder
|
||||
if object_hook is not None:
|
||||
kw['object_hook'] = object_hook
|
||||
if object_pairs_hook is not None:
|
||||
kw['object_pairs_hook'] = object_pairs_hook
|
||||
if parse_float is not None:
|
||||
kw['parse_float'] = parse_float
|
||||
if parse_int is not None:
|
||||
kw['parse_int'] = parse_int
|
||||
if parse_constant is not None:
|
||||
kw['parse_constant'] = parse_constant
|
||||
if use_decimal:
|
||||
if parse_float is not None:
|
||||
raise TypeError("use_decimal=True implies parse_float=Decimal")
|
||||
kw['parse_float'] = Decimal
|
||||
return cls(encoding=encoding, **kw).decode(s)
|
||||
|
||||
|
||||
def _toggle_speedups(enabled):
|
||||
import simplejson.decoder as dec
|
||||
import simplejson.encoder as enc
|
||||
import simplejson.scanner as scan
|
||||
c_make_encoder = _import_c_make_encoder()
|
||||
if enabled:
|
||||
dec.scanstring = dec.c_scanstring or dec.py_scanstring
|
||||
enc.c_make_encoder = c_make_encoder
|
||||
enc.encode_basestring_ascii = (enc.c_encode_basestring_ascii or
|
||||
enc.py_encode_basestring_ascii)
|
||||
scan.make_scanner = scan.c_make_scanner or scan.py_make_scanner
|
||||
else:
|
||||
dec.scanstring = dec.py_scanstring
|
||||
enc.c_make_encoder = None
|
||||
enc.encode_basestring_ascii = enc.py_encode_basestring_ascii
|
||||
scan.make_scanner = scan.py_make_scanner
|
||||
dec.make_scanner = scan.make_scanner
|
||||
global _default_decoder
|
||||
_default_decoder = JSONDecoder(
|
||||
encoding=None,
|
||||
object_hook=None,
|
||||
object_pairs_hook=None,
|
||||
)
|
||||
global _default_encoder
|
||||
_default_encoder = JSONEncoder(
|
||||
skipkeys=False,
|
||||
ensure_ascii=True,
|
||||
check_circular=True,
|
||||
allow_nan=True,
|
||||
indent=None,
|
||||
separators=None,
|
||||
encoding='utf-8',
|
||||
default=None,
|
||||
)
|
||||
@@ -0,0 +1,421 @@
|
||||
"""Implementation of JSONDecoder
|
||||
"""
|
||||
import re
|
||||
import sys
|
||||
import struct
|
||||
|
||||
from .scanner import make_scanner
|
||||
def _import_c_scanstring():
|
||||
try:
|
||||
from simplejson._speedups import scanstring
|
||||
return scanstring
|
||||
except ImportError:
|
||||
return None
|
||||
c_scanstring = _import_c_scanstring()
|
||||
|
||||
__all__ = ['JSONDecoder']
|
||||
|
||||
FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
|
||||
|
||||
def _floatconstants():
|
||||
_BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
|
||||
# The struct module in Python 2.4 would get frexp() out of range here
|
||||
# when an endian is specified in the format string. Fixed in Python 2.5+
|
||||
if sys.byteorder != 'big':
|
||||
_BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1]
|
||||
nan, inf = struct.unpack('dd', _BYTES)
|
||||
return nan, inf, -inf
|
||||
|
||||
NaN, PosInf, NegInf = _floatconstants()
|
||||
|
||||
|
||||
class JSONDecodeError(ValueError):
|
||||
"""Subclass of ValueError with the following additional properties:
|
||||
|
||||
msg: The unformatted error message
|
||||
doc: The JSON document being parsed
|
||||
pos: The start index of doc where parsing failed
|
||||
end: The end index of doc where parsing failed (may be None)
|
||||
lineno: The line corresponding to pos
|
||||
colno: The column corresponding to pos
|
||||
endlineno: The line corresponding to end (may be None)
|
||||
endcolno: The column corresponding to end (may be None)
|
||||
|
||||
"""
|
||||
def __init__(self, msg, doc, pos, end=None):
|
||||
ValueError.__init__(self, errmsg(msg, doc, pos, end=end))
|
||||
self.msg = msg
|
||||
self.doc = doc
|
||||
self.pos = pos
|
||||
self.end = end
|
||||
self.lineno, self.colno = linecol(doc, pos)
|
||||
if end is not None:
|
||||
self.endlineno, self.endcolno = linecol(doc, end)
|
||||
else:
|
||||
self.endlineno, self.endcolno = None, None
|
||||
|
||||
|
||||
def linecol(doc, pos):
|
||||
lineno = doc.count('\n', 0, pos) + 1
|
||||
if lineno == 1:
|
||||
colno = pos
|
||||
else:
|
||||
colno = pos - doc.rindex('\n', 0, pos)
|
||||
return lineno, colno
|
||||
|
||||
|
||||
def errmsg(msg, doc, pos, end=None):
|
||||
# Note that this function is called from _speedups
|
||||
lineno, colno = linecol(doc, pos)
|
||||
if end is None:
|
||||
#fmt = '{0}: line {1} column {2} (char {3})'
|
||||
#return fmt.format(msg, lineno, colno, pos)
|
||||
fmt = '%s: line %d column %d (char %d)'
|
||||
return fmt % (msg, lineno, colno, pos)
|
||||
endlineno, endcolno = linecol(doc, end)
|
||||
#fmt = '{0}: line {1} column {2} - line {3} column {4} (char {5} - {6})'
|
||||
#return fmt.format(msg, lineno, colno, endlineno, endcolno, pos, end)
|
||||
fmt = '%s: line %d column %d - line %d column %d (char %d - %d)'
|
||||
return fmt % (msg, lineno, colno, endlineno, endcolno, pos, end)
|
||||
|
||||
|
||||
_CONSTANTS = {
|
||||
'-Infinity': NegInf,
|
||||
'Infinity': PosInf,
|
||||
'NaN': NaN,
|
||||
}
|
||||
|
||||
STRINGCHUNK = re.compile(r'(.*?)(["\\\x00-\x1f])', FLAGS)
|
||||
BACKSLASH = {
|
||||
'"': u'"', '\\': u'\\', '/': u'/',
|
||||
'b': u'\b', 'f': u'\f', 'n': u'\n', 'r': u'\r', 't': u'\t',
|
||||
}
|
||||
|
||||
DEFAULT_ENCODING = "utf-8"
|
||||
|
||||
def py_scanstring(s, end, encoding=None, strict=True,
|
||||
_b=BACKSLASH, _m=STRINGCHUNK.match):
|
||||
"""Scan the string s for a JSON string. End is the index of the
|
||||
character in s after the quote that started the JSON string.
|
||||
Unescapes all valid JSON string escape sequences and raises ValueError
|
||||
on attempt to decode an invalid string. If strict is False then literal
|
||||
control characters are allowed in the string.
|
||||
|
||||
Returns a tuple of the decoded string and the index of the character in s
|
||||
after the end quote."""
|
||||
if encoding is None:
|
||||
encoding = DEFAULT_ENCODING
|
||||
chunks = []
|
||||
_append = chunks.append
|
||||
begin = end - 1
|
||||
while 1:
|
||||
chunk = _m(s, end)
|
||||
if chunk is None:
|
||||
raise JSONDecodeError(
|
||||
"Unterminated string starting at", s, begin)
|
||||
end = chunk.end()
|
||||
content, terminator = chunk.groups()
|
||||
# Content is contains zero or more unescaped string characters
|
||||
if content:
|
||||
if not isinstance(content, unicode):
|
||||
content = unicode(content, encoding)
|
||||
_append(content)
|
||||
# Terminator is the end of string, a literal control character,
|
||||
# or a backslash denoting that an escape sequence follows
|
||||
if terminator == '"':
|
||||
break
|
||||
elif terminator != '\\':
|
||||
if strict:
|
||||
msg = "Invalid control character %r at" % (terminator,)
|
||||
#msg = "Invalid control character {0!r} at".format(terminator)
|
||||
raise JSONDecodeError(msg, s, end)
|
||||
else:
|
||||
_append(terminator)
|
||||
continue
|
||||
try:
|
||||
esc = s[end]
|
||||
except IndexError:
|
||||
raise JSONDecodeError(
|
||||
"Unterminated string starting at", s, begin)
|
||||
# If not a unicode escape sequence, must be in the lookup table
|
||||
if esc != 'u':
|
||||
try:
|
||||
char = _b[esc]
|
||||
except KeyError:
|
||||
msg = "Invalid \\escape: " + repr(esc)
|
||||
raise JSONDecodeError(msg, s, end)
|
||||
end += 1
|
||||
else:
|
||||
# Unicode escape sequence
|
||||
esc = s[end + 1:end + 5]
|
||||
next_end = end + 5
|
||||
if len(esc) != 4:
|
||||
msg = "Invalid \\uXXXX escape"
|
||||
raise JSONDecodeError(msg, s, end)
|
||||
uni = int(esc, 16)
|
||||
# Check for surrogate pair on UCS-4 systems
|
||||
if 0xd800 <= uni <= 0xdbff and sys.maxunicode > 65535:
|
||||
msg = "Invalid \\uXXXX\\uXXXX surrogate pair"
|
||||
if not s[end + 5:end + 7] == '\\u':
|
||||
raise JSONDecodeError(msg, s, end)
|
||||
esc2 = s[end + 7:end + 11]
|
||||
if len(esc2) != 4:
|
||||
raise JSONDecodeError(msg, s, end)
|
||||
uni2 = int(esc2, 16)
|
||||
uni = 0x10000 + (((uni - 0xd800) << 10) | (uni2 - 0xdc00))
|
||||
next_end += 6
|
||||
char = unichr(uni)
|
||||
end = next_end
|
||||
# Append the unescaped character
|
||||
_append(char)
|
||||
return u''.join(chunks), end
|
||||
|
||||
|
||||
# Use speedup if available
|
||||
scanstring = c_scanstring or py_scanstring
|
||||
|
||||
WHITESPACE = re.compile(r'[ \t\n\r]*', FLAGS)
|
||||
WHITESPACE_STR = ' \t\n\r'
|
||||
|
||||
def JSONObject((s, end), encoding, strict, scan_once, object_hook,
|
||||
object_pairs_hook, memo=None,
|
||||
_w=WHITESPACE.match, _ws=WHITESPACE_STR):
|
||||
# Backwards compatibility
|
||||
if memo is None:
|
||||
memo = {}
|
||||
memo_get = memo.setdefault
|
||||
pairs = []
|
||||
# Use a slice to prevent IndexError from being raised, the following
|
||||
# check will raise a more specific ValueError if the string is empty
|
||||
nextchar = s[end:end + 1]
|
||||
# Normally we expect nextchar == '"'
|
||||
if nextchar != '"':
|
||||
if nextchar in _ws:
|
||||
end = _w(s, end).end()
|
||||
nextchar = s[end:end + 1]
|
||||
# Trivial empty object
|
||||
if nextchar == '}':
|
||||
if object_pairs_hook is not None:
|
||||
result = object_pairs_hook(pairs)
|
||||
return result, end + 1
|
||||
pairs = {}
|
||||
if object_hook is not None:
|
||||
pairs = object_hook(pairs)
|
||||
return pairs, end + 1
|
||||
elif nextchar != '"':
|
||||
raise JSONDecodeError("Expecting property name", s, end)
|
||||
end += 1
|
||||
while True:
|
||||
key, end = scanstring(s, end, encoding, strict)
|
||||
key = memo_get(key, key)
|
||||
|
||||
# To skip some function call overhead we optimize the fast paths where
|
||||
# the JSON key separator is ": " or just ":".
|
||||
if s[end:end + 1] != ':':
|
||||
end = _w(s, end).end()
|
||||
if s[end:end + 1] != ':':
|
||||
raise JSONDecodeError("Expecting : delimiter", s, end)
|
||||
|
||||
end += 1
|
||||
|
||||
try:
|
||||
if s[end] in _ws:
|
||||
end += 1
|
||||
if s[end] in _ws:
|
||||
end = _w(s, end + 1).end()
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
try:
|
||||
value, end = scan_once(s, end)
|
||||
except StopIteration:
|
||||
raise JSONDecodeError("Expecting object", s, end)
|
||||
pairs.append((key, value))
|
||||
|
||||
try:
|
||||
nextchar = s[end]
|
||||
if nextchar in _ws:
|
||||
end = _w(s, end + 1).end()
|
||||
nextchar = s[end]
|
||||
except IndexError:
|
||||
nextchar = ''
|
||||
end += 1
|
||||
|
||||
if nextchar == '}':
|
||||
break
|
||||
elif nextchar != ',':
|
||||
raise JSONDecodeError("Expecting , delimiter", s, end - 1)
|
||||
|
||||
try:
|
||||
nextchar = s[end]
|
||||
if nextchar in _ws:
|
||||
end += 1
|
||||
nextchar = s[end]
|
||||
if nextchar in _ws:
|
||||
end = _w(s, end + 1).end()
|
||||
nextchar = s[end]
|
||||
except IndexError:
|
||||
nextchar = ''
|
||||
|
||||
end += 1
|
||||
if nextchar != '"':
|
||||
raise JSONDecodeError("Expecting property name", s, end - 1)
|
||||
|
||||
if object_pairs_hook is not None:
|
||||
result = object_pairs_hook(pairs)
|
||||
return result, end
|
||||
pairs = dict(pairs)
|
||||
if object_hook is not None:
|
||||
pairs = object_hook(pairs)
|
||||
return pairs, end
|
||||
|
||||
def JSONArray((s, end), scan_once, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
|
||||
values = []
|
||||
nextchar = s[end:end + 1]
|
||||
if nextchar in _ws:
|
||||
end = _w(s, end + 1).end()
|
||||
nextchar = s[end:end + 1]
|
||||
# Look-ahead for trivial empty array
|
||||
if nextchar == ']':
|
||||
return values, end + 1
|
||||
_append = values.append
|
||||
while True:
|
||||
try:
|
||||
value, end = scan_once(s, end)
|
||||
except StopIteration:
|
||||
raise JSONDecodeError("Expecting object", s, end)
|
||||
_append(value)
|
||||
nextchar = s[end:end + 1]
|
||||
if nextchar in _ws:
|
||||
end = _w(s, end + 1).end()
|
||||
nextchar = s[end:end + 1]
|
||||
end += 1
|
||||
if nextchar == ']':
|
||||
break
|
||||
elif nextchar != ',':
|
||||
raise JSONDecodeError("Expecting , delimiter", s, end)
|
||||
|
||||
try:
|
||||
if s[end] in _ws:
|
||||
end += 1
|
||||
if s[end] in _ws:
|
||||
end = _w(s, end + 1).end()
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
return values, end
|
||||
|
||||
class JSONDecoder(object):
|
||||
"""Simple JSON <http://json.org> decoder
|
||||
|
||||
Performs the following translations in decoding by default:
|
||||
|
||||
+---------------+-------------------+
|
||||
| JSON | Python |
|
||||
+===============+===================+
|
||||
| object | dict |
|
||||
+---------------+-------------------+
|
||||
| array | list |
|
||||
+---------------+-------------------+
|
||||
| string | unicode |
|
||||
+---------------+-------------------+
|
||||
| number (int) | int, long |
|
||||
+---------------+-------------------+
|
||||
| number (real) | float |
|
||||
+---------------+-------------------+
|
||||
| true | True |
|
||||
+---------------+-------------------+
|
||||
| false | False |
|
||||
+---------------+-------------------+
|
||||
| null | None |
|
||||
+---------------+-------------------+
|
||||
|
||||
It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
|
||||
their corresponding ``float`` values, which is outside the JSON spec.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, encoding=None, object_hook=None, parse_float=None,
|
||||
parse_int=None, parse_constant=None, strict=True,
|
||||
object_pairs_hook=None):
|
||||
"""
|
||||
*encoding* determines the encoding used to interpret any
|
||||
:class:`str` objects decoded by this instance (``'utf-8'`` by
|
||||
default). It has no effect when decoding :class:`unicode` objects.
|
||||
|
||||
Note that currently only encodings that are a superset of ASCII work,
|
||||
strings of other encodings should be passed in as :class:`unicode`.
|
||||
|
||||
*object_hook*, if specified, will be called with the result of every
|
||||
JSON object decoded and its return value will be used in place of the
|
||||
given :class:`dict`. This can be used to provide custom
|
||||
deserializations (e.g. to support JSON-RPC class hinting).
|
||||
|
||||
*object_pairs_hook* is an optional function that will be called with
|
||||
the result of any object literal decode with an ordered list of pairs.
|
||||
The return value of *object_pairs_hook* will be used instead of the
|
||||
:class:`dict`. This feature can be used to implement custom decoders
|
||||
that rely on the order that the key and value pairs are decoded (for
|
||||
example, :func:`collections.OrderedDict` will remember the order of
|
||||
insertion). If *object_hook* is also defined, the *object_pairs_hook*
|
||||
takes priority.
|
||||
|
||||
*parse_float*, if specified, will be called with the string of every
|
||||
JSON float to be decoded. By default, this is equivalent to
|
||||
``float(num_str)``. This can be used to use another datatype or parser
|
||||
for JSON floats (e.g. :class:`decimal.Decimal`).
|
||||
|
||||
*parse_int*, if specified, will be called with the string of every
|
||||
JSON int to be decoded. By default, this is equivalent to
|
||||
``int(num_str)``. This can be used to use another datatype or parser
|
||||
for JSON integers (e.g. :class:`float`).
|
||||
|
||||
*parse_constant*, if specified, will be called with one of the
|
||||
following strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This
|
||||
can be used to raise an exception if invalid JSON numbers are
|
||||
encountered.
|
||||
|
||||
*strict* controls the parser's behavior when it encounters an
|
||||
invalid control character in a string. The default setting of
|
||||
``True`` means that unescaped control characters are parse errors, if
|
||||
``False`` then control characters will be allowed in strings.
|
||||
|
||||
"""
|
||||
self.encoding = encoding
|
||||
self.object_hook = object_hook
|
||||
self.object_pairs_hook = object_pairs_hook
|
||||
self.parse_float = parse_float or float
|
||||
self.parse_int = parse_int or int
|
||||
self.parse_constant = parse_constant or _CONSTANTS.__getitem__
|
||||
self.strict = strict
|
||||
self.parse_object = JSONObject
|
||||
self.parse_array = JSONArray
|
||||
self.parse_string = scanstring
|
||||
self.memo = {}
|
||||
self.scan_once = make_scanner(self)
|
||||
|
||||
def decode(self, s, _w=WHITESPACE.match):
|
||||
"""Return the Python representation of ``s`` (a ``str`` or ``unicode``
|
||||
instance containing a JSON document)
|
||||
|
||||
"""
|
||||
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
|
||||
end = _w(s, end).end()
|
||||
if end != len(s):
|
||||
raise JSONDecodeError("Extra data", s, end, len(s))
|
||||
return obj
|
||||
|
||||
def raw_decode(self, s, idx=0):
|
||||
"""Decode a JSON document from ``s`` (a ``str`` or ``unicode``
|
||||
beginning with a JSON document) and return a 2-tuple of the Python
|
||||
representation and the index in ``s`` where the document ended.
|
||||
|
||||
This can be used to decode a JSON document from a string that may
|
||||
have extraneous data at the end.
|
||||
|
||||
"""
|
||||
try:
|
||||
obj, end = self.scan_once(s, idx)
|
||||
except StopIteration:
|
||||
raise JSONDecodeError("No JSON object could be decoded", s, idx)
|
||||
return obj, end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user