-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from matham/master
Add compat module, remove decoding of strings in notification
- Loading branch information
Showing
4 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
''' | ||
Compatibility module for Python 2.7 and > 3.3 | ||
============================================= | ||
''' | ||
|
||
__all__ = ('PY2', 'string_types', 'queue', 'iterkeys', | ||
'itervalues', 'iteritems') | ||
|
||
import sys | ||
try: | ||
import queue | ||
except ImportError: | ||
import Queue as queue | ||
|
||
#: True if Python 2 intepreter is used | ||
PY2 = sys.version_info[0] == 2 | ||
|
||
#: String types that can be used for checking if a object is a string | ||
string_types = None | ||
text_type = None | ||
if PY2: | ||
string_types = basestring | ||
text_type = unicode | ||
else: | ||
string_types = text_type = str | ||
|
||
if PY2: | ||
iterkeys = lambda d: d.iterkeys() | ||
itervalues = lambda d: d.itervalues() | ||
iteritems = lambda d: d.iteritems() | ||
else: | ||
iterkeys = lambda d: iter(d.keys()) | ||
itervalues = lambda d: iter(d.values()) | ||
iteritems = lambda d: iter(d.items()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters