mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Convert print statements to function calls in Tools/.
This commit is contained in:
parent
e5d0e8431f
commit
6afaeb757a
66 changed files with 777 additions and 779 deletions
|
@ -49,7 +49,7 @@ def pprint(data):
|
|||
items = data.items()
|
||||
items.sort()
|
||||
for k,v in items:
|
||||
print ' %-40s%r,' % ('%r:' % k, v)
|
||||
print(' %-40s%r,' % ('%r:' % k, v))
|
||||
|
||||
def print_differences(data, olddata):
|
||||
|
||||
|
@ -57,17 +57,17 @@ def print_differences(data, olddata):
|
|||
items.sort()
|
||||
for k, v in items:
|
||||
if not data.has_key(k):
|
||||
print '# removed %r' % k
|
||||
print('# removed %r' % k)
|
||||
elif olddata[k] != data[k]:
|
||||
print '# updated %r -> %r to %r' % \
|
||||
(k, olddata[k], data[k])
|
||||
print('# updated %r -> %r to %r' % \
|
||||
(k, olddata[k], data[k]))
|
||||
# Additions are not mentioned
|
||||
|
||||
if __name__ == '__main__':
|
||||
data = locale.locale_alias.copy()
|
||||
data.update(parse(LOCALE_ALIAS))
|
||||
print_differences(data, locale.locale_alias)
|
||||
print
|
||||
print 'locale_alias = {'
|
||||
print()
|
||||
print('locale_alias = {')
|
||||
pprint(data)
|
||||
print '}'
|
||||
print('}')
|
||||
|
|
|
@ -38,9 +38,9 @@ MESSAGES = {}
|
|||
|
||||
|
||||
def usage(code, msg=''):
|
||||
print >> sys.stderr, __doc__
|
||||
print(__doc__, file=sys.stderr)
|
||||
if msg:
|
||||
print >> sys.stderr, msg
|
||||
print(msg, file=sys.stderr)
|
||||
sys.exit(code)
|
||||
|
||||
|
||||
|
@ -111,7 +111,7 @@ def make(filename, outfile):
|
|||
try:
|
||||
lines = open(infile).readlines()
|
||||
except IOError as msg:
|
||||
print >> sys.stderr, msg
|
||||
print(msg, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
section = None
|
||||
|
@ -154,9 +154,9 @@ def make(filename, outfile):
|
|||
elif section == STR:
|
||||
msgstr += l
|
||||
else:
|
||||
print >> sys.stderr, 'Syntax error on %s:%d' % (infile, lno), \
|
||||
'before:'
|
||||
print >> sys.stderr, l
|
||||
print('Syntax error on %s:%d' % (infile, lno), \
|
||||
'before:', file=sys.stderr)
|
||||
print(l, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
# Add last entry
|
||||
if section == STR:
|
||||
|
@ -168,7 +168,7 @@ def make(filename, outfile):
|
|||
try:
|
||||
open(outfile,"wb").write(output)
|
||||
except IOError as msg:
|
||||
print >> sys.stderr, msg
|
||||
print(msg, file=sys.stderr)
|
||||
|
||||
|
||||
|
||||
|
@ -185,14 +185,14 @@ def main():
|
|||
if opt in ('-h', '--help'):
|
||||
usage(0)
|
||||
elif opt in ('-V', '--version'):
|
||||
print >> sys.stderr, "msgfmt.py", __version__
|
||||
print("msgfmt.py", __version__, file=sys.stderr)
|
||||
sys.exit(0)
|
||||
elif opt in ('-o', '--output-file'):
|
||||
outfile = arg
|
||||
# do it
|
||||
if not args:
|
||||
print >> sys.stderr, 'No input file given'
|
||||
print >> sys.stderr, "Try `msgfmt --help' for more information."
|
||||
print('No input file given', file=sys.stderr)
|
||||
print("Try `msgfmt --help' for more information.", file=sys.stderr)
|
||||
return
|
||||
|
||||
for filename in args:
|
||||
|
|
|
@ -197,9 +197,9 @@ msgstr ""
|
|||
|
||||
|
||||
def usage(code, msg=''):
|
||||
print >> sys.stderr, __doc__ % globals()
|
||||
print(__doc__ % globals(), file=sys.stderr)
|
||||
if msg:
|
||||
print >> sys.stderr, msg
|
||||
print(msg, file=sys.stderr)
|
||||
sys.exit(code)
|
||||
|
||||
|
||||
|
@ -423,13 +423,13 @@ class TokenEater:
|
|||
elif ttype not in [tokenize.COMMENT, token.INDENT, token.DEDENT,
|
||||
token.NEWLINE, tokenize.NL]:
|
||||
# warn if we see anything else than STRING or whitespace
|
||||
print >> sys.stderr, _(
|
||||
print(_(
|
||||
'*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"'
|
||||
) % {
|
||||
'token': tstring,
|
||||
'file': self.__curfile,
|
||||
'lineno': self.__lineno
|
||||
}
|
||||
}, file=sys.stderr)
|
||||
self.__state = self.__waiting
|
||||
|
||||
def __addentry(self, msg, lineno=None, isdocstring=0):
|
||||
|
@ -448,7 +448,7 @@ class TokenEater:
|
|||
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...
|
||||
print >> fp, pot_header % {'time': timestamp, 'version': __version__}
|
||||
print(pot_header % {'time': timestamp, 'version': __version__}, file=fp)
|
||||
# Sort the entries. First sort each particular entry's keys, then
|
||||
# sort all the entries by their first item.
|
||||
reverse = {}
|
||||
|
@ -477,8 +477,8 @@ class TokenEater:
|
|||
elif options.locationstyle == options.SOLARIS:
|
||||
for filename, lineno in v:
|
||||
d = {'filename': filename, 'lineno': lineno}
|
||||
print >>fp, _(
|
||||
'# File: %(filename)s, line: %(lineno)d') % d
|
||||
print(_(
|
||||
'# File: %(filename)s, line: %(lineno)d') % d, file=fp)
|
||||
elif options.locationstyle == options.GNU:
|
||||
# fit as many locations on one line, as long as the
|
||||
# resulting line length doesn't exceeds 'options.width'
|
||||
|
@ -489,14 +489,14 @@ class TokenEater:
|
|||
if len(locline) + len(s) <= options.width:
|
||||
locline = locline + s
|
||||
else:
|
||||
print >> fp, locline
|
||||
print(locline, file=fp)
|
||||
locline = "#:" + s
|
||||
if len(locline) > 2:
|
||||
print >> fp, locline
|
||||
print(locline, file=fp)
|
||||
if isdocstring:
|
||||
print >> fp, '#, docstring'
|
||||
print >> fp, 'msgid', normalize(k)
|
||||
print >> fp, 'msgstr ""\n'
|
||||
print('#, docstring', file=fp)
|
||||
print('msgid', normalize(k), file=fp)
|
||||
print('msgstr ""\n', file=fp)
|
||||
|
||||
|
||||
|
||||
|
@ -570,7 +570,7 @@ def main():
|
|||
elif opt in ('-v', '--verbose'):
|
||||
options.verbose = 1
|
||||
elif opt in ('-V', '--version'):
|
||||
print _('pygettext.py (xgettext for Python) %s') % __version__
|
||||
print(_('pygettext.py (xgettext for Python) %s') % __version__)
|
||||
sys.exit(0)
|
||||
elif opt in ('-w', '--width'):
|
||||
try:
|
||||
|
@ -603,8 +603,8 @@ def main():
|
|||
options.toexclude = fp.readlines()
|
||||
fp.close()
|
||||
except IOError:
|
||||
print >> sys.stderr, _(
|
||||
"Can't read --exclude-file: %s") % options.excludefilename
|
||||
print(_(
|
||||
"Can't read --exclude-file: %s") % options.excludefilename, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
else:
|
||||
options.toexclude = []
|
||||
|
@ -623,12 +623,12 @@ def main():
|
|||
for filename in args:
|
||||
if filename == '-':
|
||||
if options.verbose:
|
||||
print _('Reading standard input')
|
||||
print(_('Reading standard input'))
|
||||
fp = sys.stdin
|
||||
closep = 0
|
||||
else:
|
||||
if options.verbose:
|
||||
print _('Working on %s') % filename
|
||||
print(_('Working on %s') % filename)
|
||||
fp = open(filename)
|
||||
closep = 1
|
||||
try:
|
||||
|
@ -636,8 +636,8 @@ def main():
|
|||
try:
|
||||
tokenize.tokenize(fp.readline, eater)
|
||||
except tokenize.TokenError as e:
|
||||
print >> sys.stderr, '%s: %s, line %d, column %d' % (
|
||||
e[0], filename, e[1][0], e[1][1])
|
||||
print('%s: %s, line %d, column %d' % (
|
||||
e[0], filename, e[1][0], e[1][1]), file=sys.stderr)
|
||||
finally:
|
||||
if closep:
|
||||
fp.close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue