Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / rfc3986 / validators.pyc
Size: Mime:
ó
ȍEYc@s¼dZddlmZddlmZddlmZdefd„ƒYZd„Zd„Zd	„Z	d
„Z
ded„Z
ed„Zed
„Zed„Zed„Zd„ZdS(s3Module containing the validation logic for rfc3986.i(t
exceptions(tmisc(tnormalizerst	ValidatorcBsweZdZedddddddgƒZd„Zd	„Zd
„Zd„Zd„Z	d
„Z
d„Zd„ZRS(stObject 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'])

    tschemetuserinfothosttporttpathtquerytfragmentcCsktƒ|_tƒ|_tƒ|_t|_itd6td6td6td6td6td6td6|_dS(	s#Initialize our default validations.RRRRRR	R
N(tsettallowed_schemest
allowed_hostst
allowed_portstTruetallow_passwordtFalsetrequired_components(tself((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyt__init__8s	cGs.x'|D]}|jjtj|ƒƒqW|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taddRtnormalize_scheme(RtschemesR((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyt
allow_schemesHs

cGs.x'|D]}|jjtj|ƒƒqW|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
RRtnormalize_host(RthostsR((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pytallow_hostsVs

cGsVxO|D]G}t|ddƒ}d|ko6dknr|jj|ƒqqW|S(sÑRequire the port to be one of the provided ports.

        :param ports:
            Ports that are allowed.
        :returns:
            The validator instance.
        :rtype:
            Validator
        tbasei
iiÿÿ(tintRR(RtportsRtport_int((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pytallow_portsds


cCs
t|_|S(s)Allow passwords to be present in the URI.(RR(R((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pytallow_use_of_passwordts	cCs
t|_|S(s1Prevent passwords from being included in the URI.(RR(R((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pytforbid_use_of_passwordys	cGsug|D]}|jƒ^q}x5|D]-}||jkr&tdj|ƒƒ‚q&q&W|jjd„|Dƒƒ|S(séRequire the components provided.

        :param components:
            Names of components from :attr:`Validator.COMPONENT_NAMES`.
        :returns:
            The validator instance.
        :rtype:
            Validator
        s"{}" is not a valid componentcSsi|]}t|“qS((R(t.0t	component((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pys
<dictcomp>s	(tlowertCOMPONENT_NAMESt
ValueErrortformatRtupdate(Rt
componentstcR$((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pytrequire_presence_of~s

	cCs—|jst|ƒng|jjƒD]\}}|r&|^q&}|rZt||ƒnt|j|dƒt|j|dƒt|j|dƒdS(sCheck a URI for conditions specified on this validator.

        :param uri:
            Parsed URI to validate.
        :type uri:
            rfc3986.uri.URIReference
        :raises MissingComponentError:
            When a required component is missing.
        :raises UnpermittedComponentError:
            When a component is not one of those allowed.
        :raises PasswordForbidden:
            When a password is present in the userinfo component but is
            not permitted by configuration.
        RRRN(	Rtcheck_passwordRtitemst ensure_required_components_existt
ensure_one_ofRR
R(RturiR$trequiredR((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pytvalidate“s	
(
t__name__t
__module__t__doc__t	frozensetR&RRRR R!R"R,R3(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyRs"							cCsN|j}|sdS|jddƒ}t|ƒdkr;dStj|ƒ‚dS(s4Assert that there is no password present in the uri.Nt:i(RtsplittlenRtPasswordForbidden(R1Rtcredentials((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyR-²s	cCsIt||ƒ}|dk	rE|rE||krEtj|||ƒ‚ndS(s=Assert that the uri's attribute is one of the allowed values.N(tgetattrtNoneRtUnpermittedComponentError(tallowed_valuesR1t	attributetvalue((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyR0½scCsStg|D]!}t||ƒdkr
|^q
ƒ}|rOtj||Œ‚ndS(s;Assert that all required components are present in the URI.N(tsortedR=R>RtMissingComponentError(R1RR$tmissing_components((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyR/Æs
$cCs8|r|dk	o|j|ƒS|dkp7|j|ƒS(sDetermine if a value is valid based on the provided matcher.

    :param str value:
        Value to validate.
    :param matcher:
        Compiled regular expression to use to validate the value.
    :param require:
        Whether or not the value is required.
    N(R>tmatch(RBtmatchertrequire((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pytis_validÑs

cCsGt|tj|ƒ}|rC|dk	rCtjj|ƒrCt|ƒS|S(snDetermine if the authority string is valid.

    :param str authority:
        The authority to validate.
    :param str host:
        (optional) The host portion of the authority to validate.
    :param bool require:
        (optional) Specify if authority must not be None.
    :returns:
        ``True`` if valid, ``False`` otherwise
    :rtype:
        bool
    N(RIRtSUBAUTHORITY_MATCHERR>tIPv4_MATCHERRFtvalid_ipv4_host_address(t	authorityRRHt	validated((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pytauthority_is_validãs$
cCst|tj|ƒS(s+Determine if the scheme is valid.

    :param str scheme:
        The scheme string to validate.
    :param bool require:
        (optional) Set to ``True`` to require the presence of a scheme.
    :returns:
        ``True`` if the scheme is valid. ``False`` otherwise.
    :rtype:
        bool
    (RIRtSCHEME_MATCHER(RRH((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pytscheme_is_valid÷scCst|tj|ƒS(s+Determine if the path component is valid.

    :param str path:
        The path string to validate.
    :param bool require:
        (optional) Set to ``True`` to require the presence of a path.
    :returns:
        ``True`` if the path is valid. ``False`` otherwise.
    :rtype:
        bool
    (RIRtPATH_MATCHER(RRH((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyt
path_is_validscCst|tj|ƒS(s0Determine if the query component is valid.

    :param str query:
        The query string to validate.
    :param bool require:
        (optional) Set to ``True`` to require the presence of a query.
    :returns:
        ``True`` if the query is valid. ``False`` otherwise.
    :rtype:
        bool
    (RIRt
QUERY_MATCHER(R	RH((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pytquery_is_validscCst|tj|ƒS(s?Determine if the fragment component is valid.

    :param str fragment:
        The fragment string to validate.
    :param bool require:
        (optional) Set to ``True`` to require the presence of a fragment.
    :returns:
        ``True`` if the fragment is valid. ``False`` otherwise.
    :rtype:
        bool
    (RIRtFRAGMENT_MATCHER(R
RH((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pytfragment_is_valid$scCsHtg|jdƒD].}dt|ddƒko<dkn^qƒS(s4Determine if the given host is a valid IPv4 address.t.iRi
iÿ(tallR9R(Rtbyte((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyRL3sN(R6tRRRtobjectRR-R0R/RIR>RRORQRSRURWRL(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/rfc3986/validators.pyt<module>s