Repository URL to install this package:
Version:
3.3.42 ▾
|
ó ȍEYc @ s¼ d Z d d l m Z d d l m Z d d l m Z d e f d YZ d Z d Z d Z d Z d e d Z e d Z e d Z e d Z e d Z d Z d S( s3 Module containing the validation logic for rfc3986.i ( t exceptions( t misc( t normalizerst Validatorc B sw e Z d Z e d d d d d d d g Z d Z d Z d Z d Z d Z d Z d Z d Z RS( st Object used to configure validation of all objects in rfc3986. Example usage:: >>> from rfc3986 import api, validators >>> uri = api.uri_reference('https://github.com/') >>> validator = validators.Validator().require_presence_of( ... 'scheme', 'host', 'path', ... ).allow_schemes( ... 'http', 'https', ... ).allow_hosts( ... '127.0.0.1', 'github.com', ... ) >>> validator.validate(uri) >>> invalid_uri = rfc3986.uri_reference('imap://mail.google.com') >>> validator.validate(invalid_uri) Traceback (most recent call last): ... rfc3986.exceptions.MissingComponentError: ('path was required but missing', URIReference(scheme=u'imap', authority=u'mail.google.com', path=None, query=None, fragment=None), ['path']) t schemet userinfot hostt portt patht queryt fragmentc C sk t | _ t | _ t | _ t | _ i t d 6t d 6t d 6t d 6t d 6t d 6t d 6| _ d S( s# Initialize our default validations.R R R R R R R N( t sett allowed_schemest allowed_hostst allowed_portst Truet allow_passwordt Falset required_components( t self( ( sG /home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyt __init__8 s c G s. x' | D] } | j j t j | q W| S( sê Require the scheme to be one of the provided schemes. :param schemes: Schemes, without ``://`` that are allowed. :returns: The validator instance. :rtype: Validator ( R t addR t normalize_scheme( R t schemesR ( ( sG /home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyt allow_schemesH s c G s. x' | D] } | j j t j | q W| S( sÑ Require the host to be one of the provided hosts. :param hosts: Hosts that are allowed. :returns: The validator instance. :rtype: Validator ( R R R t normalize_host( R t hostsR ( ( sG /home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyt allow_hostsV s c G sV xO | D]G } t | d d } d | k o6 d k n r | j j | q q W| S( sÑ Require the port to be one of the provided ports. :param ports: Ports that are allowed. :returns: The validator instance. :rtype: Validator t basei i iÿÿ ( t intR R ( R t portsR t port_int( ( sG /home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyt allow_portsd s c C s t | _ | S( s) Allow passwords to be present in the URI.( R R ( R ( ( sG /home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyt allow_use_of_passwordt s c C s t | _ | S( s1 Prevent passwords from being included in the URI.( R R ( R ( ( sG /home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyt forbid_use_of_passwordy s c G su g | D] } | j ^ q } x5 | D]- } | | j k r&