<filename>slimta/util/pycompat.py<gh_stars>0
# Copyright (c) 2016 <NAME>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

"""This module makes compatibility between Python 2 and Python 3 a little more
convenient. It's intended to avoid dependence on the ``six`` library.

"""

from __future__ import absolute_import

import sys

try:
    from urllib import parse as urlparse_mod
    from http import client as httplib_mod
    import reprlib as reprlib_mod
except ImportError:
    import urlparse as urlparse_mod
    import httplib as httplib_mod
    import repr as reprlib_mod

__all__ = ['PY3', 'PY2']

#: True if the interpreter is Python 3.x, False otherwise.
PY3 = (sys.version_info[0] == 3)

#: True if the interpreter is Python 2.x, False otherwise.
PY2 = (sys.version_info[0] == 2)

#: The ``urlparse`` module on Python 2, ``urllib.parse`` on Python 3.
urlparse = urlparse_mod

#: The ``httplib`` module on Python 2, ``http.client`` on Python 3. In Python
#: 2, the deprecated ``strict`` parameter is set to True.
httplib = httplib_mod

#: The ``repr`` module on Python 2, ``reprlib`` on Python 3.
reprlib = reprlib_mod


# vim:et:fdm=marker:sts=4:sw=4:ts=4

<filename>slimta/util/pycompat.py<gh_stars>0
# Copyright (c) 2016 <NAME>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

"""This module makes compatibility between Python 2 and Python 3 a little more
convenient. It's intended to avoid dependence on the ``six`` library.

"""

from __future__ import absolute_import

import sys

try:
    from urllib import parse as urlparse_mod
    from http import client as httplib_mod
    import reprlib as reprlib_mod
except ImportError:
    import urlparse as urlparse_mod
    import httplib as httplib_mod
    import repr as reprlib_mod

__all__ = ['PY3', 'PY2']

#: True if the interpreter is Python 3.x, False otherwise.
PY3 = (sys.version_info[0] == 3)

#: True if the interpreter is Python 2.x, False otherwise.
PY2 = (sys.version_info[0] == 2)

#: The ``urlparse`` module on Python 2, ``urllib.parse`` on Python 3.
urlparse = urlparse_mod

#: The ``httplib`` module on Python 2, ``http.client`` on Python 3. In Python
#: 2, the deprecated ``strict`` parameter is set to True.
httplib = httplib_mod

#: The ``repr`` module on Python 2, ``reprlib`` on Python 3.
reprlib = reprlib_mod


# vim:et:fdm=marker:sts=4:sw=4:ts=4

# Copyright (c) 2016 <NAME> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # This module makes compatibility between Python 2 and Python 3 a little more convenient. It's intended to avoid dependence on the ``six`` library. #: True if the interpreter is Python 3.x, False otherwise. #: True if the interpreter is Python 2.x, False otherwise. #: The ``urlparse`` module on Python 2, ``urllib.parse`` on Python 3. #: The ``httplib`` module on Python 2, ``http.client`` on Python 3. In Python #: 2, the deprecated ``strict`` parameter is set to True. #: The ``repr`` module on Python 2, ``reprlib`` on Python 3. # vim:et:fdm=marker:sts=4:sw=4:ts=4