Commit 1e06b5c2 authored by Vincent A's avatar Vincent A

futurize phase 1

With: futurize -w -1 weboob
parent 0b7dadeb
......@@ -21,6 +21,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import absolute_import
from __future__ import print_function
import re
import os
......
......@@ -376,7 +376,7 @@ class AccountListFormatter(IFormatter):
def flush(self):
self.output(u'------------------------------------------%s+----------+----------' % (('-' * 15) if not self.interactive else ''))
for currency, currency_totals in sorted(self.totals.iteritems(), key=lambda (k,v): (v,k)):
for currency, currency_totals in sorted(self.totals.iteritems(), key=lambda k_v: (k_v[1],k_v[0])):
balance = currency_totals['balance']
coming = currency_totals['coming']
......
......@@ -72,7 +72,7 @@ class SearchWidget(QWidget):
self.contacts.insert(0, contact)
self.ui.queueLabel.setText('%d' % len(self.contacts))
if self.current is None:
self.next()
next(self)
@Slot()
def next(self):
......
......@@ -292,7 +292,7 @@ class Radioob(ReplApplication):
stream = self.get_object(stream.id, 'get_audio')
else:
r = requests.get(stream.url, stream=True)
buf = r.iter_content(512).next()
buf = next(r.iter_content(512))
r.close()
playlistFormat = None
for line in buf.split("\n"):
......
......@@ -25,6 +25,7 @@ import re
import pickle
import base64
import zlib
from functools import reduce
try:
from requests.packages import urllib3
except ImportError:
......
......@@ -17,6 +17,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 os
import re
import sys
......
......@@ -25,6 +25,7 @@ import warnings
from io import BytesIO
import codecs
from cgi import parse_header
from functools import reduce
try:
import urlparse
except ImportError:
......
......@@ -38,7 +38,7 @@ def enum(**enums):
_keys = enums.keys()
_items = enums.items()
_types = list((type(value) for value in enums.values()))
_index = dict((value if not isinstance(value, dict) else value.itervalues().next(), i) for i, value in enumerate(enums.values()))
_index = dict((value if not isinstance(value, dict) else next(value.itervalues()), i) for i, value in enumerate(enums.values()))
enums['keys'] = _keys
enums['values'] = _values
......
......@@ -140,7 +140,7 @@ class CapCollection(Capability):
return
try:
i = self.iter_resources(objs, collection.split_path)
i.next()
next(i)
except StopIteration:
raise CollectionNotFound(collection.split_path)
......
......@@ -24,6 +24,6 @@ class GenericComicReaderTest(BackendTest):
def _test_download(self, _id):
g = self.backend.get_gallery(_id)
it = self.backend.iter_gallery_images(g)
it.next()
img = it.next()
next(it)
img = next(it)
self.backend.fillobj(img, ('url', 'data'))
......@@ -118,7 +118,7 @@ def limit(iterator, lim):
count = 0
iterator = iter(iterator)
while count < lim:
yield iterator.next()
yield next(iterator)
count += 1
......
......@@ -107,7 +107,7 @@ def normalize(pattern):
# at the next character and possibly go around without consuming another
# one at the top of the loop.
try:
ch, escaped = pattern_iter.next()
ch, escaped = next(pattern_iter)
except StopIteration:
return zip([u''], [[]])
......@@ -137,14 +137,14 @@ def normalize(pattern):
result = result[:start] + [inner]
elif ch == '[':
# Replace ranges with the first character in the range.
ch, escaped = pattern_iter.next()
ch, escaped = next(pattern_iter)
result.append(ch)
ch, escaped = pattern_iter.next()
ch, escaped = next(pattern_iter)
while escaped or ch != ']':
ch, escaped = pattern_iter.next()
ch, escaped = next(pattern_iter)
elif ch == '(':
# Some kind of group.
ch, escaped = pattern_iter.next()
ch, escaped = next(pattern_iter)
if ch != '?' or escaped:
# A positional group
name = "_%d" % num_args
......@@ -152,7 +152,7 @@ def normalize(pattern):
result.append(Group(((u"%%(%s)s" % name), name)))
walk_to_end(ch, pattern_iter)
else:
ch, escaped = pattern_iter.next()
ch, escaped = next(pattern_iter)
if ch in "iLmsu#":
# All of these are ignorable. Walk to the end of the
# group.
......@@ -165,7 +165,7 @@ def normalize(pattern):
# we cannot reverse.
raise ValueError("Non-reversible reg-exp portion: '(?%s'" % ch)
else:
ch, escaped = pattern_iter.next()
ch, escaped = next(pattern_iter)
if ch not in ('<', '='):
raise ValueError("Non-reversible reg-exp portion: '(?P%s'" % ch)
# We are in a named capturing group. Extra the name and
......@@ -176,10 +176,10 @@ def normalize(pattern):
else:
terminal_char = ')'
name = []
ch, escaped = pattern_iter.next()
ch, escaped = next(pattern_iter)
while ch != terminal_char:
name.append(ch)
ch, escaped = pattern_iter.next()
ch, escaped = next(pattern_iter)
param = ''.join(name)
# Named backreferences have already consumed the
# parenthesis.
......@@ -215,7 +215,7 @@ def normalize(pattern):
result.append(ch)
if consume_next:
ch, escaped = pattern_iter.next()
ch, escaped = next(pattern_iter)
else:
consume_next = True
except StopIteration:
......@@ -241,7 +241,7 @@ def next_char(input_iter):
if ch != '\\':
yield ch, False
continue
ch = input_iter.next()
ch = next(input_iter)
representative = ESCAPE_MAPPINGS.get(ch, ch)
if representative is None:
continue
......@@ -280,7 +280,7 @@ def get_quantifier(ch, input_iter):
"""
if ch in '*?+':
try:
ch2, escaped = input_iter.next()
ch2, escaped = next(input_iter)
except StopIteration:
ch2 = None
if ch2 == '?':
......@@ -291,14 +291,14 @@ def get_quantifier(ch, input_iter):
quant = []
while ch != '}':
ch, escaped = input_iter.next()
ch, escaped = next(input_iter)
quant.append(ch)
quant = quant[:-1]
values = ''.join(quant).split(',')
# Consume the trailing '?', if necessary.
try:
ch, escaped = input_iter.next()
ch, escaped = next(input_iter)
except StopIteration:
ch = None
if ch == '?':
......
......@@ -17,6 +17,7 @@
# 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 sys
from functools import wraps
from unittest import TestCase
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment