Package: uri
© 2017-2018 Alice Bevan-McGregor and contributors.https://github.com/marrow/uriInstallationInstallinguriis easy, just execute the following in a terminal:pip install uriNote:Westronglyrecommend always using a container, virtualization, or sandboxing environment of some kind when
developing using Python; installing things system-wide is yucky (for a variety of reasons) nine times out of ten.  We
prefer light-weightvirtualenv, others prefer solutions as
robust asVagrant.If you addurito theinstall_requiresargument of the call tosetup()in your application’ssetup.pyfile,uriwill be automatically installed and made available when your own application or
library is installed.  We recommend using “less than” version numbers to ensure there are no unintentional
side-effects when updating.  Useuri<2.1to get all bugfixes for the current release, anduri<3.0to get bugfixes and feature updates while ensuring that large breaking changes are not installed.While uri does not have any hard dependencies on any other package, it isstronglyrecommended that applications
using uri in web-based applications also install themarkupsafepackage to provide more efficient string escaping and
some additional functionality.Development VersionDevelopment takes place onGitHubin theuriproject.  Issue tracking, documentation, and downloads
are provided there.Installing the current development version requiresGit, a distributed source code management
system.  If you have Git you can run the following to download andlinkthe development version into your Python
runtime:git clone https://github.com/marrow/uri.git
(cd uri; python setup.py develop)You can then upgrade to the latest version at any time:(cd uri; git pull; python setup.py develop)If you would like to make changes and contribute them back to the project, fork the GitHub project, make your changes,
and submit a pull request.  This process is beyond the scope of this documentation; for more information seeGitHub’s documentation.Getting StartedURIAn abstract string-like (and mapping-like, and iterator-like…) identifier for a resource with the regular form
defined byRFC 3986:scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment]For details on these components,please refer to Wikipedia. Each of these components is represented by an
appropraite rich datatype:Theschemeof a URI represents an extensible API of string-like plugins.Any IPv6hostis automatically wrapped and unwrapped in square braces.Thepathis represented by aPurePosixPath.Thequeryis a rich ordered multi-value bucketed mutable mapping calledQSO. (Ouch, but that’s what it is!)Instantiate a new URI by passing in a string or string-castable object,pathlib.Pathcompatible object, or object
exposing a__link__method or attribute:home = URI("https://github.com/marrow/")Thescalarattributes are combined into severalcompoundgroups for convienence:Thecredentialsare a colon (:) separated combination of:user+password— also accessible via the
shorterauthor the longerauthenticationattributes.Theauthoritypart is the combination of:credentials+host+portTheheirarchicalpart is the combination of:authoritypart +pathOther aliases are provided for the scalar components, typically for compliance with external APIs, such as
interoperability withpathlib.Pathorurlsplitobjects:usernameis the long form ofuser.hostnameis the long form ofhost.authenticationis the long form ofauth.In addition, several string views are provided for convienence, but ultimately all just callstr()against the
instance or one of the compound groups described above:urirepresents the entire URI as a string.safe_urirepresents the enture URI, sans any password that may be present.baseis the combination ofschemeand theheirarchicalpart.summaryis a useful shortcut for web presentation containing only thehostandportof the URI.qsis just the query string, as a plain string instead of QSO instance.URI values may be absolute identifiers or relative references. Absolute URIs are what most people see every day:https://example.com/about/usftp://example.com/thing.txtmailto:user@example.comuri:ISSN:1535-3613Indirect references require the context of an absolute identifier in order to resolve them. Examples include://example.com/protocol/relative— protocol implied from context, frequently used in HTML when referencing
resources hosted on content delivery networks./host/relative— all elementsup tothe path are preserved from context, also frequently used in HTML when
referencing resources on the same server. This is not equivalent tofile:///host/relative, as the protocol is
unknown.relative/path— the resulting path is relative to the “current working directory” of the context.../parent/relative/path— references may ascend into parents of the context.resource#fragment— referencing a specific fragment of a sibling resource.#fragment— a same-document reference to a specific fragment of the context.Two primary methods are provided to combine a base URI with another URI, absolute or relative.  The first, utilizing
theuri.resolve(uri, **parts)method, allows you to both resolve a target URL as well as provide explicit
overrides for any of the above scalar attributes, such as query string. The second, which is recommended for general
use, is to use the division and floor division operators:base = URI("https://example.com/about/us")
cdn = base // "cdn.example.com"
js = cdn / "script.js"
css = cdn / "script.css"Please note that once a URI has an “authority” part (basically, the parts prior to the path such as host) then any
path directly assigned must be “rooted”, or contain a leading slash.SchemesEach URI has a scheme which should be registered with theInternet Assigned Numbers Authority (IANA)which specifies the mechanics of the URI
fields.  Examples include:http,https,ftp,mailto,file,data, etc.Version HistoryVersion 2.0.1Added non-standardresourcecompound view.Removed Python 3.3 support, added 3.7, removed deprecated testing dependency.Scheme objects hash as per their string representation. #5Dead code clean-up.Additional tests covering previously uncovered edge cases, such as assignment to a compound view property.Restrict assignment of rootless paths (no leading/) if an authority part is already present. #8Enable handling of the following schemes as per URL (colon + double slash):sftpmysqlredismongodbVersion 2.0Extraction of theURIStringobject from Marrow Mongo.Version 1.0Original package by Jacob Kaplan-Moss. Copyright 2008 and released under the BSD License.LicenseThe URI package has been released under the MIT Open Source license.The MIT LicenseCopyright © 2017-2018 Alice Bevan-McGregor and contributors.Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.