Add +0000 to POT-Creation-Date

%z sets an empty string when datetimes are "naive" (no timezone
specified), but some packages expect a timezone specifier on the
POT-Creation-Date header and will error out if it is missing
(e.g. babel's pofile.read_po).

Lifted the stdlib's UTC timezone recipe and set this explicitly, it's
not the correct timezone but at least it's a timezone.

The LocalTimezone recipe might be a better one.
This commit is contained in:
masklinn 2013-05-28 11:30:57 +00:00
parent 9d3bac3b8e
commit d1d1d9a73d

View File

@ -11,7 +11,7 @@
from os import path, walk from os import path, walk
from codecs import open from codecs import open
from datetime import datetime from datetime import datetime, tzinfo, timedelta
from collections import defaultdict from collections import defaultdict
from uuid import uuid4 from uuid import uuid4
@ -107,6 +107,24 @@ class I18nBuilder(Builder):
catalog.add(m, node) catalog.add(m, node)
ZERO = timedelta(0)
HOUR = timedelta(hours=1)
class UTC(tzinfo):
"""UTC"""
def utcoffset(self, dt):
return ZERO
def tzname(self, dt):
return "UTC"
def dst(self, dt):
return ZERO
utc = UTC()
class MessageCatalogBuilder(I18nBuilder): class MessageCatalogBuilder(I18nBuilder):
""" """
Builds gettext-style message catalogs (.pot files). Builds gettext-style message catalogs (.pot files).
@ -155,7 +173,7 @@ class MessageCatalogBuilder(I18nBuilder):
copyright = self.config.copyright, copyright = self.config.copyright,
project = self.config.project, project = self.config.project,
# XXX should supply tz # XXX should supply tz
ctime = datetime.now().strftime('%Y-%m-%d %H:%M%z'), ctime = datetime.now(utc).strftime('%Y-%m-%d %H:%M%z'),
) )
for textdomain, catalog in self.status_iterator( for textdomain, catalog in self.status_iterator(
self.catalogs.iteritems(), "writing message catalogs... ", self.catalogs.iteritems(), "writing message catalogs... ",