[FIX] print statement -> function
In Python 3, ``print`` becomes a builtin function. This is available
in Python 2 by importing the ``print_function`` feature from
``__future__``, the feature is conveniently still available in Python
3 (it just does nothing).
Fixers:
libfuturize.fixes.fix_print_with_import
#8530
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from __future__ import print_function
|
||||
import commands
|
||||
import logging
|
||||
import math
|
||||
@@ -131,9 +132,9 @@ class EscposDriver(Thread):
|
||||
self.status['messages'] = []
|
||||
|
||||
if status == 'error' and message:
|
||||
_logger.error('ESC/POS Error: '+message)
|
||||
_logger.error('ESC/POS Error: %s', message)
|
||||
elif status == 'disconnected' and message:
|
||||
_logger.warning('ESC/POS Device Disconnected: '+message)
|
||||
_logger.warning('ESC/POS Device Disconnected: %s', message)
|
||||
|
||||
def run(self):
|
||||
printer = None
|
||||
@@ -170,17 +171,16 @@ class EscposDriver(Thread):
|
||||
error = False
|
||||
|
||||
except NoDeviceError as e:
|
||||
print "No device found %s" %str(e)
|
||||
print("No device found %s" % e)
|
||||
except HandleDeviceError as e:
|
||||
print "Impossible to handle the device due to previous error %s" % str(e)
|
||||
print("Impossible to handle the device due to previous error %s" % e)
|
||||
except TicketNotPrinted as e:
|
||||
print "The ticket does not seems to have been fully printed %s" % str(e)
|
||||
print("The ticket does not seems to have been fully printed %s" % e)
|
||||
except NoStatusError as e:
|
||||
print "Impossible to get the status of the printer %s" % str(e)
|
||||
print("Impossible to get the status of the printer %s" % e)
|
||||
except Exception as e:
|
||||
self.set_status('error', str(e))
|
||||
errmsg = str(e) + '\n' + '-'*60+'\n' + traceback.format_exc() + '-'*60 + '\n'
|
||||
_logger.error(errmsg);
|
||||
self.set_status('error', e)
|
||||
_logger.exception()
|
||||
finally:
|
||||
if error:
|
||||
self.queue.put((timestamp, task, data))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import print_function
|
||||
import base64
|
||||
import copy
|
||||
import io
|
||||
@@ -145,7 +146,7 @@ class StyleStack:
|
||||
_style = {}
|
||||
for attr in style:
|
||||
if attr in self.cmds and not style[attr] in self.cmds[attr]:
|
||||
print 'WARNING: ESC/POS PRINTING: ignoring invalid value: '+utfstr(style[attr])+' for style: '+utfstr(attr)
|
||||
print('WARNING: ESC/POS PRINTING: ignoring invalid value: %s for style %s' % (style[attr], utfstr(attr)))
|
||||
else:
|
||||
_style[attr] = self.enforce_type(attr, style[attr])
|
||||
self.stack.append(_style)
|
||||
@@ -155,7 +156,7 @@ class StyleStack:
|
||||
_style = {}
|
||||
for attr in style:
|
||||
if attr in self.cmds and not style[attr] in self.cmds[attr]:
|
||||
print 'WARNING: ESC/POS PRINTING: ignoring invalid value: '+utfstr(style[attr])+' for style: '+utfstr(attr)
|
||||
print('WARNING: ESC/POS PRINTING: ignoring invalid value: %s for style %s' % (style[attr], attr))
|
||||
else:
|
||||
self.stack[-1][attr] = self.enforce_type(attr, style[attr])
|
||||
|
||||
@@ -383,7 +384,7 @@ class Escpos:
|
||||
|
||||
|
||||
if im.size[0] > 512:
|
||||
print "WARNING: Image is wider than 512 and could be truncated at print time "
|
||||
print("WARNING: Image is wider than 512 and could be truncated at print time ")
|
||||
if im.size[1] > 255:
|
||||
raise ImageSizeError()
|
||||
|
||||
@@ -429,12 +430,12 @@ class Escpos:
|
||||
|
||||
def print_base64_image(self,img):
|
||||
|
||||
print 'print_b64_img'
|
||||
print('print_b64_img')
|
||||
|
||||
id = md5.new(img).digest()
|
||||
|
||||
if id not in self.img_cache:
|
||||
print 'not in cache'
|
||||
print('not in cache')
|
||||
|
||||
img = img[img.find(',')+1:]
|
||||
f = io.BytesIO('img')
|
||||
@@ -449,16 +450,16 @@ class Escpos:
|
||||
else:
|
||||
img.paste(img_rgba)
|
||||
|
||||
print 'convert image'
|
||||
print('convert image')
|
||||
|
||||
pix_line, img_size = self._convert_image(img)
|
||||
|
||||
print 'print image'
|
||||
print('print image')
|
||||
|
||||
buffer = self._raw_print_image(pix_line, img_size)
|
||||
self.img_cache[id] = buffer
|
||||
|
||||
print 'raw image'
|
||||
print('raw image')
|
||||
|
||||
self._raw(self.img_cache[id])
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from __future__ import print_function
|
||||
import serial
|
||||
import socket
|
||||
import usb.core
|
||||
@@ -170,9 +171,9 @@ class Serial(Escpos):
|
||||
self.device = serial.Serial(port=self.devfile, baudrate=self.baudrate, bytesize=self.bytesize, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=self.timeout, dsrdtr=True)
|
||||
|
||||
if self.device is not None:
|
||||
print "Serial printer enabled"
|
||||
print("Serial printer enabled")
|
||||
else:
|
||||
print "Unable to open serial printer on: %s" % self.devfile
|
||||
print("Unable to open serial printer on: %s" % self.devfile)
|
||||
|
||||
|
||||
def _raw(self, msg):
|
||||
@@ -206,7 +207,7 @@ class Network(Escpos):
|
||||
self.device.connect((self.host, self.port))
|
||||
|
||||
if self.device is None:
|
||||
print "Could not open socket for %s" % self.host
|
||||
print("Could not open socket for %s" % self.host)
|
||||
|
||||
|
||||
def _raw(self, msg):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from __future__ import print_function
|
||||
import commands
|
||||
import logging
|
||||
import time
|
||||
@@ -140,78 +141,78 @@ class Proxy(http.Controller):
|
||||
"""
|
||||
A product has been scanned with success
|
||||
"""
|
||||
print 'scan_item_success: ' + str(ean)
|
||||
print('scan_item_success: %s', ean)
|
||||
|
||||
@http.route('/hw_proxy/scan_item_error_unrecognized', type='json', auth='none', cors='*')
|
||||
def scan_item_error_unrecognized(self, ean):
|
||||
"""
|
||||
A product has been scanned without success
|
||||
"""
|
||||
print 'scan_item_error_unrecognized: ' + str(ean)
|
||||
print('scan_item_error_unrecognized: %s', ean)
|
||||
|
||||
@http.route('/hw_proxy/help_needed', type='json', auth='none', cors='*')
|
||||
def help_needed(self):
|
||||
"""
|
||||
The user wants an help (ex: light is on)
|
||||
"""
|
||||
print "help_needed"
|
||||
print("help_needed")
|
||||
|
||||
@http.route('/hw_proxy/help_canceled', type='json', auth='none', cors='*')
|
||||
def help_canceled(self):
|
||||
"""
|
||||
The user stops the help request
|
||||
"""
|
||||
print "help_canceled"
|
||||
print("help_canceled")
|
||||
|
||||
@http.route('/hw_proxy/payment_request', type='json', auth='none', cors='*')
|
||||
def payment_request(self, price):
|
||||
"""
|
||||
The PoS will activate the method payment
|
||||
"""
|
||||
print "payment_request: price:"+str(price)
|
||||
print("payment_request: price:%s" % price)
|
||||
return 'ok'
|
||||
|
||||
@http.route('/hw_proxy/payment_status', type='json', auth='none', cors='*')
|
||||
def payment_status(self):
|
||||
print "payment_status"
|
||||
print("payment_status")
|
||||
return { 'status':'waiting' }
|
||||
|
||||
@http.route('/hw_proxy/payment_cancel', type='json', auth='none', cors='*')
|
||||
def payment_cancel(self):
|
||||
print "payment_cancel"
|
||||
print("payment_cancel")
|
||||
|
||||
@http.route('/hw_proxy/transaction_start', type='json', auth='none', cors='*')
|
||||
def transaction_start(self):
|
||||
print 'transaction_start'
|
||||
print('transaction_start')
|
||||
|
||||
@http.route('/hw_proxy/transaction_end', type='json', auth='none', cors='*')
|
||||
def transaction_end(self):
|
||||
print 'transaction_end'
|
||||
print('transaction_end')
|
||||
|
||||
@http.route('/hw_proxy/cashier_mode_activated', type='json', auth='none', cors='*')
|
||||
def cashier_mode_activated(self):
|
||||
print 'cashier_mode_activated'
|
||||
print('cashier_mode_activated')
|
||||
|
||||
@http.route('/hw_proxy/cashier_mode_deactivated', type='json', auth='none', cors='*')
|
||||
def cashier_mode_deactivated(self):
|
||||
print 'cashier_mode_deactivated'
|
||||
print('cashier_mode_deactivated')
|
||||
|
||||
@http.route('/hw_proxy/open_cashbox', type='json', auth='none', cors='*')
|
||||
def open_cashbox(self):
|
||||
print 'open_cashbox'
|
||||
print('open_cashbox')
|
||||
|
||||
@http.route('/hw_proxy/print_receipt', type='json', auth='none', cors='*')
|
||||
def print_receipt(self, receipt):
|
||||
print 'print_receipt' + str(receipt)
|
||||
print('print_receipt %s', receipt)
|
||||
|
||||
@http.route('/hw_proxy/is_scanner_connected', type='json', auth='none', cors='*')
|
||||
def is_scanner_connected(self, receipt):
|
||||
print 'is_scanner_connected?'
|
||||
print('is_scanner_connected?')
|
||||
return False
|
||||
|
||||
@http.route('/hw_proxy/scanner', type='json', auth='none', cors='*')
|
||||
def scanner(self, receipt):
|
||||
print 'scanner'
|
||||
print('scanner')
|
||||
time.sleep(10)
|
||||
return ''
|
||||
|
||||
@@ -221,4 +222,4 @@ class Proxy(http.Controller):
|
||||
|
||||
@http.route('/hw_proxy/print_pdf_invoice', type='json', auth='none', cors='*')
|
||||
def print_pdf_invoice(self, pdfinvoice):
|
||||
print 'print_pdf_invoice' + str(pdfinvoice)
|
||||
print('print_pdf_invoice %s' % pdfinvoice)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
import ast
|
||||
from urlparse import urlparse
|
||||
from lxml import html
|
||||
@@ -166,7 +167,6 @@ class IrQWeb(models.AbstractModel, QWeb):
|
||||
try:
|
||||
options = "{'widget': 'monetary'"
|
||||
for k, v in json.loads(field_options).iteritems():
|
||||
print k, v
|
||||
if k in ('display_currency', 'from_currency'):
|
||||
options = "%s, '%s': %s" % (options, k, v)
|
||||
else:
|
||||
|
||||
+4
-3
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
import logging
|
||||
import sys
|
||||
import os
|
||||
@@ -26,14 +27,14 @@ class Command(object):
|
||||
class Help(Command):
|
||||
"""Display the list of available commands"""
|
||||
def run(self, args):
|
||||
print "Available commands:\n"
|
||||
print("Available commands:\n")
|
||||
names = commands.keys()
|
||||
padding = max([len(k) for k in names]) + 2
|
||||
for k in sorted(names):
|
||||
name = k.ljust(padding, ' ')
|
||||
doc = (commands[k].__doc__ or '').strip()
|
||||
print " %s%s" % (name, doc)
|
||||
print "\nUse '%s <command> --help' for individual command help." % sys.argv[0].split(os.path.sep)[-1]
|
||||
print(" %s%s" % (name, doc))
|
||||
print("\nUse '%s <command> --help' for individual command help." % sys.argv[0].split(os.path.sep)[-1])
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
import argparse
|
||||
import os
|
||||
import requests
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
@@ -128,9 +129,9 @@ class template(object):
|
||||
.dump(f, encoding='utf-8')
|
||||
|
||||
def die(message, code=1):
|
||||
print >>sys.stderr, message
|
||||
print(message, file=sys.stderr)
|
||||
sys.exit(code)
|
||||
|
||||
def warn(message):
|
||||
# ASK: shall we use logger ?
|
||||
print "WARNING: " + message
|
||||
print("WARNING:", message)
|
||||
|
||||
+4
-3
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from __future__ import print_function
|
||||
import code
|
||||
import logging
|
||||
import os
|
||||
@@ -44,7 +45,7 @@ class Console(code.InteractiveConsole):
|
||||
import readline
|
||||
import rlcompleter
|
||||
except ImportError:
|
||||
print 'readline or rlcompleter not available, autocomplete disabled.'
|
||||
print('readline or rlcompleter not available, autocomplete disabled.')
|
||||
else:
|
||||
readline.set_completer(rlcompleter.Completer(locals).complete)
|
||||
readline.parse_and_bind("tab: complete")
|
||||
@@ -65,9 +66,9 @@ class Shell(Command):
|
||||
exec sys.stdin in local_vars
|
||||
else:
|
||||
if 'env' not in local_vars:
|
||||
print 'No environment set, use `%s shell -d dbname` to get one.' % sys.argv[0]
|
||||
print('No environment set, use `%s shell -d dbname` to get one.' % sys.argv[0])
|
||||
for i in sorted(local_vars):
|
||||
print '%s: %s' % (i, local_vars[i])
|
||||
print('%s: %s' % (i, local_vars[i]))
|
||||
|
||||
preferred_interface = config.options.get('shell_interface')
|
||||
if preferred_interface:
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
import argparse
|
||||
import glob
|
||||
import itertools
|
||||
@@ -77,5 +78,5 @@ class Start(Command):
|
||||
main(cmdargs)
|
||||
|
||||
def die(message, code=1):
|
||||
print >>sys.stderr, message
|
||||
print(message, file=sys.stderr)
|
||||
sys.exit(code)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#-------------------------------------------------------------
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
to_19_fr = ( u'zéro', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six',
|
||||
'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize',
|
||||
'quatorze', 'quinze', 'seize', 'dix-sept', 'dix-huit', 'dix-neuf' )
|
||||
@@ -163,19 +164,7 @@ def amount_to_text(nbr, lang='fr', currency='euro'):
|
||||
|
||||
if lang not in _translate_funcs:
|
||||
#TODO: use logger
|
||||
print "WARNING: no translation function found for lang: '%s'" % (lang,)
|
||||
print("WARNING: no translation function found for lang: '%s'" % (lang,))
|
||||
#TODO: (default should be en) same as above
|
||||
lang = 'fr'
|
||||
return _translate_funcs[lang](abs(nbr), currency)
|
||||
|
||||
if __name__=='__main__':
|
||||
from sys import argv
|
||||
|
||||
lang = 'nl'
|
||||
if len(argv) < 2:
|
||||
for i in range(1,200):
|
||||
print i, ">>", amount_to_text(i, lang)
|
||||
for i in range(200,999999,139):
|
||||
print i, ">>", amount_to_text(i, lang)
|
||||
else:
|
||||
print amount_to_text(int(argv[1]), lang)
|
||||
|
||||
@@ -99,15 +99,3 @@ def amount_to_text(nbr, lang='en', currency='euro'):
|
||||
#TODO: (default should be en) same as above
|
||||
lang = 'en'
|
||||
return _translate_funcs[lang](abs(nbr), currency)
|
||||
|
||||
if __name__=='__main__':
|
||||
from sys import argv
|
||||
|
||||
lang = 'nl'
|
||||
if len(argv) < 2:
|
||||
for i in range(1,200):
|
||||
print i, ">>", int_to_text(i, lang)
|
||||
for i in range(200,999999,139):
|
||||
print i, ">>", int_to_text(i, lang)
|
||||
else:
|
||||
print int_to_text(int(argv[1]), lang)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
See <http://github.com/ActiveState/appdirs> for details and usage.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
# Dev Notes:
|
||||
# - MSDN on where to store app data files:
|
||||
# http://support.microsoft.com/default.aspx?scid=kb;en-us;310294#XSLTH3194121123120121120120
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from __future__ import print_function
|
||||
import math
|
||||
|
||||
def _float_check_precision(precision_digits=None, precision_rounding=None):
|
||||
@@ -207,7 +208,7 @@ if __name__ == "__main__":
|
||||
precision_digits=precision_digits)
|
||||
if result != expected:
|
||||
errors += 1
|
||||
print '###!!! Rounding error: got %s , expected %s' % (result, expected)
|
||||
print('###!!! Rounding error: got %s , expected %s' % (result, expected))
|
||||
|
||||
# Extended float range test, inspired by Cloves Almeida's test on bug #882036.
|
||||
fractions = [.0, .015, .01499, .675, .67499, .4555, .4555, .45555]
|
||||
@@ -229,4 +230,4 @@ if __name__ == "__main__":
|
||||
# 47130 round calls in 0.422306060791 secs, with Python 2.6.7 on Core i3 x64
|
||||
# with decimal:
|
||||
# 47130 round calls in 6.612248100021 secs, with Python 2.6.7 on Core i3 x64
|
||||
print count, " round calls, ", errors, "errors, done in ", (stop-start), 'secs'
|
||||
print(count, " round calls, ", errors, "errors, done in ", (stop-start), 'secs')
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
## this functions are taken from the setuptools package (version 0.6c8)
|
||||
## http://peak.telecommunity.com/DevCenter/PkgResources#parsing-utilities
|
||||
|
||||
from __future__ import print_function
|
||||
import re
|
||||
|
||||
component_re = re.compile(r'(\d+ | [a-z]+ | \.| -)', re.VERBOSE)
|
||||
@@ -69,7 +70,7 @@ if __name__ == '__main__':
|
||||
pv = parse_version(v)
|
||||
pvs.append(pv)
|
||||
if verbose:
|
||||
print v, pv
|
||||
print(v, pv)
|
||||
|
||||
for a, b in zip(pvs, pvs[1:]):
|
||||
assert a < b, '%s < %s == %s' % (a, b, a < b)
|
||||
|
||||
Reference in New Issue
Block a user