[Checkins] SVN: zope.app.locales/trunk/ Write POT creation date in standard format.

Gediminas Paulauskas menesis at pov.lt
Thu Feb 16 17:43:02 UTC 2012


Log message for revision 124421:
  Write POT creation date in standard format.
  Add a doctest for POTMaker.write
  

Changed:
  U   zope.app.locales/trunk/CHANGES.txt
  U   zope.app.locales/trunk/buildout.cfg
  U   zope.app.locales/trunk/src/zope/app/locales/extract.py
  U   zope.app.locales/trunk/src/zope/app/locales/tests.py

-=-
Modified: zope.app.locales/trunk/CHANGES.txt
===================================================================
--- zope.app.locales/trunk/CHANGES.txt	2012-02-16 16:23:09 UTC (rev 124420)
+++ zope.app.locales/trunk/CHANGES.txt	2012-02-16 17:43:02 UTC (rev 124421)
@@ -5,7 +5,7 @@
 3.7.4 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- Write POT creation date in standard format.
 
 
 3.7.3 (2012-01-06)

Modified: zope.app.locales/trunk/buildout.cfg
===================================================================
--- zope.app.locales/trunk/buildout.cfg	2012-02-16 16:23:09 UTC (rev 124420)
+++ zope.app.locales/trunk/buildout.cfg	2012-02-16 17:43:02 UTC (rev 124421)
@@ -11,7 +11,7 @@
 
 [test]
 recipe = zc.recipe.testrunner
-eggs = zope.app.locales [test,zcml]
+eggs = zope.app.locales [test,zcml,extract]
 
 [ctags]
 recipe = z3c.recipe.tag

Modified: zope.app.locales/trunk/src/zope/app/locales/extract.py
===================================================================
--- zope.app.locales/trunk/src/zope/app/locales/extract.py	2012-02-16 16:23:09 UTC (rev 124420)
+++ zope.app.locales/trunk/src/zope/app/locales/extract.py	2012-02-16 17:43:02 UTC (rev 124421)
@@ -181,7 +181,8 @@
 
     def write(self):
         file = open(self._output_filename, 'w')
-        file.write(pot_header % {'time':     time.ctime(),
+        ztime = time.strftime('%Y-%m-%d %H:%M%z')
+        file.write(pot_header % {'time':     ztime,
                                  'version':  self._getProductVersion(),
                                  'charset':  DEFAULT_CHARSET,
                                  'encoding': DEFAULT_ENCODING})

Modified: zope.app.locales/trunk/src/zope/app/locales/tests.py
===================================================================
--- zope.app.locales/trunk/src/zope/app/locales/tests.py	2012-02-16 16:23:09 UTC (rev 124420)
+++ zope.app.locales/trunk/src/zope/app/locales/tests.py	2012-02-16 17:43:02 UTC (rev 124421)
@@ -12,10 +12,12 @@
 #
 ##############################################################################
 """Tests for the message string extraction tool."""
+__docformat__ = 'restructuredtext'
 
 import doctest
 import os
 import unittest
+import tempfile
 import zope.app.locales
 import zope.component
 import zope.configuration.xmlconfig
@@ -162,11 +164,73 @@
     """
 
 
+def doctest_POTMaker_write():
+    r"""Test for POTMaker.write
+
+        >>> from zope.app.locales.extract import POTMaker
+        >>> f, path = tempfile.mkstemp()
+        >>> pm = POTMaker(path, '')
+        >>> pm.add({'msgid1': [('file2.py', 2), ('file1.py', 3)],
+        ...         'msgid2': [('file1.py', 5)]})
+        >>> from zope.app.locales.pygettext import make_escapes
+        >>> make_escapes(0)
+        >>> pm.write()
+
+        >>> f = open(path)
+        >>> pot = f.read()
+        >>> print pot
+        ##############################################################################
+        #
+        # Copyright (c) 2003-2004 Zope Foundation and Contributors.
+        # All Rights Reserved.
+        #
+        # This software is subject to the provisions of the Zope Public License,
+        # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+        # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+        # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+        # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+        # FOR A PARTICULAR PURPOSE.
+        #
+        ##############################################################################
+        msgid ""
+        msgstr ""
+        "Project-Id-Version: Meaningless\n"
+        "POT-Creation-Date: ...-...-... ...:...0\n"
+        "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+        "Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+        "Language-Team: Zope 3 Developers <zope-dev at zope.org>\n"
+        "MIME-Version: 1.0\n"
+        "Content-Type: text/plain; charset=UTF-8\n"
+        "Content-Transfer-Encoding: 8bit\n"
+        "Generated-By: zope/app/locales/extract.py\n"
+        <BLANKLINE>
+        #: file1.py:3
+        #: file2.py:2
+        msgid "msgid1"
+        msgstr ""
+        <BLANKLINE>
+        #: file1.py:5
+        msgid "msgid2"
+        msgstr ""
+        <BLANKLINE>
+        <BLANKLINE>
+
+        >>> f.close()
+        >>> os.unlink(path)
+
+    """
+
+
 def test_suite():
     return unittest.TestSuite((
-        doctest.DocTestSuite(),
+        doctest.DocTestSuite(
+            optionflags=doctest.NORMALIZE_WHITESPACE|
+                        doctest.ELLIPSIS|
+                        doctest.REPORT_NDIFF,),
         doctest.DocTestSuite('zope.app.locales.extract',
-            optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,),
+            optionflags=doctest.NORMALIZE_WHITESPACE|
+                        doctest.ELLIPSIS|
+                        doctest.REPORT_NDIFF,),
         unittest.makeSuite(TestIsUnicodeInAllCatalog),
         unittest.makeSuite(ZCMLTest),
         ))



More information about the checkins mailing list