15
15
# See the License for the specific language governing permissions and
16
16
# limitations under the License.
17
17
from collections import namedtuple
18
+ import warnings
18
19
19
20
from . import compat
20
21
from . import exceptions as exc
@@ -210,6 +211,10 @@ def is_absolute(self):
210
211
def is_valid (self , ** kwargs ):
211
212
"""Determine if the URI is valid.
212
213
214
+ .. deprecated:: 1.1.0
215
+
216
+ Use the :class:`~rfc3986.validators.Validator` object instead.
217
+
213
218
:param bool require_scheme: Set to ``True`` if you wish to require the
214
219
presence of the scheme component.
215
220
:param bool require_authority: Set to ``True`` if you wish to require
@@ -223,6 +228,9 @@ def is_valid(self, **kwargs):
223
228
:returns: ``True`` if the URI is valid. ``False`` otherwise.
224
229
:rtype: bool
225
230
"""
231
+ warnings .warn ("Please use rfc3986.validators.Validator instead. "
232
+ "This method will be eventually removed." ,
233
+ DeprecationWarning )
226
234
validators = [
227
235
(self .scheme_is_valid , kwargs .get ('require_scheme' , False )),
228
236
(self .authority_is_valid , kwargs .get ('require_authority' , False )),
@@ -235,13 +243,20 @@ def is_valid(self, **kwargs):
235
243
def authority_is_valid (self , require = False ):
236
244
"""Determine if the authority component is valid.
237
245
246
+ .. deprecated:: 1.1.0
247
+
248
+ Use the :class:`~rfc3986.validators.Validator` object instead.
249
+
238
250
:param bool require:
239
251
Set to ``True`` to require the presence of this component.
240
252
:returns:
241
253
``True`` if the authority is valid. ``False`` otherwise.
242
254
:rtype:
243
255
bool
244
256
"""
257
+ warnings .warn ("Please use rfc3986.validators.Validator instead. "
258
+ "This method will be eventually removed." ,
259
+ DeprecationWarning )
245
260
try :
246
261
self .authority_info ()
247
262
except exc .InvalidAuthority :
@@ -256,41 +271,69 @@ def authority_is_valid(self, require=False):
256
271
def scheme_is_valid (self , require = False ):
257
272
"""Determine if the scheme component is valid.
258
273
274
+ .. deprecated:: 1.1.0
275
+
276
+ Use the :class:`~rfc3986.validators.Validator` object instead.
277
+
259
278
:param str require: Set to ``True`` to require the presence of this
260
279
component.
261
280
:returns: ``True`` if the scheme is valid. ``False`` otherwise.
262
281
:rtype: bool
263
282
"""
283
+ warnings .warn ("Please use rfc3986.validators.Validator instead. "
284
+ "This method will be eventually removed." ,
285
+ DeprecationWarning )
264
286
return validators .scheme_is_valid (self .scheme , require )
265
287
266
288
def path_is_valid (self , require = False ):
267
289
"""Determine if the path component is valid.
268
290
291
+ .. deprecated:: 1.1.0
292
+
293
+ Use the :class:`~rfc3986.validators.Validator` object instead.
294
+
269
295
:param str require: Set to ``True`` to require the presence of this
270
296
component.
271
297
:returns: ``True`` if the path is valid. ``False`` otherwise.
272
298
:rtype: bool
273
299
"""
300
+ warnings .warn ("Please use rfc3986.validators.Validator instead. "
301
+ "This method will be eventually removed." ,
302
+ DeprecationWarning )
274
303
return validators .path_is_valid (self .path , require )
275
304
276
305
def query_is_valid (self , require = False ):
277
306
"""Determine if the query component is valid.
278
307
308
+ .. deprecated:: 1.1.0
309
+
310
+ Use the :class:`~rfc3986.validators.Validator` object instead.
311
+
279
312
:param str require: Set to ``True`` to require the presence of this
280
313
component.
281
314
:returns: ``True`` if the query is valid. ``False`` otherwise.
282
315
:rtype: bool
283
316
"""
317
+ warnings .warn ("Please use rfc3986.validators.Validator instead. "
318
+ "This method will be eventually removed." ,
319
+ DeprecationWarning )
284
320
return validators .query_is_valid (self .query , require )
285
321
286
322
def fragment_is_valid (self , require = False ):
287
323
"""Determine if the fragment component is valid.
288
324
325
+ .. deprecated:: 1.1.0
326
+
327
+ Use the Validator object instead.
328
+
289
329
:param str require: Set to ``True`` to require the presence of this
290
330
component.
291
331
:returns: ``True`` if the fragment is valid. ``False`` otherwise.
292
332
:rtype: bool
293
333
"""
334
+ warnings .warn ("Please use rfc3986.validators.Validator instead. "
335
+ "This method will be eventually removed." ,
336
+ DeprecationWarning )
294
337
return validators .fragment_is_valid (self .fragment , require )
295
338
296
339
def normalize (self ):
0 commit comments