view sat_tmp/twisted/__init__.py @ 71:a564fc84d5d0

twisted: added Twisted module for Python 3.8 compatibility: Current Twisted version (19.10.0) is not Python 3.8 compatible, so a twisted directory has been added to fix `twisted.words.xish.domish` and be able to use it with Python 3.8. To be removed once Python 3.8 compatible version of Twisted is published.
author Goffi <goffi@goffi.org>
date Mon, 18 Nov 2019 20:48:45 +0100
parents
children
line wrap: on
line source

#!/usr/bin/env python3
#
# Series of Twisted patches used by SàT
# Copyright (C) 2015-2019 Jérôme Poisson (goffi@goffi.org)

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys
from twisted import version as v
from logging import Logger

log = Logger(__name__)


def install():
    """Monkey patch Twisted to have improvments implemented here"""
    # Python 3.8 support for domish
    if (v.major, v.minor) > (19, 10):
        log.warning(
            f"New release of Twisted available ({v.short()}), Python 3.8 patch may not "
            f"be needed anymore")

    from . import domish
    sys.modules['twisted.words.xish.domish'] = domish