ó ½z]c@sPdZddlmZddlmZddlmZdefd„ƒYZdS(s6Module containing the logic for the URIBuilder object.i(tcompat(t normalizers(turit URIBuildercBs†eZdZd d d d d d d d„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „ZRS( s Object to aid in building up a URI Reference from parts. .. note:: This object should be instantiated by the user, but it's recommended that it is not provided with arguments. Instead, use the available method to populate the fields. cCsC||_||_||_||_||_||_||_dS(s€Initialize our URI builder. :param str scheme: (optional) :param str userinfo: (optional) :param str host: (optional) :param int port: (optional) :param str path: (optional) :param str query: (optional) :param str fragment: (optional) N(tschemetuserinfothosttporttpathtquerytfragment(tselfRRRRRR R ((sA/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/builder.pyt__init__ s      cCsd}|jd|ƒS(s0Provide a convenient view of our builder object.s‰URIBuilder(scheme={b.scheme}, userinfo={b.userinfo}, host={b.host}, port={b.port}, path={b.path}, query={b.query}, fragment={b.fragment})tb(tformat(R t formatstr((sA/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/builder.pyt__repr__;scCsRtj|ƒ}td|d|jd|jd|jd|jd|jd|jƒS(s“Add a scheme to our builder object. After normalizing, this will generate a new URIBuilder instance with the specified scheme and all other attributes the same. .. code-block:: python >>> URIBuilder().add_scheme('HTTPS') URIBuilder(scheme='https', userinfo=None, host=None, port=None, path=None, query=None, fragment=None) RRRRRR R ( Rtnormalize_schemeRRRRRR R (R R((sA/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/builder.pyt add_schemeBs      cCs—|d krtdƒ‚ntj|ƒ}|d k rTdj|tj|ƒƒ}ntd|jd|d|jd|j d|j d|j d |j ƒS( sëAdd credentials as the userinfo portion of the URI. .. code-block:: python >>> URIBuilder().add_credentials('root', 's3crete') URIBuilder(scheme=None, userinfo='root:s3crete', host=None, port=None, path=None, query=None, fragment=None) >>> URIBuilder().add_credentials('root', None) URIBuilder(scheme=None, userinfo='root', host=None, port=None, path=None, query=None, fragment=None) sUsername cannot be Nones{}:{}RRRRRR R N( tNonet ValueErrorRtnormalize_usernameRtnormalize_passwordRRRRRR R (R tusernametpasswordR((sA/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/builder.pytadd_credentialsZs       cCsLtd|jd|jdtj|ƒd|jd|jd|jd|jƒS(sAdd hostname to the URI. .. code-block:: python >>> URIBuilder().add_host('google.com') URIBuilder(scheme=None, userinfo=None, host='google.com', port=None, path=None, query=None, fragment=None) RRRRRR R ( RRRRtnormalize_hostRRR R (R R((sA/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/builder.pytadd_host{s      cCs t|ƒ}|dkr0tdj|ƒƒ‚n|dkrTtdj|ƒƒ‚ntd|jd|jd|jdd j|ƒd |jd |jd |j ƒS( sœAdd port to the URI. .. code-block:: python >>> URIBuilder().add_port(80) URIBuilder(scheme=None, userinfo=None, host=None, port='80', path=None, query=None, fragment=None) >>> URIBuilder().add_port(443) URIBuilder(scheme=None, userinfo=None, host=None, port='443', path=None, query=None, fragment=None) is5ports are not allowed to be negative. You provided {}iÿÿs>ports are not allowed to be larger than 65535. You provided {}RRRRs{}RR R ( tintRRRRRRRR R (R Rtport_int((sA/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/builder.pytadd_ports"        cCsm|jdƒs!dj|ƒ}ntd|jd|jd|jd|jdtj|ƒd|j d |j ƒS( sÛAdd a path to the URI. .. code-block:: python >>> URIBuilder().add_path('sigmavirus24/rfc3985') URIBuilder(scheme=None, userinfo=None, host=None, port=None, path='/sigmavirus24/rfc3986', query=None, fragment=None) >>> URIBuilder().add_path('/checkout.php') URIBuilder(scheme=None, userinfo=None, host=None, port=None, path='/checkout.php', query=None, fragment=None) t/s/{}RRRRRR R ( t startswithRRRRRRRtnormalize_pathR R (R R((sA/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/builder.pytadd_path¶s     cCs[tjtj|ƒƒ}td|jd|jd|jd|jd|j d|d|j ƒS(sæGenerate and add a query a dictionary or list of tuples. .. code-block:: python >>> URIBuilder().add_query_from({'a': 'b c'}) URIBuilder(scheme=None, userinfo=None, host=None, port=None, path=None, query='a=b+c', fragment=None) >>> URIBuilder().add_query_from([('a', 'b c')]) URIBuilder(scheme=None, userinfo=None, host=None, port=None, path=None, query='a=b+c', fragment=None) RRRRRR R ( Rtnormalize_queryRt urlencodeRRRRRRR (R t query_itemsR ((sA/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/builder.pytadd_query_fromÑs     cCsLtd|jd|jd|jd|jd|jdtj|ƒd|jƒS(sAdd a pre-formated query string to the URI. .. code-block:: python >>> URIBuilder().add_query('a=b&c=d') URIBuilder(scheme=None, userinfo=None, host=None, port=None, path=None, query='a=b&c=d', fragment=None) RRRRRR R ( RRRRRRRR#R (R R ((sA/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/builder.pyt add_queryës      cCsLtd|jd|jd|jd|jd|jd|jdtj|ƒƒS(sAdd a fragment to the URI. .. code-block:: python >>> URIBuilder().add_fragment('section-2.6.1') URIBuilder(scheme=None, userinfo=None, host=None, port=None, path=None, query=None, fragment='section-2.6.1') RRRRRR R ( RRRRRRR Rtnormalize_fragment(R R ((sA/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/builder.pyt add_fragmentÿs       cCs@tj|jtj|j|j|jfƒ|j|j |j ƒS(s>Create a URIReference from our builder. .. code-block:: python >>> URIBuilder().add_scheme('https').add_host('github.com' ... ).add_path('sigmavirus24/rfc3986').finalize().unsplit() 'https://github.com/sigmavirus24/rfc3986' >>> URIBuilder().add_scheme('https').add_host('github.com' ... ).add_path('sigmavirus24/rfc3986').add_credentials( ... 'sigmavirus24', 'not-re@l').finalize().unsplit() 'https://sigmavirus24:not-re%40l@github.com/sigmavirus24/rfc3986' ( Rt URIReferenceRRtnormalize_authorityRRRRR R (R ((sA/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/builder.pytfinalizesN(t__name__t __module__t__doc__RR RRRRRR"R&R'R)R,(((sA/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/builder.pyRs     !  '    N(R/tRRRtobjectR(((sA/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/builder.pyts