Mercurial > babel > mirror
annotate babel/compat.py @ 567:c81a11cb1476 trunk
add a compat module to shield the code from changes in different versions of Python
author | fschwarz |
---|---|
date | Mon, 26 Sep 2011 09:42:43 +0000 |
parents | |
children | 8ce41e60f90d |
rev | line source |
---|---|
567
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
2 # |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
3 # Copyright (C) 2007-2011 Edgewall Software |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
4 # All rights reserved. |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
5 # |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
6 # This software is licensed as described in the file COPYING, which |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
7 # you should have received as part of this distribution. The terms |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
8 # are also available at http://babel.edgewall.org/wiki/License. |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
9 # |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
10 # This software consists of voluntary contributions made by many |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
11 # individuals. For the exact contribution history, see the revision |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
12 # history and logs, available at http://babel.edgewall.org/log/. |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
13 |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
14 try: |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
15 from xml.etree import ElementTree |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
16 except ImportError: |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
17 from elementtree import ElementTree |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
18 |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
19 try: |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
20 any = any |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
21 except NameError: |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
22 def any(iterable): |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
23 return filter(None, list(iterable)) |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
24 |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
25 try: |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
26 import threading |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
27 except ImportError: |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
28 import dummy_threading as threading |
c81a11cb1476
add a compat module to shield the code from changes in different versions of Python
fschwarz
parents:
diff
changeset
|
29 |