Use the print function everywhere
python modernize.py --no-six -f libmodernize.fixes.fix_print -w With manual fixes as the import was put always on top.
This commit is contained in:
parent
d22656308a
commit
74a4ef6723
73 changed files with 499 additions and 442 deletions
|
|
@ -18,6 +18,8 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import datetime
|
||||
|
|
@ -50,11 +52,11 @@ def write(target, contents):
|
|||
if not os.path.isdir(os.path.dirname(target)):
|
||||
os.makedirs(os.path.dirname(target))
|
||||
if os.path.exists(target):
|
||||
print >>sys.stderr, "%s already exists." % target
|
||||
print("%s already exists." % target, file=sys.stderr)
|
||||
sys.exit(4)
|
||||
with codecs.open(target, mode='w', encoding='utf-8') as f:
|
||||
f.write(contents)
|
||||
print 'Created %s' % target
|
||||
print('Created %s' % target)
|
||||
|
||||
|
||||
class Recipe(object):
|
||||
|
|
@ -156,7 +158,7 @@ class CapRecipe(Recipe):
|
|||
self.error('Capability %r not found' % self.capname)
|
||||
|
||||
def error(self, message):
|
||||
print >>sys.stderr, message
|
||||
print(message, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
def methods_code(self, klass):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
from weboob.tools.browser import StandardBrowser
|
||||
|
||||
print StandardBrowser()._certhash(sys.argv[1])
|
||||
print(StandardBrowser()._certhash(sys.argv[1]))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
|
@ -15,7 +16,7 @@ for root, dirs, files in os.walk(sys.argv[1]):
|
|||
try:
|
||||
exec(s)
|
||||
except ImportError as e:
|
||||
print >>sys.stderr, str(e)
|
||||
print(str(e), file=sys.stderr)
|
||||
else:
|
||||
m = eval(f[:-3])
|
||||
for attrname in dir(m):
|
||||
|
|
@ -36,7 +37,7 @@ for f in selection:
|
|||
for line in p.stdout.readlines():
|
||||
dependencies.add(line.strip().split(':')[0])
|
||||
else:
|
||||
print 'not found: %s' % f
|
||||
print('not found: %s' % f)
|
||||
|
||||
for d in dependencies:
|
||||
print d
|
||||
print(d)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
|
@ -10,26 +12,26 @@ if '--deps' in sys.argv:
|
|||
else:
|
||||
deps = ['--nodeps']
|
||||
|
||||
print "Weboob local installer"
|
||||
print
|
||||
print("Weboob local installer")
|
||||
print()
|
||||
if len(sys.argv) < 2:
|
||||
print "This tool will install Weboob to be usuable without requiring"
|
||||
print "messing with your system, which should only be touched by a package manager."
|
||||
print
|
||||
print "Usage: %s DESTINATION [OPTIONS]" % sys.argv[0]
|
||||
print
|
||||
print "By default, no dependencies are installed, as you should try"
|
||||
print "to install them from your package manager as much as possible."
|
||||
print "To install all the missing dependencies, add the option --deps"
|
||||
print "at the end of the command line."
|
||||
print
|
||||
print >>sys.stderr, "Error: Please provide a destination, " \
|
||||
"for example ‘%s/bin’" % os.getenv('HOME')
|
||||
print("This tool will install Weboob to be usuable without requiring")
|
||||
print("messing with your system, which should only be touched by a package manager.")
|
||||
print()
|
||||
print("Usage: %s DESTINATION [OPTIONS]" % sys.argv[0])
|
||||
print()
|
||||
print("By default, no dependencies are installed, as you should try")
|
||||
print("to install them from your package manager as much as possible.")
|
||||
print("To install all the missing dependencies, add the option --deps")
|
||||
print("at the end of the command line.")
|
||||
print()
|
||||
print("Error: Please provide a destination, " \
|
||||
"for example ‘%s/bin’" % os.getenv('HOME'), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
else:
|
||||
dest = os.path.expanduser(sys.argv[1])
|
||||
|
||||
print "Installing weboob applications into ‘%s’." % dest
|
||||
print("Installing weboob applications into ‘%s’." % dest)
|
||||
|
||||
subprocess.check_call(
|
||||
[sys.executable, 'setup.py',
|
||||
|
|
@ -38,11 +40,11 @@ subprocess.check_call(
|
|||
|
||||
subprocess.check_call([sys.executable, os.path.join(dest, 'weboob-config'), 'update'])
|
||||
|
||||
print
|
||||
print "Installation done. Applications are available in ‘%s’." % dest
|
||||
print "You can remove the source files."
|
||||
print
|
||||
print "To have easy access to the Weboob applications,"
|
||||
print "you should add the following line to your ~/.bashrc or ~/.zshrc file:"
|
||||
print "export PATH=\"$PATH:%s\"" % dest
|
||||
print "And then restart your shells."
|
||||
print()
|
||||
print("Installation done. Applications are available in ‘%s’." % dest)
|
||||
print("You can remove the source files.")
|
||||
print()
|
||||
print("To have easy access to the Weboob applications,")
|
||||
print("you should add the following line to your ~/.bashrc or ~/.zshrc file:")
|
||||
print("export PATH=\"$PATH:%s\"" % dest)
|
||||
print("And then restart your shells.")
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print "Usage: %s SCRIPTNAME [args]" % sys.argv[0]
|
||||
print("Usage: %s SCRIPTNAME [args]" % sys.argv[0])
|
||||
sys.exit(1)
|
||||
else:
|
||||
script = sys.argv[1]
|
||||
|
|
@ -37,7 +39,7 @@ p = subprocess.Popen(
|
|||
stdout=subprocess.PIPE)
|
||||
s = p.communicate()
|
||||
if p.returncode != 0:
|
||||
print s[0]
|
||||
print(s[0])
|
||||
sys.exit(p.returncode)
|
||||
|
||||
if os.path.exists(script):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
|
||||
# Copyright(C) 2010-2011 Laurent Bachelier
|
||||
#
|
||||
|
|
@ -120,10 +121,10 @@ def main():
|
|||
try:
|
||||
script = imp.load_module("scripts.%s" % fname, f, tmpfile, desc)
|
||||
except ImportError as e:
|
||||
print >>sys.stderr, "Unable to load the %s script (%s)" \
|
||||
% (fname, e)
|
||||
print("Unable to load the %s script (%s)" \
|
||||
% (fname, e), file=sys.stderr)
|
||||
else:
|
||||
print "Loaded %s" % fname
|
||||
print("Loaded %s" % fname)
|
||||
# Find the applications we can handle
|
||||
for klass in script.__dict__.itervalues():
|
||||
if inspect.isclass(klass) and issubclass(klass, Application):
|
||||
|
|
@ -227,7 +228,7 @@ For full COPYRIGHT see COPYING file with weboob package.
|
|||
with open(os.path.join(BASE_PATH, DEST_DIR, "%s.1" % script_name), 'w+') as manfile:
|
||||
for line in mantext.split('\n'):
|
||||
manfile.write('%s\n' % line.lstrip().encode('utf-8'))
|
||||
print "wrote %s/%s.1" % (DEST_DIR, script_name)
|
||||
print("wrote %s/%s.1" % (DEST_DIR, script_name))
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
|
@ -17,4 +19,4 @@ for dirpath, dirnames, filenames in os.walk(root):
|
|||
if not os.path.exists(os.path.join(dirpath, filename[:-1])):
|
||||
os.unlink(os.path.join(dirpath, filename))
|
||||
if verbose:
|
||||
print os.path.join(dirpath, filename)
|
||||
print(os.path.join(dirpath, filename))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
# Hint: use this script with file:///path/to/local/modules/ in sources.list
|
||||
# if you want to correctly check all modules.
|
||||
|
|
@ -22,6 +23,6 @@ for name, backend in weboob.modules_loader.loaded.iteritems():
|
|||
backends_without_icons.append(name)
|
||||
|
||||
if backends_without_tests:
|
||||
print 'Modules without tests: %s' % backends_without_tests
|
||||
print('Modules without tests: %s' % backends_without_tests)
|
||||
if backends_without_icons:
|
||||
print 'Modules without icons: %s' % backends_without_icons
|
||||
print('Modules without icons: %s' % backends_without_icons)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue