Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
compat.py83 linesDownload Raw Back to boto3
1# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License"). You4# may not use this file except in compliance with the License. A copy of5# the License is located at6#7# https://aws.amazon.com/apache2.0/8#9# or in the "license" file accompanying this file. This file is10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF11# ANY KIND, either express or implied. See the License for the specific12# language governing permissions and limitations under the License.13import sys14import os15import errno16import socket17import warnings18 19from boto3.exceptions import PythonDeprecationWarning20 21# In python3, socket.error is OSError, which is too general22# for what we want (i.e FileNotFoundError is a subclass of OSError).23# In py3 all the socket related errors are in a newly created24# ConnectionError25SOCKET_ERROR = ConnectionError26 27import collections.abc as collections_abc28 29 30if sys.platform.startswith('win'):31    def rename_file(current_filename, new_filename):32        try:33            os.remove(new_filename)34        except OSError as e:35            if not e.errno == errno.ENOENT:36                # We only want to a ignore trying to remove37                # a file that does not exist.  If it fails38                # for any other reason we should be propagating39                # that exception.40                raise41        os.rename(current_filename, new_filename)42else:43    rename_file = os.rename44 45 46def filter_python_deprecation_warnings():47    """48    Invoking this filter acknowledges your runtime will soon be deprecated49    at which time you will stop receiving all updates to your client.50    """51    warnings.filterwarnings(52        'ignore',53        message=".*Boto3 will no longer support Python.*",54        category=PythonDeprecationWarning,55        module=r".*boto3\.compat"56    )57 58 59def _warn_deprecated_python():60    """Use this template for future deprecation campaigns as needed."""61    py_37_params = {62        'date': 'December 13, 2023',63        'blog_link': (64            'https://aws.amazon.com/blogs/developer/'65            'python-support-policy-updates-for-aws-sdks-and-tools/'66        )67    }68    deprecated_versions = {69        # Example template for future deprecations70        (3, 7): py_37_params,71    }72    py_version = sys.version_info[:2]73 74    if py_version in deprecated_versions:75        params = deprecated_versions[py_version]76        warning = (77            "Boto3 will no longer support Python {}.{} "78            "starting {}. To continue receiving service updates, "79            "bug fixes, and security updates please upgrade to Python 3.8 or "80            "later. More information can be found here: {}"81        ).format(py_version[0], py_version[1], params['date'], params['blog_link'])82        warnings.warn(warning, PythonDeprecationWarning)83 
codekingpro/portable-devtools · Team Ai