~ubuntu-branches/debian/sid/sqlalchemy/sid

« back to all changes in this revision

Viewing changes to lib/sqlalchemy/util/compat.py

  • Committer: Package Import Robot
  • Author(s): Piotr Ożarowski
  • Date: 2012-01-29 23:29:50 UTC
  • mfrom: (1.4.18)
  • Revision ID: package-import@ubuntu.com-20120129232950-1mw4zn2xy2o51ua5
Tags: 0.7.5-1
* New upstream release
  - minumum required python-sphinx version bumped to 1.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# util/compat.py
2
 
# Copyright (C) 2005-2011 the SQLAlchemy authors and contributors <see AUTHORS file>
 
2
# Copyright (C) 2005-2012 the SQLAlchemy authors and contributors <see AUTHORS file>
3
3
#
4
4
# This module is part of SQLAlchemy and is released under
5
5
# the MIT License: http://www.opensource.org/licenses/mit-license.php
8
8
 
9
9
import sys
10
10
 
11
 
# Py2K
12
 
import __builtin__
13
 
# end Py2K
14
11
 
15
12
try:
16
13
    import threading
18
15
    import dummy_threading as threading
19
16
 
20
17
py32 = sys.version_info >= (3, 2)
21
 
py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0)
 
18
py3k_warning = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0)
22
19
jython = sys.platform.startswith('java')
23
20
pypy = hasattr(sys, 'pypy_version_info')
24
21
win32 = sys.platform.startswith('win')
25
22
 
26
 
if py3k:
 
23
if py3k_warning:
27
24
    set_types = set
28
25
elif sys.version_info < (2, 6):
29
26
    import sets
43
40
 
44
41
    set_types = set, sets.Set
45
42
 
46
 
if py3k:
 
43
if py3k_warning:
47
44
    import pickle
48
45
else:
49
46
    try:
56
53
    return x 
57
54
 
58
55
# Py2K
59
 
buffer = getattr(__builtin__, 'buffer', buffer)
 
56
buffer = buffer
60
57
# end Py2K
61
58
 
62
59
try:
89
86
else:
90
87
    from urlparse import parse_qsl
91
88
 
92
 
if py3k:
93
 
    from inspect import getfullargspec as inspect_getfullargspec
94
 
else:
95
 
    from inspect import getargspec as inspect_getfullargspec
 
89
# Py3K
 
90
#from inspect import getfullargspec as inspect_getfullargspec
 
91
# Py2K
 
92
from inspect import getargspec as inspect_getfullargspec
 
93
# end Py2K
96
94
 
97
 
if py3k:
 
95
if py3k_warning:
98
96
    # they're bringing it back in 3.2.  brilliant !
99
97
    def callable(fn):
100
98
        return hasattr(fn, '__call__')
103
101
 
104
102
    from functools import reduce
105
103
else:
106
 
    callable = __builtin__.callable
107
 
    cmp = __builtin__.cmp
108
 
    reduce = __builtin__.reduce
 
104
    callable = callable
 
105
    cmp = cmp
 
106
    reduce = reduce
109
107
 
110
108
try:
111
109
    from collections import defaultdict
192
190
    time_func = time.time 
193
191
 
194
192
if sys.version_info >= (2, 5):
 
193
    any = any
 
194
else:
 
195
    def any(iterator):
 
196
        for item in iterator:
 
197
            if bool(item):
 
198
                return True
 
199
        else:
 
200
            return False
 
201
 
 
202
if sys.version_info >= (2, 5):
195
203
    def decode_slice(slc):
196
204
        """decode a slice object as sent to __getitem__.
197
205