[Python-modules-commits] [python-odf] 43/118: Fix attrconverters

Wolfgang Borgert debacle at moszumanska.debian.org
Fri Oct 3 21:27:20 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to reference refs/remotes/upstream/master
in repository python-odf.

commit f7b086fb45219b723974bd28bad6056aa088f341
Author: Søren Roug <soren.roug at eea.europa.eu>
Date:   Sat Mar 7 22:49:26 2009 +0000

    Fix attrconverters
---
 grammar/OpenDocument-schema-v1.1.rng |   2 +-
 odf/attrconverters.py                |  26 +++++----
 odf/grammar.py                       | 105 +++++++++++++++++++++++++++++++++--
 odf/namespaces.py                    |   2 +-
 odf/ooostyles.py                     |  71 -----------------------
 tests/testconverters.py              |  58 +++++++++++++++++++
 6 files changed, 175 insertions(+), 89 deletions(-)

diff --git a/grammar/OpenDocument-schema-v1.1.rng b/grammar/OpenDocument-schema-v1.1.rng
index 32ee051..9fadaa9 100644
--- a/grammar/OpenDocument-schema-v1.1.rng
+++ b/grammar/OpenDocument-schema-v1.1.rng
@@ -6751,7 +6751,7 @@
         </attribute>
     </optional>
 </define>
-<define name="draw-glue-points-attlist" combine="interleave">
+<define name="draw-glue-point-attlist" combine="interleave">
     <attribute name="draw:escape-direction">
         <choice>
             <value>auto</value>
diff --git a/odf/attrconverters.py b/odf/attrconverters.py
index 9abdf05..0117324 100644
--- a/odf/attrconverters.py
+++ b/odf/attrconverters.py
@@ -182,11 +182,6 @@ def cnv_points(attribute, arg, element):
             raise ValueError, "Points must be string or [(0,0),(1,1)] - not %s" % arg
         return strarg
 
-def cnv_position(attribute, arg, element):
-    if element == (STYLENS,u'tab-stop'):
-       return cnv_length(attribute, arg, element)
-    return cnv_string(attribute, arg, element)
-
 def cnv_positiveInteger(attribute, arg, element):
     return str(arg)
 
