scrapy / scrapy
1
"""Boto/botocore helpers"""
2 7
import warnings
3

4 7
from scrapy.exceptions import NotConfigured, ScrapyDeprecationWarning
5

6

7 7
def is_botocore():
8
    """ Returns True if botocore is available, otherwise raises NotConfigured. Never returns False.
9

10
    Previously, when boto was supported in addition to botocore, this returned False if boto was available
11
    but botocore wasn't.
12
    """
13 0
    message = (
14
        'is_botocore() is deprecated and always returns True or raises an Exception, '
15
        'so it cannot be used for checking if boto is available instead of botocore. '
16
        'You can use scrapy.utils.boto.is_botocore_available() to check if botocore '
17
        'is available.'
18
    )
19 0
    warnings.warn(message, ScrapyDeprecationWarning, stacklevel=2)
20 0
    try:
21 0
        import botocore  # noqa: F401
22 0
        return True
23 0
    except ImportError:
24 0
        raise NotConfigured('missing botocore library')
25

26

27 7
def is_botocore_available():
28 7
    try:
29 7
        import botocore  # noqa: F401
30 7
        return True
31 0
    except ImportError:
32 0
        return False

Read our documentation on viewing source code .

Loading