Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/scrapy/exceptions.py: 79%

28 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-02-07 06:38 +0000

1""" 

2Scrapy core exceptions 

3 

4These exceptions are documented in docs/topics/exceptions.rst. Please don't add 

5new exceptions here without documenting them there. 

6""" 

7from typing import Any 

8 

9# Internal 

10 

11 

12class NotConfigured(Exception): 

13 """Indicates a missing configuration situation""" 

14 

15 pass 

16 

17 

18class _InvalidOutput(TypeError): 

19 """ 

20 Indicates an invalid value has been returned by a middleware's processing method. 

21 Internal and undocumented, it should not be raised or caught by user code. 

22 """ 

23 

24 pass 

25 

26 

27# HTTP and crawling 

28 

29 

30class IgnoreRequest(Exception): 

31 """Indicates a decision was made not to process a request""" 

32 

33 

34class DontCloseSpider(Exception): 

35 """Request the spider not to be closed yet""" 

36 

37 pass 

38 

39 

40class CloseSpider(Exception): 

41 """Raise this from callbacks to request the spider to be closed""" 

42 

43 def __init__(self, reason: str = "cancelled"): 

44 super().__init__() 

45 self.reason = reason 

46 

47 

48class StopDownload(Exception): 

49 """ 

50 Stop the download of the body for a given response. 

51 The 'fail' boolean parameter indicates whether or not the resulting partial response 

52 should be handled by the request errback. Note that 'fail' is a keyword-only argument. 

53 """ 

54 

55 def __init__(self, *, fail: bool = True): 

56 super().__init__() 

57 self.fail = fail 

58 

59 

60# Items 

61 

62 

63class DropItem(Exception): 

64 """Drop item from the item pipeline""" 

65 

66 pass 

67 

68 

69class NotSupported(Exception): 

70 """Indicates a feature or method is not supported""" 

71 

72 pass 

73 

74 

75# Commands 

76 

77 

78class UsageError(Exception): 

79 """To indicate a command-line usage error""" 

80 

81 def __init__(self, *a: Any, **kw: Any): 

82 self.print_help = kw.pop("print_help", True) 

83 super().__init__(*a, **kw) 

84 

85 

86class ScrapyDeprecationWarning(Warning): 

87 """Warning category for deprecated features, since the default 

88 DeprecationWarning is silenced on Python 2.7+ 

89 """ 

90 

91 pass 

92 

93 

94class ContractFail(AssertionError): 

95 """Error raised in case of a failing contract""" 

96 

97 pass