Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions appengine/standard/i18n/i18n_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
The idea of this example, especially for how to translate strings in
Javascript is originally from an implementation of Django i18n.
"""

from __future__ import print_function

import gettext
import json
Expand All @@ -31,6 +31,11 @@

from webob import Request

try:
basestring
except NameError:
basestring = str


def _get_plural_forms(js_translations):
"""Extracts the parameters for what constitutes a plural.
Expand All @@ -49,15 +54,15 @@ def _get_plural_forms(js_translations):
for l in js_translations._catalog[''].split('\n'):
if l.startswith('Plural-Forms:'):
plural = l.split(':', 1)[1].strip()
print "plural is %s" % plural
print('plural is {}'.format(plural))
if plural is not None:
for raw_element in plural.split(';'):
element = raw_element.strip()
if element.startswith('nplurals='):
n_plural = int(element.split('=', 1)[1])
elif element.startswith('plural='):
plural = element.split('=', 1)[1]
print "plural is now %s" % plural
print('plural is now {}'.format(plural))
else:
n_plural = 2
plural = '(n == 1) ? 0 : 1'
Expand All @@ -83,9 +88,9 @@ def convert_translations_to_dict(js_translations):
for key, value in js_translations._catalog.items():
if key == '':
continue
if type(key) in (str, unicode):
if isinstance(key, basestring):
translations_dict['catalog'][key] = value
elif type(key) == tuple:
elif isinstance(key, tuple):
if key[0] not in translations_dict['catalog']:
translations_dict['catalog'][key[0]] = [''] * n_plural
translations_dict['catalog'][key[0]][int(key[1])] = value
Expand Down
3 changes: 2 additions & 1 deletion appengine/standard/mail/header.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
# Copyright 2016 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -40,7 +41,7 @@ def get(self):
</form></body></html>""")

def post(self):
print repr(self.request.POST)
print(repr(self.request.POST))
id = self.request.POST['thread_id']
send_example_mail('{}@appspot.gserviceaccount.com'.format(
app_identity.get_application_id()), id)
Expand Down
3 changes: 2 additions & 1 deletion appengine/standard/ndb/properties/snippets.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
# Copyright 2016 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -147,4 +148,4 @@ class Part(ndb.Model):

def print_part():
p1 = Part(name='foo', color=Color.RED)
print p1.color # prints "RED"
print(p1.color) # prints "RED"
3 changes: 2 additions & 1 deletion appengine/standard/ndb/queries/snippets_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
# Copyright 2016 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -343,7 +344,7 @@ def test_fetch_message_accounts_inefficient(testbed):

assert len(message_account_pairs) == 5

print repr(message_account_pairs)
print(repr(message_account_pairs))
for i in range(1, 6):
message, account = message_account_pairs[i - 1]
assert message.content == 'Message %s' % i
Expand Down