diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-27 19:53:57 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-27 19:53:57 -0400 |
| commit | 4b614b9b35cd2baddb7ca67c04bee5d70ec6a172 (patch) | |
| tree | 7483cd269f5823f903f96709eb864fff9b6d9383 /lib/sqlalchemy/ext | |
| parent | 9716a5c45e6185c5871555722d8495880f0e8c7a (diff) | |
| download | sqlalchemy-4b614b9b35cd2baddb7ca67c04bee5d70ec6a172.tar.gz | |
- the raw 2to3 run
- went through examples/ and cleaned out excess list() calls
Diffstat (limited to 'lib/sqlalchemy/ext')
| -rw-r--r-- | lib/sqlalchemy/ext/associationproxy.py | 32 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/declarative/api.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/declarative/base.py | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/declarative/clsregistry.py | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/mutable.py | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/orderinglist.py | 24 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/serializer.py | 26 |
7 files changed, 52 insertions, 50 deletions
diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index 252efcb42..ad09db831 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -475,7 +475,7 @@ class _AssociationCollection(object): def __len__(self): return len(self.col) - def __nonzero__(self): + def __bool__(self): return bool(self.col) def __getstate__(self): @@ -514,7 +514,7 @@ class _AssociationList(_AssociationCollection): stop = index.stop step = index.step or 1 - rng = range(index.start or 0, stop, step) + rng = list(range(index.start or 0, stop, step)) if step == 1: for i in rng: del self[index.start] @@ -569,7 +569,7 @@ class _AssociationList(_AssociationCollection): def count(self, value): return sum([1 for _ in - itertools.ifilter(lambda v: v == value, iter(self))]) + filter(lambda v: v == value, iter(self))]) def extend(self, values): for v in values: @@ -668,8 +668,8 @@ class _AssociationList(_AssociationCollection): def __hash__(self): raise TypeError("%s objects are unhashable" % type(self).__name__) - for func_name, func in locals().items(): - if (util.callable(func) and func.func_name == func_name and + for func_name, func in list(locals().items()): + if (util.callable(func) and func.__name__ == func_name and not func.__doc__ and hasattr(list, func_name)): func.__doc__ = getattr(list, func_name).__doc__ del func_name, func @@ -711,7 +711,7 @@ class _AssociationDict(_AssociationCollection): return key in self.col def __iter__(self): - return self.col.iterkeys() + return iter(self.col.keys()) def clear(self): self.col.clear() @@ -738,7 +738,7 @@ class _AssociationDict(_AssociationCollection): return cmp(dict(self), other) def __repr__(self): - return repr(dict(self.items())) + return repr(dict(list(self.items()))) def get(self, key, default=None): try: @@ -754,13 +754,13 @@ class _AssociationDict(_AssociationCollection): return self[key] def keys(self): - return self.col.keys() + return list(self.col.keys()) def iterkeys(self): - return self.col.iterkeys() + return iter(self.col.keys()) def values(self): - return [self._get(member) for member in self.col.values()] + return [self._get(member) for member in list(self.col.values())] def itervalues(self): for key in self.col: @@ -811,13 +811,13 @@ class _AssociationDict(_AssociationCollection): self[key] = value def copy(self): - return dict(self.items()) + return dict(list(self.items())) def __hash__(self): raise TypeError("%s objects are unhashable" % type(self).__name__) - for func_name, func in locals().items(): - if (util.callable(func) and func.func_name == func_name and + for func_name, func in list(locals().items()): + if (util.callable(func) and func.__name__ == func_name and not func.__doc__ and hasattr(dict, func_name)): func.__doc__ = getattr(dict, func_name).__doc__ del func_name, func @@ -838,7 +838,7 @@ class _AssociationSet(_AssociationCollection): def __len__(self): return len(self.col) - def __nonzero__(self): + def __bool__(self): if self.col: return True else: @@ -1014,8 +1014,8 @@ class _AssociationSet(_AssociationCollection): def __hash__(self): raise TypeError("%s objects are unhashable" % type(self).__name__) - for func_name, func in locals().items(): - if (util.callable(func) and func.func_name == func_name and + for func_name, func in list(locals().items()): + if (util.callable(func) and func.__name__ == func_name and not func.__doc__ and hasattr(set, func_name)): func.__doc__ = getattr(set, func_name).__doc__ del func_name, func diff --git a/lib/sqlalchemy/ext/declarative/api.py b/lib/sqlalchemy/ext/declarative/api.py index 6f3ffddc7..21fac8534 100644 --- a/lib/sqlalchemy/ext/declarative/api.py +++ b/lib/sqlalchemy/ext/declarative/api.py @@ -424,7 +424,7 @@ class DeferredReflection(object): def prepare(cls, engine): """Reflect all :class:`.Table` objects for all current :class:`.DeferredReflection` subclasses""" - to_map = [m for m in _MapperConfig.configs.values() + to_map = [m for m in list(_MapperConfig.configs.values()) if issubclass(m.cls, cls)] for thingy in to_map: cls._sa_decl_prepare(thingy.local_table, engine) diff --git a/lib/sqlalchemy/ext/declarative/base.py b/lib/sqlalchemy/ext/declarative/base.py index ee2f0134a..2099f9eb0 100644 --- a/lib/sqlalchemy/ext/declarative/base.py +++ b/lib/sqlalchemy/ext/declarative/base.py @@ -57,7 +57,7 @@ def _as_declarative(cls, classname, dict_): class_mapped = _declared_mapping_info(base) is not None - for name, obj in vars(base).items(): + for name, obj in list(vars(base).items()): if name == '__mapper_args__': if not mapper_args_fn and ( not class_mapped or @@ -129,7 +129,7 @@ def _as_declarative(cls, classname, dict_): ret.doc = obj.__doc__ # apply inherited columns as we should - for k, v in potential_columns.items(): + for k, v in list(potential_columns.items()): dict_[k] = v if inherited_table_args and not tablename: @@ -173,7 +173,7 @@ def _as_declarative(cls, classname, dict_): # extract columns from the class dict declared_columns = set() - for key, c in our_stuff.iteritems(): + for key, c in our_stuff.items(): if isinstance(c, (ColumnProperty, CompositeProperty)): for col in c.columns: if isinstance(col, Column) and \ @@ -354,7 +354,7 @@ class _MapperConfig(object): # in which case the mapper makes this combination). # See if the superclass has a similar column property. # If so, join them together. - for k, col in properties.items(): + for k, col in list(properties.items()): if not isinstance(col, expression.ColumnElement): continue if k in inherited_mapper._props: diff --git a/lib/sqlalchemy/ext/declarative/clsregistry.py b/lib/sqlalchemy/ext/declarative/clsregistry.py index 89975716d..95aba93fa 100644 --- a/lib/sqlalchemy/ext/declarative/clsregistry.py +++ b/lib/sqlalchemy/ext/declarative/clsregistry.py @@ -255,7 +255,7 @@ def _resolver(cls, prop): return x.cls else: return x - except NameError, n: + except NameError as n: raise exc.InvalidRequestError( "When initializing mapper %s, expression %r failed to " "locate a name (%r). If this is a class name, consider " @@ -275,14 +275,14 @@ def _deferred_relationship(cls, prop): for attr in ('argument', 'order_by', 'primaryjoin', 'secondaryjoin', 'secondary', '_user_defined_foreign_keys', 'remote_side'): v = getattr(prop, attr) - if isinstance(v, basestring): + if isinstance(v, str): setattr(prop, attr, resolve_arg(v)) if prop.backref and isinstance(prop.backref, tuple): key, kwargs = prop.backref for attr in ('primaryjoin', 'secondaryjoin', 'secondary', 'foreign_keys', 'remote_side', 'order_by'): - if attr in kwargs and isinstance(kwargs[attr], basestring): + if attr in kwargs and isinstance(kwargs[attr], str): kwargs[attr] = resolve_arg(kwargs[attr]) return prop diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py index b1b851f72..08c0bdf13 100644 --- a/lib/sqlalchemy/ext/mutable.py +++ b/lib/sqlalchemy/ext/mutable.py @@ -485,7 +485,7 @@ class Mutable(MutableBase): def changed(self): """Subclasses should call this method whenever change events occur.""" - for parent, key in self._parents.items(): + for parent, key in list(self._parents.items()): flag_modified(parent, key) @classmethod @@ -579,7 +579,7 @@ class MutableComposite(MutableBase): def changed(self): """Subclasses should call this method whenever change events occur.""" - for parent, key in self._parents.items(): + for parent, key in list(self._parents.items()): prop = object_mapper(parent).get_property(key) for value, attr_name in zip( diff --git a/lib/sqlalchemy/ext/orderinglist.py b/lib/sqlalchemy/ext/orderinglist.py index ffdd971a0..930464d7b 100644 --- a/lib/sqlalchemy/ext/orderinglist.py +++ b/lib/sqlalchemy/ext/orderinglist.py @@ -324,7 +324,7 @@ class OrderingList(list): if stop < 0: stop += len(self) - for i in xrange(start, stop, step): + for i in range(start, stop, step): self.__setitem__(i, entity[i]) else: self._order_entity(index, entity, True) @@ -334,21 +334,21 @@ class OrderingList(list): super(OrderingList, self).__delitem__(index) self._reorder() - # Py2K - def __setslice__(self, start, end, values): - super(OrderingList, self).__setslice__(start, end, values) - self._reorder() - - def __delslice__(self, start, end): - super(OrderingList, self).__delslice__(start, end) - self._reorder() - # end Py2K +# start Py2K +# def __setslice__(self, start, end, values): +# super(OrderingList, self).__setslice__(start, end, values) +# self._reorder() +# +# def __delslice__(self, start, end): +# super(OrderingList, self).__delslice__(start, end) +# self._reorder() +# end Py2K def __reduce__(self): return _reconstitute, (self.__class__, self.__dict__, list(self)) - for func_name, func in locals().items(): - if (util.callable(func) and func.func_name == func_name and + for func_name, func in list(locals().items()): + if (util.callable(func) and func.__name__ == func_name and not func.__doc__ and hasattr(list, func_name)): func.__doc__ = getattr(list, func_name).__doc__ del func_name, func diff --git a/lib/sqlalchemy/ext/serializer.py b/lib/sqlalchemy/ext/serializer.py index 5a3fb5937..759652014 100644 --- a/lib/sqlalchemy/ext/serializer.py +++ b/lib/sqlalchemy/ext/serializer.py @@ -61,20 +61,22 @@ from ..engine import Engine from ..util import pickle import re import base64 -# Py3K -#from io import BytesIO as byte_buffer -# Py2K -from cStringIO import StringIO as byte_buffer +# start Py3K +from io import BytesIO as byte_buffer +# end Py3K +# start Py2K +#from cStringIO import StringIO as byte_buffer # end Py2K -# Py3K -#def b64encode(x): -# return base64.b64encode(x).decode('ascii') -#def b64decode(x): -# return base64.b64decode(x.encode('ascii')) -# Py2K -b64encode = base64.b64encode -b64decode = base64.b64decode +# start Py3K +def b64encode(x): + return base64.b64encode(x).decode('ascii') +def b64decode(x): + return base64.b64decode(x.encode('ascii')) +# end Py3K +# start Py2K +#b64encode = base64.b64encode +#b64decode = base64.b64decode # end Py2K __all__ = ['Serializer', 'Deserializer', 'dumps', 'loads'] |
