[gnome-doc-utils] [xml2po] Make all modes inherit from basic mode



commit ea7f21d0423c800dc063aaa27542c116f2b7a8c1
Author: Claude Paroz <claude 2xlibre net>
Date:   Wed Jun 24 23:14:30 2009 +0200

    [xml2po] Make all modes inherit from basic mode

 xml2po/modes/Makefile.am |    2 +-
 xml2po/modes/docbook.py  |    8 ++---
 xml2po/modes/empty.py    |   63 ----------------------------------------------
 xml2po/modes/gs.py       |   16 ++---------
 xml2po/modes/xhtml.py    |   34 +++----------------------
 5 files changed, 11 insertions(+), 112 deletions(-)
---
diff --git a/xml2po/modes/Makefile.am b/xml2po/modes/Makefile.am
index 55eff17..7a7f956 100644
--- a/xml2po/modes/Makefile.am
+++ b/xml2po/modes/Makefile.am
@@ -1,4 +1,4 @@
 commondir = $(datadir)/xml2po
-common_DATA = docbook.py empty.py gs.py ubuntu.py xhtml.py
+common_DATA = basic.py docbook.py gs.py ubuntu.py xhtml.py
 
 EXTRA_DIST = $(common_DATA)
diff --git a/xml2po/modes/docbook.py b/xml2po/modes/docbook.py
index 7fac01b..2e43f36 100644
--- a/xml2po/modes/docbook.py
+++ b/xml2po/modes/docbook.py
@@ -43,7 +43,9 @@ try:
 except ImportError:
     from md5 import new as md5_new
 
-class docbookXmlMode:
+from basic import basicXmlMode
+
+class docbookXmlMode(basicXmlMode):
     """Class for special handling of DocBook document types.
 
     It sets lang attribute on article elements, and adds translators
@@ -77,10 +79,6 @@ class docbookXmlMode:
             'userinput'
             ]
 
-    def getTreatedAttributes(self):
-        "Returns array of tag attributes which content is to be translated"
-        return []
-
     def getStringForTranslators(self):
         """Returns string which will be used to credit translators."""
         return "translator-credits"
diff --git a/xml2po/modes/gs.py b/xml2po/modes/gs.py
index 9ba0307..6a8fc17 100644
--- a/xml2po/modes/gs.py
+++ b/xml2po/modes/gs.py
@@ -20,7 +20,9 @@
 # Special case Gnome Summary
 #
 
-class gsXmlMode:
+from basic import basicXmlMode
+
+class gsXmlMode(basicXmlMode):
     """Abstract class for special handling of document types."""
     def getIgnoredTags(self):
         "Returns array of tags to be ignored."
@@ -30,18 +32,6 @@ class gsXmlMode:
         "Returns array of tags to be considered 'final'."
         return ['title', 'para', 'name', 'desc' ]
 
-    def getSpacePreserveTags(self):
-        "Returns array of tags in which spaces are to be preserved."
-        return []
-
-    def getTreatedAttributes(self):
-        "Returns array of tag attributes which content is to be translated"
-        return []
-
-    def preProcessXml(self, doc, msg):
-        "Preprocess a document and perhaps adds some messages."
-        pass
-
     def _find_salute(self, node):
         if node.name == 'salute':
             return node
diff --git a/xml2po/modes/xhtml.py b/xml2po/modes/xhtml.py
index f4371e7..9b865c6 100644
--- a/xml2po/modes/xhtml.py
+++ b/xml2po/modes/xhtml.py
@@ -1,5 +1,5 @@
 # Copyright (c) 2004, 2005, 2006 Danilo Segan <danilo gnome org>.
-# Copyright (c) 2006 Claude Paroz <paroz email ch>.
+# Copyright (c) 2006, 2009 Claude Paroz <claude 2xlibre net>.
 #
 # This file is part of xml2po.
 #
@@ -21,12 +21,10 @@
 # This implements special instructions for handling XHTML documents
 # in a better way, particularly to extract some attributes in HTML tags
 
-class xhtmlXmlMode:
-    """Class for special handling of XHTML document types."""
-    def getIgnoredTags(self):
-        "Returns array of tags to be ignored."
-        return []
+from basic import basicXmlMode
 
+class xhtmlXmlMode(basicXmlMode):
+    """Class for special handling of XHTML document types."""
     def getFinalTags(self):
         "Returns array of tags to be considered 'final'."
         return ['p', 'li', 'pre']
@@ -38,27 +36,3 @@ class xhtmlXmlMode:
     def getSpacePreserveTags(self):
         "Returns array of tags in which spaces are to be preserved."
         return ['pre']
-
-    def preProcessXml(self, doc, msg):
-        "Preprocess a document and perhaps adds some messages."
-        pass
-
-    def postProcessXmlTranslation(self, doc, language, translators):
-        """Sets a language and translators in "doc" tree.
-
-        "translators" is a string consisted of translator credits.
-        "language" is a simple string.
-        "doc" is a libxml2.xmlDoc instance."""
-        pass
-
-    def getStringForTranslators(self):
-        """Returns None or a string to be added to PO files.
-
-        Common example is 'translator-credits'."""
-        return None
-
-    def getCommentForTranslators(self):
-        """Returns a comment to be added next to string for crediting translators.
-
-        It should explain the format of the string provided by getStringForTranslators()."""
-        return None



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]