# HG changeset patch # User cmlenz # Date 1182255226 0 # Node ID 60565dc8495d1e3b5eb40cf85ed3ad438bb79d4b # Parent 7d3d03855980d506952be69ba718198c2af3b7d9 More fixes for Windows compatibility: * normalize path segment separator to "/" * use `dates.format_date` also to set the expected date-strings in the frontend tests. diff --git a/babel/messages/pofile.py b/babel/messages/pofile.py --- a/babel/messages/pofile.py +++ b/babel/messages/pofile.py @@ -19,6 +19,7 @@ """ from datetime import date, datetime +import os import re try: set @@ -353,7 +354,8 @@ _write('#. %s\n' % line.strip()) if not no_location: - locs = u' '.join([u'%s:%d' % item for item in message.locations]) + locs = u' '.join([u'%s:%d' % (filename.replace(os.sep, '/'), lineno) + for filename, lineno in message.locations]) if width and width > 0: locs = wrap(locs, width, break_long_words=False) for line in locs: diff --git a/babel/messages/tests/frontend.py b/babel/messages/tests/frontend.py --- a/babel/messages/tests/frontend.py +++ b/babel/messages/tests/frontend.py @@ -11,6 +11,7 @@ # individuals. For the exact contribution history, see the revision # history and logs, available at http://babel.edgewall.org/log/. +from datetime import datetime from distutils.dist import Distribution from distutils.errors import DistutilsOptionError, DistutilsSetupError from distutils.log import _global_log @@ -23,7 +24,9 @@ import unittest from babel import __version__ as VERSION +from babel.dates import format_datetime from babel.messages import frontend +from babel.util import LOCALTZ class ExtractMessagesTestCase(unittest.TestCase): @@ -116,7 +119,9 @@ """ % {'version': VERSION, 'year': time.strftime('%Y'), - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, open(pot_file, 'U').read()) + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, + open(pot_file, 'U').read()) def test_extraction_with_mapping_file(self): self.cmd.copyright_holder = 'FooBar, Inc.' @@ -166,7 +171,9 @@ """ % {'version': VERSION, 'year': time.strftime('%Y'), - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, open(pot_file, 'U').read()) + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, + open(pot_file, 'U').read()) def test_extraction_with_mapping_dict(self): self.dist.message_extractors = { @@ -221,7 +228,9 @@ """ % {'version': VERSION, 'year': time.strftime('%Y'), - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, open(pot_file, 'U').read()) + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, + open(pot_file, 'U').read()) class NewCatalogTestCase(unittest.TestCase): @@ -304,7 +313,8 @@ msgstr[1] "" """ % {'version': VERSION, - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, open(po_file, 'U').read()) @@ -407,7 +417,9 @@ """ % {'version': VERSION, 'year': time.strftime('%Y'), - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, open(pot_file, 'U').read()) + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, + open(pot_file, 'U').read()) def test_extract_with_mapping_file(self): pot_file = os.path.join(self.datadir, 'project', 'i18n', 'temp.pot') @@ -456,7 +468,9 @@ """ % {'version': VERSION, 'year': time.strftime('%Y'), - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, open(pot_file, 'U').read()) + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, + open(pot_file, 'U').read()) def test_init_with_output_dir(self): po_file = os.path.join(self.datadir, 'project', 'i18n', 'en_US', @@ -505,7 +519,8 @@ msgstr[1] "" """ % {'version': VERSION, - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, open(po_file, 'U').read()) diff --git a/babel/util.py b/babel/util.py --- a/babel/util.py +++ b/babel/util.py @@ -65,7 +65,8 @@ buf.append(symbols[part]) elif part: buf.append(re.escape(part)) - return re.match(''.join(buf) + '$', filename) is not None + match = re.match(''.join(buf) + '$', filename.replace(os.sep, '/')) + return match is not None class odict(dict):