From 34f71a80358c4457ff338d2527e2503711f04ff2 Mon Sep 17 00:00:00 2001 From: abhishekkekane Date: Sun, 31 Jan 2016 01:11:46 -0800 Subject: [PATCH] Python3: Add support for iter.next Replaced iter.next() with next(iter) This patch is generated by the following tool using 'next' option. https://github.com/haypo/sixer Command: python sixer.py -w 'next' trove/ Partially implements: blueprint trove-python3 Change-Id: Ifbe25ddaa20f60b8af245f4745a9851c9b262bf3 --- .../datastore/experimental/db2/service.py | 18 +++++++++--------- .../postgresql/service/database.py | 6 +++--- .../experimental/postgresql/service/users.py | 6 +++--- .../strategies/replication/mysql_binlog.py | 4 ++-- .../tests/unittests/taskmanager/test_models.py | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/trove/guestagent/datastore/experimental/db2/service.py b/trove/guestagent/datastore/experimental/db2/service.py index 933f5fa630..53276262ca 100644 --- a/trove/guestagent/datastore/experimental/db2/service.py +++ b/trove/guestagent/datastore/experimental/db2/service.py @@ -206,9 +206,9 @@ class DB2Admin(object): if marker is not None: try: - item = result.next() + item = next(result) while item != marker: - item = result.next() + item = next(result) if item == marker: marker = None @@ -216,7 +216,7 @@ class DB2Admin(object): pass try: - item = result.next() + item = next(result) while item: count = count + 1 if (limit and count <= limit) or limit is None: @@ -227,7 +227,7 @@ class DB2Admin(object): db2_db.collate = None next_marker = db2_db.name databases.append(db2_db.serialize()) - item = result.next() + item = next(result) else: next_marker = None break @@ -347,9 +347,9 @@ class DB2Admin(object): if marker is not None: try: - item = result.next() + item = next(result) while item != marker: - item = result.next() + item = next(result) if item == marker: marker = None @@ -357,7 +357,7 @@ class DB2Admin(object): pass try: - item = result.next() + item = next(result) db2db = models.MySQLDatabase() db2db.name = db2_db.name @@ -369,7 +369,7 @@ class DB2Admin(object): if item in user_map: db2user = user_map.get(item) db2user.databases.append(db2db.serialize()) - item = result.next() + item = next(result) continue ''' If this user was not previously discovered, then add @@ -382,7 +382,7 @@ class DB2Admin(object): db2_user.databases.append(db2db.serialize()) users.append(db2_user.serialize()) user_map.update({item: db2_user}) - item = result.next() + item = next(result) else: next_marker = None break diff --git a/trove/guestagent/datastore/experimental/postgresql/service/database.py b/trove/guestagent/datastore/experimental/postgresql/service/database.py index b6919a293c..339bccc598 100644 --- a/trove/guestagent/datastore/experimental/postgresql/service/database.py +++ b/trove/guestagent/datastore/experimental/postgresql/service/database.py @@ -103,9 +103,9 @@ class PgSqlDatabase(object): # Force __iter__ of generator until marker found. if marker is not None: try: - item = results.next() + item = next(results) while item['_name'] != marker: - item = results.next() + item = next(results) except StopIteration: pass @@ -119,7 +119,7 @@ class PgSqlDatabase(object): next_marker = None if remainder is not None: try: - next_marker = remainder.next() + next_marker = next(remainder) except StopIteration: pass diff --git a/trove/guestagent/datastore/experimental/postgresql/service/users.py b/trove/guestagent/datastore/experimental/postgresql/service/users.py index 4829111787..521aa3a58d 100644 --- a/trove/guestagent/datastore/experimental/postgresql/service/users.py +++ b/trove/guestagent/datastore/experimental/postgresql/service/users.py @@ -131,9 +131,9 @@ class PgSqlUsers(PgSqlAccess): # Force __iter__ of generator until marker found. if marker is not None: try: - item = results.next() + item = next(results) while item['_name'] != marker: - item = results.next() + item = next(results) except StopIteration: pass @@ -147,7 +147,7 @@ class PgSqlUsers(PgSqlAccess): next_marker = None if remainder is not None: try: - next_marker = remainder.next() + next_marker = next(remainder) except StopIteration: pass diff --git a/trove/guestagent/strategies/replication/mysql_binlog.py b/trove/guestagent/strategies/replication/mysql_binlog.py index 47f54115d1..409a08cb3b 100644 --- a/trove/guestagent/strategies/replication/mysql_binlog.py +++ b/trove/guestagent/strategies/replication/mysql_binlog.py @@ -69,8 +69,8 @@ class MysqlBinlogReplication(mysql_base.MysqlReplicationBase): LOG.info(_("Reading log position from %s") % INFO_FILE) try: with open(INFO_FILE, 'rb') as f: - row = csv.reader(f, delimiter='\t', - skipinitialspace=True).next() + row = next(csv.reader(f, delimiter='\t', + skipinitialspace=True)) return { 'log_file': row[0], 'log_position': int(row[1]) diff --git a/trove/tests/unittests/taskmanager/test_models.py b/trove/tests/unittests/taskmanager/test_models.py index 7ce443a54d..a0e6cd7565 100644 --- a/trove/tests/unittests/taskmanager/test_models.py +++ b/trove/tests/unittests/taskmanager/test_models.py @@ -678,7 +678,7 @@ class BuiltInstanceTasksTest(trove_testtools.TestCase): def side_effect_func(*args, **kwargs): if 'instance_id' in kwargs: - return answers.next() + return next(answers) elif ('id' in kwargs and 'deleted' in kwargs and not kwargs['deleted']): return db_instance