Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
2b78129b
Kaydet (Commit)
2b78129b
authored
Nis 16, 2015
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#18128: use standard +NNNN timezone format in POT-Creation-Date header.
Patch by Michael McFadden, with a few small style tweaks.
üst
29fbd21d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
3 deletions
+77
-3
3.5.rst
Doc/whatsnew/3.5.rst
+4
-0
test_i18n.py
Lib/test/test_tools/test_i18n.py
+68
-0
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
pygettext.py
Tools/i18n/pygettext.py
+1
-3
No files found.
Doc/whatsnew/3.5.rst
Dosyayı görüntüle @
2b78129b
...
@@ -814,6 +814,10 @@ Changes in the Python API
...
@@ -814,6 +814,10 @@ Changes in the Python API
* The :mod:`socket` module now exports the CAN_RAW_FD_FRAMES constant on linux
* The :mod:`socket` module now exports the CAN_RAW_FD_FRAMES constant on linux
3.6 and greater.
3.6 and greater.
* The `pygettext.py` Tool now uses the standard +NNNN format for timezones in
the POT-Creation-Date header.
Changes in the C API
Changes in the C API
--------------------
--------------------
...
...
Lib/test/test_tools/test_i18n.py
0 → 100644
Dosyayı görüntüle @
2b78129b
"""Tests to cover the Tools/i18n package"""
import
os
import
unittest
from
test.script_helper
import
assert_python_ok
from
test.test_tools
import
toolsdir
from
test.support
import
temp_cwd
class
Test_pygettext
(
unittest
.
TestCase
):
"""Tests for the pygettext.py tool"""
script
=
os
.
path
.
join
(
toolsdir
,
'i18n'
,
'pygettext.py'
)
def
get_header
(
self
,
data
):
""" utility: return the header of a .po file as a dictionary """
headers
=
{}
for
line
in
data
.
split
(
'
\n
'
):
if
not
line
or
line
.
startswith
((
'#'
,
'msgid'
,
'msgstr'
)):
continue
line
=
line
.
strip
(
'"'
)
key
,
val
=
line
.
split
(
':'
,
1
)
headers
[
key
]
=
val
.
strip
()
return
headers
def
test_header
(
self
):
"""Make sure the required fields are in the header, according to:
http://www.gnu.org/software/gettext/manual/gettext.html#Header-Entry
"""
with
temp_cwd
(
None
)
as
cwd
:
assert_python_ok
(
self
.
script
)
with
open
(
'messages.pot'
)
as
fp
:
data
=
fp
.
read
()
header
=
self
.
get_header
(
data
)
self
.
assertIn
(
"Project-Id-Version"
,
header
)
self
.
assertIn
(
"POT-Creation-Date"
,
header
)
self
.
assertIn
(
"PO-Revision-Date"
,
header
)
self
.
assertIn
(
"Last-Translator"
,
header
)
self
.
assertIn
(
"Language-Team"
,
header
)
self
.
assertIn
(
"MIME-Version"
,
header
)
self
.
assertIn
(
"Content-Type"
,
header
)
self
.
assertIn
(
"Content-Transfer-Encoding"
,
header
)
self
.
assertIn
(
"Generated-By"
,
header
)
# not clear if these should be required in POT (template) files
#self.assertIn("Report-Msgid-Bugs-To", header)
#self.assertIn("Language", header)
#"Plural-Forms" is optional
def
test_POT_Creation_Date
(
self
):
""" Match the date format from xgettext for POT-Creation-Date """
from
datetime
import
datetime
with
temp_cwd
(
None
)
as
cwd
:
assert_python_ok
(
self
.
script
)
with
open
(
'messages.pot'
)
as
fp
:
data
=
fp
.
read
()
header
=
self
.
get_header
(
data
)
creationDate
=
header
[
'POT-Creation-Date'
]
# peel off the escaped newline at the end of string
if
creationDate
.
endswith
(
'
\\
n'
):
creationDate
=
creationDate
[:
-
len
(
'
\\
n'
)]
# This will raise if the date format does not exactly match.
datetime
.
strptime
(
creationDate
,
'
%
Y-
%
m-
%
d
%
H:
%
M
%
z'
)
Misc/ACKS
Dosyayı görüntüle @
2b78129b
...
@@ -911,6 +911,7 @@ Jack McCracken
...
@@ -911,6 +911,7 @@ Jack McCracken
Rebecca McCreary
Rebecca McCreary
Kirk McDonald
Kirk McDonald
Chris McDonough
Chris McDonough
Michael McFadden
Greg McFarlane
Greg McFarlane
Alan McIntyre
Alan McIntyre
Jessica McKellar
Jessica McKellar
...
...
Misc/NEWS
Dosyayı görüntüle @
2b78129b
...
@@ -187,6 +187,9 @@ Tests
...
@@ -187,6 +187,9 @@ Tests
Tools
/
Demos
Tools
/
Demos
-----------
-----------
-
Issue
#
18128
:
pygettext
now
uses
standard
+
NNNN
format
in
the
POT
-
Creation
-
Date
header
.
-
Issue
#
23935
:
Argument
Clinic
's understanding of format units
-
Issue
#
23935
:
Argument
Clinic
's understanding of format units
accepting bytes, bytearrays, and buffers is now consistent with
accepting bytes, bytearrays, and buffers is now consistent with
both the documentation and the implementation.
both the documentation and the implementation.
...
...
Tools/i18n/pygettext.py
Dosyayı görüntüle @
2b78129b
...
@@ -441,9 +441,7 @@ class TokenEater:
...
@@ -441,9 +441,7 @@ class TokenEater:
def
write
(
self
,
fp
):
def
write
(
self
,
fp
):
options
=
self
.
__options
options
=
self
.
__options
timestamp
=
time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M+
%
Z'
)
timestamp
=
time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M
%
z'
)
# The time stamp in the header doesn't have the same format as that
# generated by xgettext...
encoding
=
fp
.
encoding
if
fp
.
encoding
else
'UTF-8'
encoding
=
fp
.
encoding
if
fp
.
encoding
else
'UTF-8'
print
(
pot_header
%
{
'time'
:
timestamp
,
'version'
:
__version__
,
print
(
pot_header
%
{
'time'
:
timestamp
,
'version'
:
__version__
,
'charset'
:
encoding
,
'charset'
:
encoding
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment