diff options
| author | Eric Hurst | 2019-08-29 09:30:49 -0600 |
|---|---|---|
| committer | Eric Hurst | 2019-08-29 10:09:35 -0600 |
| commit | fe7850ec78cb2ecbf1a2a2afa2e5c3feb5e62351 (patch) | |
| tree | e458904b6a0e63267c0e9ac286e92722afd43889 | |
| parent | cec5028f9c85ed567e93cdf84e7f7816fde0d279 (diff) | |
| download | eventmq-fe7850ec78cb2ecbf1a2a2afa2e5c3feb5e62351.tar.gz eventmq-fe7850ec78cb2ecbf1a2a2afa2e5c3feb5e62351.zip | |
Add python 2/3 compatablity for configparser
| -rw-r--r-- | eventmq/tests/test_utils.py | 11 | ||||
| -rw-r--r-- | eventmq/utils/settings.py | 9 |
2 files changed, 18 insertions, 2 deletions
diff --git a/eventmq/tests/test_utils.py b/eventmq/tests/test_utils.py index 2937085..501b081 100644 --- a/eventmq/tests/test_utils.py +++ b/eventmq/tests/test_utils.py | |||
| @@ -12,7 +12,16 @@ | |||
| 12 | # | 12 | # |
| 13 | # You should have received a copy of the GNU Lesser General Public License | 13 | # You should have received a copy of the GNU Lesser General Public License |
| 14 | # along with eventmq. If not, see <http://www.gnu.org/licenses/>. | 14 | # along with eventmq. If not, see <http://www.gnu.org/licenses/>. |
| 15 | from configparser import ConfigParser | 15 | |
| 16 | # | ||
| 17 | |||
| 18 | # ConfigParser was renamed to configparser in python 3. Do this try...except | ||
| 19 | # to maintain python 2/3 compatability | ||
| 20 | try: | ||
| 21 | from configparser import ConfigParser | ||
| 22 | except ImportError: | ||
| 23 | import ConfigParser | ||
| 24 | |||
| 16 | from imp import reload | 25 | from imp import reload |
| 17 | import io | 26 | import io |
| 18 | import os | 27 | import os |
diff --git a/eventmq/utils/settings.py b/eventmq/utils/settings.py index 7a91858..ade76c2 100644 --- a/eventmq/utils/settings.py +++ b/eventmq/utils/settings.py | |||
| @@ -16,7 +16,14 @@ | |||
| 16 | :mod:`settings` -- Settings Utilities | 16 | :mod:`settings` -- Settings Utilities |
| 17 | ===================================== | 17 | ===================================== |
| 18 | """ | 18 | """ |
| 19 | from configparser import ConfigParser, NoOptionError | 19 | |
| 20 | # ConfigParser was renamed to configparser in python 3. Do this try...except | ||
| 21 | # to maintain python 2/3 compatability | ||
| 22 | try: | ||
| 23 | from configparser import ConfigParser, NoOptionError | ||
| 24 | except ImportError: | ||
| 25 | from ConfigParser import ConfigParser, NoOptionError | ||
| 26 | |||
| 20 | import json | 27 | import json |
| 21 | import logging | 28 | import logging |
| 22 | import os | 29 | import os |