@@ -253,7 +248,7 @@ attrconverters = {
 	((CHARTNS,u'gap-width'), None): cnv_string,
 	((CHARTNS,u'interpolation'), None): cnv_string,
 	((CHARTNS,u'interval-major'), None): cnv_string,
-	((CHARTNS,u'interval-minor'), None): cnv_string,
+	((CHARTNS,u'interval-minor-divisor'), None): cnv_string,
 	((CHARTNS,u'japanese-candle-stick'), None): cnv_boolean,
 	((CHARTNS,u'label-arrangement'), None): cnv_string,
 	((CHARTNS,u'label-cell-address'), None): cnv_string,
@@ -352,6 +347,7 @@ attrconverters = {
 	((DRAWNS,u'caption-line-length'), None): cnv_length,
 	((DRAWNS,u'caption-point-x'), None): cnv_string,
 	((DRAWNS,u'caption-point-y'), None): cnv_string,
+	((DRAWNS,u'caption-id'), None): cnv_IDREF,
 	((DRAWNS,u'caption-type'), None): cnv_string,
 	((DRAWNS,u'chain-next-name'), None): cnv_string,
 	((DRAWNS,u'class-id'), None): cnv_string,
@@ -476,6 +472,7 @@ attrconverters = {
 	((DRAWNS,u'modifiers'), None): cnv_string,
 	((DRAWNS,u'name'), None): cnv_NCName,
 #	((DRAWNS,u'name'), None): cnv_string,
+	((DRAWNS,u'nav-order'), None): cnv_IDREF,
 	((DRAWNS,u'nohref'), None): cnv_string,
 	((DRAWNS,u'notify-on-update-of-ranges'), None): cnv_string,
 	((DRAWNS,u'object'), None): cnv_string,
@@ -683,7 +680,7 @@ attrconverters = {
 	((MANIFESTNS,'initialisation-vector'), None): cnv_string,
 	((MANIFESTNS,'iteration-count'), None): cnv_nonNegativeInteger,
 	((MANIFESTNS,'key-derivation-name'), None): cnv_string,
-	((MANIFESTNS,'manifest:media-type'), None): cnv_string,
+	((MANIFESTNS,'media-type'), None): cnv_string,
 	((MANIFESTNS,'salt'), None): cnv_string,
 	((MANIFESTNS,'size'), None): cnv_nonNegativeInteger,
 	((METANS,u'cell-count'), None): cnv_nonNegativeInteger,
@@ -746,6 +743,7 @@ attrconverters = {
 	((OFFICENS,u'target-frame'), None): cnv_string,
 	((OFFICENS,u'target-frame-name'), None): cnv_string,
 	((OFFICENS,u'time-value'), None): cnv_duration,
+	((OFFICENS,u'title'), None): cnv_string,
 	((OFFICENS,u'value'), None): cnv_double,
 	((OFFICENS,u'value-type'), None): cnv_string,
 	((OFFICENS,u'version'), None): cnv_string,
@@ -783,6 +781,7 @@ attrconverters = {
 	((PRESENTATIONNS,u'preset-id'), None): cnv_string,
 	((PRESENTATIONNS,u'preset-sub-type'), None): cnv_string,
 	((PRESENTATIONNS,u'show'), None): cnv_string,
+	((PRESENTATIONNS,u'show-end-of-presentation-slide'), None): cnv_boolean,
 	((PRESENTATIONNS,u'show-logo'), None): cnv_boolean,
 	((PRESENTATIONNS,u'source'), None): cnv_string,
 	((PRESENTATIONNS,u'speed'), None): cnv_string,
@@ -873,6 +872,8 @@ attrconverters = {
 	((STYLENS,u'flow-with-text'), None): cnv_boolean,
 	((STYLENS,u'font-adornments'), None): cnv_string,
 	((STYLENS,u'font-charset'), None): cnv_string,
+	((STYLENS,u'font-charset-asian'), None): cnv_string,
+	((STYLENS,u'font-charset-complex'), None): cnv_string,
 	((STYLENS,u'font-family-asian'), None): cnv_string,
 	((STYLENS,u'font-family-complex'), None): cnv_string,
 	((STYLENS,u'font-family-generic-asian'), None): cnv_string,
@@ -949,7 +950,8 @@ attrconverters = {
 	((STYLENS,u'page-usage'), None): cnv_string,
 	((STYLENS,u'paper-tray-name'), None): cnv_string,
 	((STYLENS,u'parent-style-name'), None): cnv_StyleNameRef,
-	((STYLENS,u'position'), None): cnv_position,
+	((STYLENS,u'position'), (STYLENS,u'tab-stop')): cnv_length,
+	((STYLENS,u'position'), None): cnv_string,
 	((STYLENS,u'print'), None): cnv_string,
 	((STYLENS,u'print-content'), None): cnv_boolean,
 	((STYLENS,u'print-orientation'), None): cnv_string,
@@ -1015,7 +1017,7 @@ attrconverters = {
 	((STYLENS,u'wrap'), None): cnv_string,
 	((STYLENS,u'wrap-contour'), None): cnv_boolean,
 	((STYLENS,u'wrap-contour-mode'), None): cnv_string,
-	((STYLENS,u'wrap-dynamic-treshold'), None): cnv_string,
+	((STYLENS,u'wrap-dynamic-threshold'), None): cnv_length,
 	((STYLENS,u'writing-mode-automatic'), None): cnv_boolean,
 	((STYLENS,u'writing-mode'), None): cnv_string,
 	((SVGNS,u'accent-height'), None): cnv_integer,
@@ -1122,7 +1124,7 @@ attrconverters = {
 	((TABLENS,u'database-table-name'), None): cnv_string,
 	((TABLENS,u'date-end'), None): cnv_string,
 	((TABLENS,u'date-start'), None): cnv_string,
-	((TABLENS,u'date-value-type'), None): cnv_date,
+	((TABLENS,u'date-value'), None): cnv_date,
 	((TABLENS,u'default-cell-style-name'), None): cnv_StyleNameRef,
 	((TABLENS,u'direction'), None): cnv_string,
 	((TABLENS,u'display-border'), None): cnv_boolean,
@@ -1304,7 +1306,7 @@ attrconverters = {
 	((TEXTNS,u'database-name'), None): cnv_string,
 	((TEXTNS,u'date-adjust'), None): cnv_duration,
 	((TEXTNS,u'date-value'), None): cnv_date,
-	((TEXTNS,u'date-value'), None): cnv_dateTime,
+#	((TEXTNS,u'date-value'), None): cnv_dateTime,
 	((TEXTNS,u'default-style-name'), None): cnv_StyleNameRef,
 	((TEXTNS,u'description'), None): cnv_string,
 	((TEXTNS,u'display'), None): cnv_string,
@@ -1366,6 +1368,7 @@ attrconverters = {
 	((TEXTNS,u'outline-level'), None): cnv_string,
 	((TEXTNS,u'page-adjust'), None): cnv_integer,
 	((TEXTNS,u'pages'), None): cnv_string,
+	((TEXTNS,u'paragraph-style-name'), None): cnv_StyleNameRef,
 	((TEXTNS,u'placeholder-type'), None): cnv_string,
 	((TEXTNS,u'prefix'), None): cnv_string,
 	((TEXTNS,u'protected'), None): cnv_boolean,
@@ -1417,6 +1420,7 @@ attrconverters = {
 	((TEXTNS,u'use-objects'), None): cnv_boolean,
 	((TEXTNS,u'use-other-objects'), None): cnv_boolean,
 	((TEXTNS,u'use-outline-level'), None): cnv_boolean,
+	((TEXTNS,u'use-soft-page-breaks'), None): cnv_boolean,
 	((TEXTNS,u'use-spreadsheet-objects'), None): cnv_boolean,
 	((TEXTNS,u'use-tables'), None): cnv_boolean,
 	((TEXTNS,u'value'), None): cnv_nonNegativeInteger,
diff --git a/odf/grammar.py b/odf/grammar.py
index 2b5b366..1951845 100644
--- a/odf/grammar.py
+++ b/odf/grammar.py
@@ -27,12 +27,14 @@ from namespaces import *
 
 # The following code is generated from the RelaxNG schema with this notice:
 
-#   OASIS OpenDocument v1.0
-#   OASIS standard, 1 May 2005
-#   Relax-NG Manifest Schema
+#   OASIS OpenDocument v1.1
+#   OASIS Standard, 1 Feb 2007
+#   Relax-NG Schema
 
-#   © 2002-2005 OASIS Open
-#   © 1999-2005 Sun Microsystems, Inc.
+#   $Id$
+
+#   © 2002-2007 OASIS Open
+#   © 1999-2007 Sun Microsystems, Inc.
 
 #   This document and translations of it may be copied and furnished
 #   to others, and derivative works that comment on or otherwise explain
@@ -337,6 +339,7 @@ allowed_children = {
 		(STYLENS,u'map'),
 		(STYLENS,u'text-properties'),
 	),
+# allowed_children
 	(NUMBERNS,u'time-style') : (
 		(NUMBERNS,u'am-pm'),
 		(NUMBERNS,u'hours'),
@@ -436,6 +439,7 @@ allowed_children = {
 		(TEXTNS,u'list'),
 		(TEXTNS,u'p'),
 	),
+# allowed_children
 	(DRAWNS,u'ellipse') : (
 		(DRAWNS,u'glue-point'),
 		(OFFICENS,u'event-listeners'),
@@ -450,6 +454,7 @@ allowed_children = {
 	),
 	(DRAWNS,u'equation') : (
 	),
+# allowed_children
 	(DRAWNS,u'fill-image') : (
 	),
 	(DRAWNS,u'floating-frame') : (
@@ -470,6 +475,7 @@ allowed_children = {
 		(SVGNS,u'desc'),
 		(SVGNS,u'title'),
 	),
+# allowed_children
 	(DRAWNS,u'g') : (
 		(DR3DNS,u'scene'),
 		(DRAWNS,u'caption'),
@@ -541,6 +547,7 @@ allowed_children = {
 		(MATHNS,u'math'),
 		(OFFICENS,u'document'),
 	),
+# allowed_children
 	(DRAWNS,u'object-ole') : (
 		(OFFICENS,u'binary-data'),
 	),
@@ -579,6 +586,7 @@ allowed_children = {
 		(PRESENTATIONNS,u'animations'),
 		(PRESENTATIONNS,u'notes'),
 	),
+# allowed_children
 	(DRAWNS,u'page-thumbnail') : (
 		(SVGNS,u'desc'),
 		(SVGNS,u'title'),
@@ -612,6 +620,7 @@ allowed_children = {
 		(TEXTNS,u'list'),
 		(TEXTNS,u'p'),
 	),
+# allowed_children
 	(DRAWNS,u'rect') : (
 		(DRAWNS,u'glue-point'),
 		(OFFICENS,u'event-listeners'),
@@ -667,6 +676,7 @@ allowed_children = {
 		(TEXTNS,u'table-of-content'),
 		(TEXTNS,u'user-index'),
 	),
+# allowed_children
 	(FORMNS,u'button') : (
 		(FORMNS,u'properties'),
 		(OFFICENS,u'event-listeners'),
@@ -757,6 +767,7 @@ allowed_children = {
 		(FORMNS,u'properties'),
 		(OFFICENS,u'event-listeners'),
 	),
+# allowed_children
 	(FORMNS,u'image-frame') : (
 		(FORMNS,u'properties'),
 		(OFFICENS,u'event-listeners'),
@@ -1263,6 +1274,7 @@ allowed_children = {
 		(TEXTNS,u'user-index'),
 		(TEXTNS,u'variable-decls'),
 	),
+# allowed_children
 	(STYLENS,u'footer-left') : (
 		(STYLENS,u'region-center'),
 		(STYLENS,u'region-left'),
@@ -1300,6 +1312,7 @@ allowed_children = {
 		(STYLENS,u'columns'),
 		(TEXTNS,u'list-style'),
 	),
+# allowed_children
 	(STYLENS,u'handout-master') : (
 		(DR3DNS,u'scene'),
 		(DRAWNS,u'caption'),
@@ -1420,6 +1433,7 @@ allowed_children = {
 		(STYLENS,u'columns'),
 		(STYLENS,u'footnote-sep'),
 	),
+# allowed_children
 	(STYLENS,u'paragraph-properties') : (
 		(STYLENS,u'background-image'),
 		(STYLENS,u'drop-cap'),
@@ -1463,6 +1477,7 @@ allowed_children = {
 	(STYLENS,u'tab-stops') : (
 		(STYLENS,u'tab-stop'),
 	),
+# allowed_children
 	(STYLENS,u'table-cell-properties') : (
 		(STYLENS,u'background-image'),
 	),
@@ -1536,6 +1551,7 @@ allowed_children = {
 		(TABLENS,u'error-message'),
 		(TABLENS,u'help-message'),
 	),
+# allowed_children
 	(TABLENS,u'content-validations') : (
 		(TABLENS,u'content-validation'),
 	),
@@ -1579,6 +1595,7 @@ allowed_children = {
 		(TEXTNS,u'table-of-content'),
 		(TEXTNS,u'user-index'),
 	),
+# allowed_children
 	(TABLENS,u'cut-offs') : (
 		(TABLENS,u'insertion-cut-off'),
 		(TABLENS,u'movement-cut-off'),
@@ -1650,6 +1667,7 @@ allowed_children = {
 	),
 	(TABLENS,u'database-source-table') : (
 	),
+# allowed_children
 	(TABLENS,u'dde-link') : (
 		(OFFICENS,u'dde-source'),
 		(TABLENS,u'table'),
@@ -1676,6 +1694,7 @@ allowed_children = {
 		(TABLENS,u'highlighted-range'),
 		(TABLENS,u'operation'),
 	),
+# allowed_children
 	(TABLENS,u'error-macro') : (
 	),
 	(TABLENS,u'error-message') : (
@@ -1743,6 +1762,7 @@ allowed_children = {
 		(TABLENS,u'named-expression'),
 		(TABLENS,u'named-range'),
 	),
+# allowed_children
 	(TABLENS,u'named-range') : (
 	),
 	(TABLENS,u'null-date') : (
@@ -1777,6 +1797,7 @@ allowed_children = {
 		(DRAWNS,u'rect'),
 		(DRAWNS,u'regular-polygon'),
 	),
+# allowed_children
 	(TABLENS,u'sort') : (
 		(TABLENS,u'sort-by'),
 	),
@@ -1857,6 +1878,7 @@ allowed_children = {
 		(TEXTNS,u'table-of-content'),
 		(TEXTNS,u'user-index'),
 	),
+# allowed_children
 	(TABLENS,u'table-column') : (
 	),
 	(TABLENS,u'table-column-group') : (
@@ -1890,6 +1912,7 @@ allowed_children = {
 		(TABLENS,u'table-row'),
 		(TEXTNS,u'soft-page-break'),
 	),
+# allowed_children
 	(TABLENS,u'table-source') : (
 	),
 	(TABLENS,u'table-template') : (
@@ -2040,6 +2063,7 @@ allowed_children = {
 		(TEXTNS,u'variable-input'),
 		(TEXTNS,u'variable-set'),
 	),
+# allowed_children
 	(TEXTNS,u'alphabetical-index') : (
 		(TEXTNS,u'alphabetical-index-source'),
 		(TEXTNS,u'index-body'),
@@ -2325,6 +2349,7 @@ allowed_children = {
 		(TEXTNS,u'variable-input'),
 		(TEXTNS,u'variable-set'),
 	),
+# allowed_children
 	(TEXTNS,u'hidden-paragraph') : (
 	),
 	(TEXTNS,u'hidden-text') : (
@@ -2742,6 +2767,7 @@ allowed_children = {
 	),
 	(TEXTNS,u'reference-mark-end') : (
 	),
+# allowed_children
 	(TEXTNS,u'reference-mark-start') : (
 	),
 	(TEXTNS,u'reference-ref') : (
@@ -2877,6 +2903,7 @@ allowed_children = {
 		(TEXTNS,u'variable-input'),
 		(TEXTNS,u'variable-set'),
 	),
+# allowed_children
 	(TEXTNS,u'ruby-text') : (
 	),
 	(TEXTNS,u's') : (
@@ -2930,6 +2957,7 @@ allowed_children = {
 	),
 	(TEXTNS,u'sender-country') : (
 	),
+# allowed_children
 	(TEXTNS,u'sender-email') : (
 	),
 	(TEXTNS,u'sender-fax') : (
@@ -2969,6 +2997,7 @@ allowed_children = {
 	),
 	(TEXTNS,u'sort-key') : (
 	),
+# allowed_children
 	(TEXTNS,u'span') : (
 		(DR3DNS,u'scene'),
 		(DRAWNS,u'a'),
@@ -3096,6 +3125,7 @@ allowed_children = {
 		(TEXTNS,u'variable-input'),
 		(TEXTNS,u'variable-set'),
 	),
+# allowed_children
 	(TEXTNS,u'subject') : (
 	),
 	(TEXTNS,u'tab') : (
@@ -3232,6 +3262,7 @@ allows_text = (
 	(METANS,u'date-string'),
 	(METANS,u'editing-cycles'),
 	(METANS,u'editing-duration'),
+# allows_text
 	(METANS,u'generator'),
 	(METANS,u'initial-creator'),
 	(METANS,u'keyword'),
@@ -3274,6 +3305,7 @@ allows_text = (
 	(TEXTNS,u'hidden-paragraph'),
 	(TEXTNS,u'hidden-text'),
 	(TEXTNS,u'image-count'),
+# allowed_children
 	(TEXTNS,u'index-entry-span'),
 	(TEXTNS,u'index-title-template'),
 	(TEXTNS,u'initial-creator'),
@@ -3321,6 +3353,7 @@ allows_text = (
 	(TEXTNS,u'sequence'),
 	(TEXTNS,u'sequence-ref'),
 	(TEXTNS,u'sheet-name'),
+# allowed_children
 	(TEXTNS,u'span'),
 	(TEXTNS,u'subject'),
 	(TEXTNS,u'table-count'),
@@ -3364,6 +3397,7 @@ required_attributes = {
 	(ANIMNS,u'set'): (
 		(SMILNS,u'attributeName'),
 	),
+# required_attributes
 	(ANIMNS,u'transitionFilter'): (
 		(SMILNS,u'type'),
 	),
@@ -3389,6 +3423,7 @@ required_attributes = {
 	(CONFIGNS,u'config-item-set'): (
 		(CONFIGNS,u'name'),
 	),
+# required_attributes
 	(NUMBERNS,u'boolean-style'): (
 		(STYLENS,u'name'),
 	),
@@ -3424,6 +3459,7 @@ required_attributes = {
 		(SVGNS,u'viewBox'),
 		(SVGNS,u'd'),
 	),
+# required_attributes
 	(DRAWNS,u'a'): (
 		(XLINKNS,u'href'),
 	),
@@ -3470,7 +3506,9 @@ required_attributes = {
 		(SVGNS,u'y'),
 		(SVGNS,u'x'),
 		(DRAWNS,u'id'),
+		(DRAWNS,u'escape-direction'),
 	),
+# required_attributes
 	(DRAWNS,u'gradient'): (
 		(DRAWNS,u'style'),
 	),
@@ -3518,6 +3556,7 @@ required_attributes = {
 		(DRAWNS,u'points'),
 		(SVGNS,u'viewBox'),
 	),
+# required_attributes
 	(DRAWNS,u'polyline'): (
 		(DRAWNS,u'points'),
 		(SVGNS,u'viewBox'),
@@ -3564,6 +3603,7 @@ required_attributes = {
 	(FORMNS,u'hidden'): (
 		(FORMNS,u'id'),
 	),
+# required_attributes
 	(FORMNS,u'image'): (
 		(FORMNS,u'id'),
 	),
@@ -3646,6 +3686,7 @@ required_attributes = {
 		(DRAWNS,u'color'),
 		(DRAWNS,u'shape-id'),
 	),
+# required_attributes
 	(PRESENTATIONNS,u'event-listener'): (
 		(PRESENTATIONNS,u'action'),
 		(SCRIPTNS,u'event-name'),
@@ -3692,6 +3733,7 @@ required_attributes = {
 	(STYLENS,u'column'): (
 		(STYLENS,u'rel-width'),
 	),
+# required_attributes
 	(STYLENS,u'column-sep'): (
 		(STYLENS,u'width'),
 	),
@@ -3739,6 +3781,7 @@ required_attributes = {
 	(SVGNS,u'stop'): (
 		(SVGNS,u'offset'),
 	),
+# required_attributes
 	(TABLENS,u'body'): (
 		(TEXTNS,u'style-name'),
 	),
@@ -3809,6 +3852,7 @@ required_attributes = {
 	(TABLENS,u'database-range'): (
 		(TABLENS,u'target-range-address'),
 	),
+# required_attributes
 	(TABLENS,u'database-source-query'): (
 		(TABLENS,u'query-name'),
 		(TABLENS,u'database-name'),
@@ -3855,6 +3899,7 @@ required_attributes = {
 		(TABLENS,u'position'),
 		(TABLENS,u'id'),
 	),
+# required_attributes
 	(TABLENS,u'label-range'): (
 		(TABLENS,u'label-cell-range-address'),
 		(TABLENS,u'data-cell-range-address'),
@@ -3887,6 +3932,7 @@ required_attributes = {
 		(TABLENS,u'index'),
 		(TABLENS,u'name'),
 	),
+# required_attributes
 	(TABLENS,u'scenario'): (
 		(TABLENS,u'is-active'),
 		(TABLENS,u'scenario-ranges'),
@@ -3955,6 +4001,7 @@ required_attributes = {
 	(TEXTNS,u'bookmark'): (
 		(TEXTNS,u'name'),
 	),
+# required_attributes
 	(TEXTNS,u'bookmark-end'): (
 		(TEXTNS,u'name'),
 	),
@@ -4001,6 +4048,7 @@ required_attributes = {
 	(TEXTNS,u'dde-connection'): (
 		(TEXTNS,u'connection-name'),
 	),
+# required_attributes
 	(TEXTNS,u'dde-connection-decl'): (
 		(OFFICENS,u'dde-topic'),
 		(OFFICENS,u'dde-application'),
@@ -4048,6 +4096,7 @@ required_attributes = {
 	(TEXTNS,u'list-style'): (
 		(STYLENS,u'name'),
 	),
+# required_attributes
 	(TEXTNS,u'measure'): (
 		(TEXTNS,u'kind'),
 	),
@@ -4211,6 +4260,7 @@ allowed_attributes = {
 # Completes Dublin Core end
 	(MATHNS,u'math'): None,
 	(XFORMSNS,u'model'): None,
+# allowed_attributes
 	(ANIMNS,u'animate'):(
 		(ANIMNS,u'formula'),
 		(ANIMNS,u'sub-item'),
@@ -4238,6 +4288,7 @@ allowed_attributes = {
 		(SMILNS,u'to'),
 		(SMILNS,u'values'),
 	),
+# allowed_attributes
 	(ANIMNS,u'animateColor'):(
 		(ANIMNS,u'color-interpolation'),
 		(ANIMNS,u'color-interpolation-direction'),
@@ -4297,6 +4348,7 @@ allowed_attributes = {
 		(SVGNS,u'origin'),
 		(SVGNS,u'path'),
 	),
+# allowed_attributes
 	(ANIMNS,u'animateTransform'):(
 		(ANIMNS,u'formula'),
 		(ANIMNS,u'sub-item'),
@@ -4322,6 +4374,7 @@ allowed_attributes = {
 		(SMILNS,u'values'),
 		(SVGNS,u'type'),
 	),
+# allowed_attributes
 	(ANIMNS,u'audio'):(
 		(ANIMNS,u'audio-level'),
 		(ANIMNS,u'id'),
@@ -4352,6 +4405,7 @@ allowed_attributes = {
 		(ANIMNS,u'id'),
 		(PRESENTATIONNS,u'master-element'),
 	),
+# allowed_attributes
 	(ANIMNS,u'iterate'):(
 		(ANIMNS,u'id'),
 		(ANIMNS,u'iterate-interval'),
@@ -4400,6 +4454,7 @@ allowed_attributes = {
 		(SMILNS,u'restart'),
 		(PRESENTATIONNS,u'master-element'),
 	),
+# allowed_attributes
 	(ANIMNS,u'param'):(
 		(ANIMNS,u'name'),
 		(ANIMNS,u'value'),
@@ -4447,6 +4502,7 @@ allowed_attributes = {
 		(SMILNS,u'to'),
 
 	),
+# allowed_attributes
 	(ANIMNS,u'transitionFilter'):(
 		(ANIMNS,u'formula'),
 		(ANIMNS,u'sub-item'),
@@ -4564,6 +4620,7 @@ allowed_attributes = {
 	(CHARTNS,u'stock-gain-marker'):(
 		(CHARTNS,u'style-name'),
 	),
+# allowed_attributes
 	(CHARTNS,u'stock-loss-marker'):(
 		(CHARTNS,u'style-name'),
 	),
@@ -4637,6 +4694,7 @@ allowed_attributes = {
 		(NUMBERNS,u'country'),
 		(NUMBERNS,u'language'),
 	),
+# allowed_attributes
 	(NUMBERNS,u'date-style'):(
 		(NUMBERNS,u'transliteration-language'),
 		(STYLENS,u'name'),
@@ -4675,6 +4733,7 @@ allowed_attributes = {
 	(NUMBERNS,u'hours'):(
 		(NUMBERNS,u'style'),
 	),
+# allowed_attributes
 	(NUMBERNS,u'minutes'):(
 		(NUMBERNS,u'style'),
 	),
@@ -5084,6 +5143,7 @@ allowed_attributes = {
 		(SVGNS,u'x'),
 		(DRAWNS,u'text-style-name'),
 	),
+# allowed_attributes
 	(DRAWNS,u'enhanced-geometry'):(
 		(DRAWNS,u'extrusion-rotation-center'),
 		(DRAWNS,u'extrusion-shininess'),
@@ -5129,6 +5189,7 @@ allowed_attributes = {
 		(DRAWNS,u'glue-point-type'),
 		(DRAWNS,u'text-path'),
 	),
+# allowed_attributes
 	(DRAWNS,u'equation'):(
 		(DRAWNS,u'formula'),
 		(DRAWNS,u'name'),
@@ -5179,6 +5240,7 @@ allowed_attributes = {
 		(TEXTNS,u'anchor-page-number'),
 		(TEXTNS,u'anchor-type'),
 	),
+# allowed_attributes
 	(DRAWNS,u'g'):(
 		(DRAWNS,u'id'),
                 (DRAWNS,u'caption-id'),
@@ -5201,6 +5263,7 @@ allowed_attributes = {
 		(SVGNS,u'x'),
 		(DRAWNS,u'align'),
 		(DRAWNS,u'id'),
+		(DRAWNS,u'escape-direction'),
 	),
 	(DRAWNS,u'gradient'):(
 		(DRAWNS,u'style'),
@@ -5250,6 +5313,7 @@ allowed_attributes = {
 		(DRAWNS,u'name'),
 		(DRAWNS,u'display'),
 	),
+# allowed_attributes
 	(DRAWNS,u'layer-set'):(
 	),
 	(DRAWNS,u'line'):(
@@ -5371,6 +5435,7 @@ allowed_attributes = {
 		(DRAWNS,u'name'),
 		(DRAWNS,u'value'),
 	),
+# allowed_attributes
 	(DRAWNS,u'path'):(
 		(TABLENS,u'table-background'),
 		(DRAWNS,u'layer'),
@@ -5428,6 +5493,7 @@ allowed_attributes = {
 		(SVGNS,u'viewBox'),
 		(TEXTNS,u'anchor-type'),
 	),
+# allowed_attributes
 	(DRAWNS,u'polyline'):(
 		(TABLENS,u'table-background'),
 		(DRAWNS,u'layer'),
@@ -5523,6 +5589,7 @@ allowed_attributes = {
 		(FONS,u'max-width'),
                 (TEXTNS,u'id'),
 	),
+# allowed_attributes
 	(FORMNS,u'button'):(
 		(FORMNS,u'tab-stop'),
 		(FORMNS,u'focus-on-click'),
@@ -5594,6 +5661,7 @@ allowed_attributes = {
 		(FORMNS,u'current-value'),
 		(FORMNS,u'size'),
 	),
+# allowed_attributes
 	(FORMNS,u'connection-resource'):(
 		(XLINKNS,u'href'),
 	),
@@ -5643,6 +5711,7 @@ allowed_attributes = {
 		(FORMNS,u'printable'),
 		(FORMNS,u'id'),
 	),
+# allowed_attributes
 	(FORMNS,u'form'):(
 		(XLINKNS,u'actuate'),
 		(XLINKNS,u'href'),
@@ -5699,6 +5768,7 @@ allowed_attributes = {
 		(FORMNS,u'printable'),
 		(FORMNS,u'id'),
 	),
+# allowed_attributes
 	(FORMNS,u'generic-control'):(
 		(FORMNS,u'control-implementation'),
 		(XFORMSNS,u'bind'),
@@ -5978,6 +6048,7 @@ allowed_attributes = {
 	),
 	(METANS,u'generator'):(
 	),
+# allowed_attributes
 	(METANS,u'hyperlink-behaviour'):(
 		(OFFICENS,u'target-frame-name'),
 		(XLINKNS,u'show'),
@@ -6073,6 +6144,7 @@ allowed_attributes = {
 	),
 	(OFFICENS,u'image'):(
 	),
+# allowed_attributes
 	(OFFICENS,u'master-styles'):(
 	),
 	(OFFICENS,u'meta'):(
@@ -6143,6 +6215,7 @@ allowed_attributes = {
 		(PRESENTATIONNS,u'speed'),
 		(DRAWNS,u'shape-id'),
 	),
+# allowed_attributes
 	(PRESENTATIONNS,u'hide-text'):(
 		(PRESENTATIONNS,u'direction'),
 		(PRESENTATIONNS,u'effect'),
@@ -6216,6 +6289,7 @@ allowed_attributes = {
 		(PRESENTATIONNS,u'play-full'),
 		(XLINKNS,u'show'),
 	),
+# allowed_attributes
 	(SCRIPTNS,u'event-listener'):(
 		(SCRIPTNS,u'language'),
 		(SCRIPTNS,u'macro-name'),
@@ -6308,6 +6382,7 @@ allowed_attributes = {
 	(STYLENS,u'default-style'):(
 		(STYLENS,u'family'),
 	),
+# allowed_attributes
 	(STYLENS,u'drawing-page-properties'): (
 		(DRAWNS,u'fill'),
 		(DRAWNS,u'fill-color'),
@@ -6350,6 +6425,7 @@ allowed_attributes = {
 		(STYLENS,u'style-name'),
 		(STYLENS,u'lines'),
 	),
+# allowed_attributes
 	(STYLENS,u'font-face'):(
 		(STYLENS,u'font-adornments'),
 		(STYLENS,u'font-charset'),
@@ -6590,6 +6666,7 @@ allowed_attributes = {
 		(PRESENTATIONNS,u'use-header-name'),
 		(PRESENTATIONNS,u'use-date-time-name'),
 	),
+# allowed_attributes
 	(STYLENS,u'header'):(
 		(STYLENS,u'display'),
 	),
@@ -6654,6 +6731,7 @@ allowed_attributes = {
 		(STYLENS,u'name'),
 		(STYLENS,u'page-usage'),
 	),
+# allowed_attributes
 	(STYLENS,u'page-layout-properties'): (
 		(FONS,u'background-color'),
 		(FONS,u'border'),
@@ -6703,6 +6781,7 @@ allowed_attributes = {
 		(STYLENS,u'table-centering'),
 		(STYLENS,u'writing-mode'),
 	),
+# allowed_attributes
 	(STYLENS,u'paragraph-properties'): (
 		(FONS,u'background-color'),
 		(FONS,u'border'),
@@ -6793,6 +6872,7 @@ allowed_attributes = {
 		(STYLENS,u'display-name'),
 		(STYLENS,u'parent-style-name'),
 	),
+# allowed_attributes
 	(STYLENS,u'tab-stop'):(
 		(STYLENS,u'leader-text-style'),
 		(STYLENS,u'leader-width'),
@@ -6841,6 +6921,7 @@ allowed_attributes = {
 		(STYLENS,u'text-align-source'),
 		(STYLENS,u'vertical-align'),
 	),
+# allowed_attributes
 	(STYLENS,u'table-column-properties'): (
 		(FONS,u'break-after'),
 		(FONS,u'break-before'),
@@ -6963,6 +7044,7 @@ allowed_attributes = {
 	(SVGNS,u'font-face-format'):(
 		(SVGNS,u'string'),
 	),
+# allowed_attributes
 	(SVGNS,u'font-face-name'):(
 		(SVGNS,u'name'),
 	),
@@ -7003,6 +7085,7 @@ allowed_attributes = {
 	),
 	(SVGNS,u'title'):(
 	),
+# allowed_attributes
 	(TABLENS,u'body'):(
 		(TEXTNS,u'paragraph-style-name'),
 		(TEXTNS,u'style-name'),
@@ -7072,6 +7155,7 @@ allowed_attributes = {
 	),
 	(TABLENS,u'content-validations'):(
 	),
+# allowed_attributes
 	(TABLENS,u'covered-table-cell'):(
 		(TABLENS,u'protect'),
 		(OFFICENS,u'string-value'),
@@ -7387,6 +7471,7 @@ allowed_attributes = {
 		(TABLENS,u'end-table'),
 		(TABLENS,u'start-column'),
 	),
+# allowed_attributes
 	(TABLENS,u'source-service'):(
 		(TABLENS,u'user-name'),
 		(TABLENS,u'source-name'),
@@ -7433,6 +7518,7 @@ allowed_attributes = {
 		(TABLENS,u'formula'),
 		(OFFICENS,u'time-value'),
 	),
+# allowed_attributes
 	(TABLENS,u'table-column'):(
 		(TABLENS,u'style-name'),
 		(TABLENS,u'default-cell-style-name'),
@@ -7525,6 +7611,7 @@ allowed_attributes = {
 		(TEXTNS,u'key2-phonetic'),
 		(TEXTNS,u'string-value-phonetic'),
 	),
+# allowed_attributes
 	(TEXTNS,u'alphabetical-index-mark-end'):(
 		(TEXTNS,u'id'),
 	),
@@ -7579,6 +7666,7 @@ allowed_attributes = {
 		(TEXTNS,u'style-name'),
 		(TEXTNS,u'bibliography-type'),
 	),
+# allowed_attributes
 	(TEXTNS,u'bibliography-mark'):(
 		(TEXTNS,u'address'),
 		(TEXTNS,u'annote'),
@@ -7628,6 +7716,7 @@ allowed_attributes = {
 	(TEXTNS,u'bookmark-start'):(
 		(TEXTNS,u'name'),
 	),
+# allowed_attributes
 	(TEXTNS,u'change'):(
 		(TEXTNS,u'change-id'),
 	),
@@ -7747,6 +7836,7 @@ allowed_attributes = {
 		(TEXTNS,u'fixed'),
 		(TEXTNS,u'display'),
 	),
+# allowed_attributes
 	(TEXTNS,u'format-change'):(
 	),
 	(TEXTNS,u'h'):(
@@ -7794,6 +7884,7 @@ allowed_attributes = {
 		(TEXTNS,u'style-name'),
 		(TEXTNS,u'display'),
 	),
+# allowed_attributes
 	(TEXTNS,u'index-entry-link-end'):(
 		(TEXTNS,u'style-name'),
 	),
@@ -7890,6 +7981,7 @@ allowed_attributes = {
 		(STYLENS,u'num-letter-sync'),
 		(TEXTNS,u'start-value'),
 	),
+# allowed_attributes
 	(TEXTNS,u'list-style'):(
 		(TEXTNS,u'consecutive-numbering'),
 		(STYLENS,u'display-name'),
@@ -8079,6 +8171,7 @@ allowed_attributes = {
 	(TEXTNS,u'sender-country'):(
 		(TEXTNS,u'fixed'),
 	),
+# allowed_attributes
 	(TEXTNS,u'sender-email'):(
 		(TEXTNS,u'fixed'),
 	),
@@ -8173,6 +8266,7 @@ allowed_attributes = {
 		(TEXTNS,u'caption-sequence-format'),
 		(TEXTNS,u'relative-tab-stop-position'),
 	),
+# allowed_attributes
 	(TEXTNS,u'table-of-content'):(
 		(TEXTNS,u'protected'),
 		(TEXTNS,u'style-name'),
@@ -8248,6 +8342,7 @@ allowed_attributes = {
 		(TEXTNS,u'name'),
 		(TEXTNS,u'display'),
 	),
+# allowed_attributes
 	(TEXTNS,u'user-field-input'):(
 		(STYLENS,u'data-style-name'),
 		(TEXTNS,u'name'),
diff --git a/odf/namespaces.py b/odf/namespaces.py
index 5940535..e647906 100644
--- a/odf/namespaces.py
+++ b/odf/namespaces.py
@@ -71,7 +71,7 @@ nsdict = {
    OFFICENS: u'office',
    OOONS: u'ooo',
    OOOWNS: u'ooow',
-   OOOCNS: u'ooc',
+   OOOCNS: u'oooc',
    PRESENTATIONNS: u'presentation',
    RDFANS: u'rdfa',
    SCRIPTNS: u'script',
diff --git a/odf/ooostyles.py b/odf/ooostyles.py
deleted file mode 100644
index 8600d3a..0000000
--- a/odf/ooostyles.py
+++ /dev/null
@@ -1,71 +0,0 @@
-from style import Style, ParagraphProperties, TextProperties
-
-def addOOoStandardStyles(styles):
-    style = Style(name="Standard", family="paragraph", attributes={'class':"text"})
-    styles.addElement(style)
-
-    style = Style(name="Text_20_body", displayname="Text body", family="paragraph", parentstylename="Standard", attributes={'class':"text"})
-    p = ParagraphProperties(margintop="0cm", marginbottom="0.212cm")
-    style.addElement(p)
-    styles.addElement(style)
-
-    style = Style(name="Text_20_body_20_indent", displayname="Text body indent", family="paragraph", parentstylename="Text_20_body", attributes={'class':"text"})
-    p = ParagraphProperties(marginleft="0.499cm", marginright="0cm", textindent="0cm", autotextindent="false")
-    style.addElement(p)
-    styles.addElement(style)
-
-    style = Style(name="Salutation", family="paragraph", parentstylename="Standard", attributes={'class':"text"})
-    p = ParagraphProperties(numberlines="false", linenumber=0)
-    style.addElement(p)
-    styles.addElement(style)
-
-    style = Style(name="Signature", family="paragraph", parentstylename="Standard", attributes={'class':"text"})
-    p = ParagraphProperties(numberlines="false", linenumber=0)
-    style.addElement(p)
-    styles.addElement(style)
-
-    style = Style(name="Heading", family="paragraph", parentstylename="Standard", nextstylename="Text_20_body", attributes={'class':"text"})
-    p = ParagraphProperties(margintop="0.423cm", marginbottom="0.212cm", keepwithnext="always")
-    style.addElement(p)
-    p = TextProperties(fontname="Nimbus Sans L", fontsize="14pt", fontnameasian="DejaVu LGC Sans", fontsizeasian="14pt", fontnamecomplex="DejaVu LGC Sans", fontsizecomplex="14pt")
-    style.addElement(p)
-    styles.addElement(style)
-
-    style = Style(name="Heading_20_1", displayname="Heading 1", family="paragraph", parentstylename="Heading", nextstylename="Text_20_body", attributes={'class':"text"}, defaultoutlinelevel=1)
-    p = TextProperties(fontsize="115%", fontweight="bold", fontsizeasian="115%", fontweightasian="bold", fontsizecomplex="115%", fontweightcomplex="bold")
-    style.addElement(p)
-    styles.addElement(style)
-
-    style = Style(name="Heading_20_2", displayname="Heading 2", family="paragraph", parentstylename="Heading", nextstylename="Text_20_body", attributes={'class':"text"}, defaultoutlinelevel=2)
-    p = TextProperties(fontsize="14pt", fontstyle="italic", fontweight="bold", fontsizeasian="14pt", fontstyleasian="italic", fontweightasian="bold", fontsizecomplex="14pt", fontstylecomplex="italic", fontweightcomplex="bold")
-    style.addElement(p)
-    styles.addElement(style)
-
-    style = Style(name="Heading_20_3", displayname="Heading 3", family="paragraph", parentstylename="Heading", nextstylename="Text_20_body", attributes={'class':"text"}, defaultoutlinelevel=3)
-    p = TextProperties(fontsize="14pt", fontweight="bold", fontsizeasian="14pt", fontweightasian="bold", fontsizecomplex="14pt", fontweightcomplex="bold")
-    style.addElement(p)
-    styles.addElement(style)
-
-    style = Style(name="List", family="paragraph", parentstylename="Text_20_body", attributes={'class':"list"})
-    styles.addElement(style)
-
-    style = Style(name="Caption", family="paragraph", parentstylename="Standard", attributes={'class':"extra"})
-    p = ParagraphProperties(margintop="0.212cm", marginbottom="0.212cm", numberlines="false", linenumber="0")
-    style.addElement(p)
-    p = TextProperties(fontsize="12pt", fontstyle="italic", fontsizeasian="12pt", fontstyleasian="italic", fontsizecomplex="12pt", fontstylecomplex="italic")
-    style.addElement(p)
-    styles.addElement(style)
-
-    style = Style(name="Index", family="paragraph", parentstylename="Standard", attributes={'class':"index"})
-    p = ParagraphProperties(numberlines="false", linenumber=0)
-    styles.addElement(style)
-
-    style = Style(name="Source_20_Text", displayname="Source Text", family="text")
-    p = TextProperties(fontname="Courier", fontnameasian="Courier", fontnamecomplex="Courier")
-    style.addElement(p)
-    styles.addElement(style)
-
-    style = Style(name="Variable", family="text")
-    p = TextProperties(fontstyle="italic", fontstyleasian="italic", fontstylecomplex="italic")
-    style.addElement(p)
-    styles.addElement(style)
diff --git a/tests/testconverters.py b/tests/testconverters.py
new file mode 100644
index 0000000..16b2903
--- /dev/null
+++ b/tests/testconverters.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 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):
+#
+
+import unittest
+from odf import grammar, attrconverters
+from odf.namespaces import OFFICENS
+
+def findconv(attribute, element):
+    converter = attrconverters.attrconverters.get((attribute,element), None)
+    if converter is not None:
+        return attribute
+    else:
+        converter = attrconverters.attrconverters.get((attribute, None), None)
+        if converter is not None:
+            return attribute
+    return ""
+
+
+class TestConverters(unittest.TestCase):
+    allattrs = {}
+    allqattrs = {}
+
+    def testConverters(self):
+        """ Check that there are converters for all attributes and vice versa"""
+        for element,attrs in grammar.allowed_attributes.items():
+            if attrs:
+                for attr in attrs:
+                    self.allattrs[attr] = 1
+                    self.allqattrs[(attr, element)] = 1
+                    self.assertEquals(attr, findconv(attr, element))
+        for (attr,elem) in attrconverters.attrconverters.keys():
+            if attr == (OFFICENS,u'process-content'):  # Special attribute
+                continue
+            if elem is None:
+                self.assertEquals(self.allattrs[attr], 1)
+            else:
+                self.assertEquals(self.allqattrs[(attr, elem)], 1)
+
+
+if __name__ == '__main__':
+    unittest.main()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-odf.git



More information about the Python-modules-commits mailing list