7
7
there is a good reason not to, and provide that reason in those cases.
8
8
"""
9
9
10
- from typing import Optional
11
10
12
11
#### General errors ####
13
12
@@ -39,29 +38,16 @@ class URLParsingError(Exception):
39
38
cannot be isoalted."""
40
39
41
40
42
- class RepositoryError (Exception ):
43
- """An error with a repository's state, such as a missing file."""
44
-
45
-
46
41
#### Repository errors ####
47
42
48
43
49
- class UnsignedMetadataError (RepositoryError ):
50
- """An error about metadata object with insufficient threshold of signatures.
51
-
52
- Args:
53
- message: The error message
54
- """
55
-
56
- def __init__ (self , message : str ) -> None :
57
- super ().__init__ ()
58
- self .exception_message = message
44
+ class RepositoryError (Exception ):
45
+ """An error with a repository's state, such as a missing file."""
59
46
60
- def __str__ (self ) -> str :
61
- return self .exception_message
62
47
63
- def __repr__ (self ) -> str :
64
- return self .__class__ .__name__ + " : " + str (self )
48
+ class UnsignedMetadataError (RepositoryError ):
49
+ """An error about metadata object with insufficient threshold of
50
+ signatures."""
65
51
66
52
67
53
class BadVersionNumberError (RepositoryError ):
@@ -92,17 +78,11 @@ def __init__(
92
78
93
79
def __str__ (self ) -> str :
94
80
return (
95
- "Downloaded "
96
- + repr (self .metadata_role )
97
- + " is older ("
98
- + repr (self .downloaded_version )
99
- + ") than the version currently "
100
- "installed (" + repr (self .current_version ) + ")."
81
+ f"Downloaded { self .metadata_role } is older ("
82
+ f"{ self .downloaded_version } ) than the version currently installed"
83
+ f"({ self .current_version } )"
101
84
)
102
85
103
- def __repr__ (self ) -> str :
104
- return self .__class__ .__name__ + " : " + str (self )
105
-
106
86
107
87
#### Download Errors ####
108
88
@@ -114,42 +94,6 @@ class DownloadError(Exception):
114
94
class DownloadLengthMismatchError (DownloadError ):
115
95
"""Indicate that a mismatch of lengths was seen while downloading a file."""
116
96
117
- def __init__ (self , expected_length : int , observed_length : int ) -> None :
118
- super ().__init__ ()
119
-
120
- self .expected_length = expected_length # bytes
121
- self .observed_length = observed_length # bytes
122
-
123
- def __str__ (self ) -> str :
124
- return (
125
- "Observed length ("
126
- + repr (self .observed_length )
127
- + ") < expected length ("
128
- + repr (self .expected_length )
129
- + ")."
130
- )
131
-
132
- def __repr__ (self ) -> str :
133
- return self .__class__ .__name__ + " : " + str (self )
134
-
135
97
136
98
class SlowRetrievalError (DownloadError ):
137
- """ "Indicate that downloading a file took an unreasonably long time."""
138
-
139
- def __init__ (self , average_download_speed : Optional [int ] = None ) -> None :
140
- super ().__init__ ()
141
- self .__average_download_speed = average_download_speed # bytes/second
142
-
143
- def __str__ (self ) -> str :
144
- msg = "Download was too slow."
145
- if self .__average_download_speed is not None :
146
- msg = (
147
- "Download was too slow. Average speed: "
148
- + repr (self .__average_download_speed )
149
- + " bytes per second."
150
- )
151
-
152
- return msg
153
-
154
- def __repr__ (self ) -> str :
155
- return self .__class__ .__name__ + " : " + str (self )
99
+ """Indicate that downloading a file took an unreasonably long time."""
0 commit comments