Skip to content

Commit

Permalink
Remove itervalues compatibility fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovsky committed Jan 23, 2022
1 parent 608491e commit 81153ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
6 changes: 3 additions & 3 deletions pony/orm/core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import absolute_import, print_function, division
from pony.py23compat import itervalues, items_list, values_list, cmp, \
from pony.py23compat import items_list, values_list, cmp, \
basestring, unicode, buffer, int_types, builtins, with_metaclass

import json, re, sys, types, datetime, logging, itertools, warnings, inspect, ast
Expand Down Expand Up @@ -2930,7 +2930,7 @@ def load(attr, obj, items=None):
if prefetching:
pk_index = cache.indexes[entity._pk_attrs_]
max_batch_size = database.provider.max_params_count // len(entity._pk_columns_)
for obj2 in itervalues(pk_index):
for obj2 in pk_index.values():
if obj2 is obj: continue
if obj2._status_ in created_or_deleted_statuses: continue
setdata2 = obj2._vals_.get(attr)
Expand Down Expand Up @@ -3621,7 +3621,7 @@ def distinct(multiset):
def __repr__(multiset):
cache = multiset._obj_._session_cache_
if cache is not None and cache.is_alive:
size = builtins.sum(itervalues(multiset._items_))
size = builtins.sum(multiset._items_.values())
if size == 1: size_str = ' (1 item)'
else: size_str = ' (%d items)' % size
else: size_str = ''
Expand Down
16 changes: 8 additions & 8 deletions pony/orm/dbschema.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import absolute_import, print_function, division
from pony.py23compat import itervalues, basestring, int_types
from pony.py23compat import basestring, int_types

from operator import attrgetter

Expand Down Expand Up @@ -32,7 +32,7 @@ def order_tables_to_create(schema):
tables = []
created_tables = set()
split = schema.provider.split_table_name
tables_to_create = sorted(itervalues(schema.tables), key=lambda table: split(table.name))
tables_to_create = sorted(schema.tables.values(), key=lambda table: split(table.name))
while tables_to_create:
for table in tables_to_create:
if table.parent_tables.issubset(created_tables):
Expand Down Expand Up @@ -66,7 +66,7 @@ def create_tables(schema, provider, connection):
def check_tables(schema, provider, connection):
cursor = connection.cursor()
split = provider.split_table_name
for table in sorted(itervalues(schema.tables), key=lambda table: split(table.name)):
for table in sorted(schema.tables.values(), key=lambda table: split(table.name)):
alias = provider.base_name(table.name)
sql_ast = [ 'SELECT',
[ 'ALL', ] + [ [ 'COLUMN', alias, column.name ] for column in table.column_list ],
Expand Down Expand Up @@ -133,13 +133,13 @@ def get_create_command(table):
cmd.append(schema.indent + column.get_sql() + ',')
if len(table.pk_index.columns) > 1:
cmd.append(schema.indent + table.pk_index.get_sql() + ',')
indexes = [ index for index in itervalues(table.indexes)
indexes = [ index for index in table.indexes.values()
if not index.is_pk and index.is_unique and len(index.columns) > 1 ]
for index in indexes: assert index.name is not None
indexes.sort(key=attrgetter('name'))
for index in indexes: cmd.append(schema.indent+index.get_sql() + ',')
if not schema.named_foreign_keys:
for foreign_key in sorted(itervalues(table.foreign_keys), key=lambda fk: fk.name):
for foreign_key in sorted(table.foreign_keys.values(), key=lambda fk: fk.name):
if schema.inline_fk_syntax and len(foreign_key.child_columns) == 1: continue
cmd.append(schema.indent+foreign_key.get_sql() + ',')
interleave_fks = [ fk for fk in table.foreign_keys.values() if fk.interleave ]
Expand Down Expand Up @@ -168,18 +168,18 @@ def get_objects_to_create(table, created_tables=None):
if created_tables is None: created_tables = set()
created_tables.add(table)
result = [ table ]
indexes = [ index for index in itervalues(table.indexes) if not index.is_pk and not index.is_unique ]
indexes = [ index for index in table.indexes.values() if not index.is_pk and not index.is_unique ]
for index in indexes: assert index.name is not None
indexes.sort(key=attrgetter('name'))
result.extend(indexes)
schema = table.schema
if schema.named_foreign_keys:
for foreign_key in sorted(itervalues(table.foreign_keys), key=lambda fk: fk.name):
for foreign_key in sorted(table.foreign_keys.values(), key=lambda fk: fk.name):
if foreign_key.parent_table not in created_tables: continue
result.append(foreign_key)
for child_table in table.child_tables:
if child_table not in created_tables: continue
for foreign_key in sorted(itervalues(child_table.foreign_keys), key=lambda fk: fk.name):
for foreign_key in sorted(child_table.foreign_keys.values(), key=lambda fk: fk.name):
if foreign_key.parent_table is not table: continue
result.append(foreign_key)
return result
Expand Down
3 changes: 0 additions & 3 deletions pony/py23compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
def cmp(a, b):
return (a > b) - (a < b)

def itervalues(dict):
return iter(dict.values())

def items_list(dict):
return list(dict.items())

Expand Down

0 comments on commit 81153ff

Please sign in to comment.