lazr.uri


Namelazr.uri JSON
Version 1.0.6 PyPI version JSON
download
home_pagehttps://launchpad.net/lazr.uri
SummaryA self-contained, easily reusable library for parsing, manipulating,
upload_time2021-09-13 15:42:36
maintainerLAZR Developers
docs_urlNone
author
requires_python
licenseLGPL v3
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ..
    This file is part of lazr.uri.

    lazr.uri is free software: you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, version 3 of the License.

    lazr.uri is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
    License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with lazr.uri.  If not, see <http://www.gnu.org/licenses/>.

lazr.uri
********

The lazr.uri package includes code for parsing and dealing with URIs.

    >>> import lazr.uri
    >>> print('VERSION:', lazr.uri.__version__)
    VERSION: ...

=============
The URI class
=============

    >>> from lazr.uri import URI
    >>> uri1 = URI('http://localhost/foo/bar?123')
    >>> uri2 = URI('http://localhost/foo/bar/baz')
    >>> uri1.contains(uri2)
    True

These next two are equivalent, so the answer should be True, even through
the "outside" one is shorter than the "inside" one.

    >>> uri1 = URI('http://localhost/foo/bar/')
    >>> uri2 = URI('http://localhost/foo/bar')
    >>> uri1.contains(uri2)
    True

The next two are exactly the same.  We consider a url to be inside itself.

    >>> uri1 = URI('http://localhost/foo/bar/')
    >>> uri2 = URI('http://localhost/foo/bar/')
    >>> uri1.contains(uri2)
    True

In the next case, the string of url2 starts with the string of url1.  But,
because url2 continues within the same path step, url2 is not inside url1.

    >>> uri1 = URI('http://localhost/foo/ba')
    >>> uri2 = URI('http://localhost/foo/bar')
    >>> uri1.contains(uri2)
    False

Here, url2 is url1 plus an extra path step.  So, url2 is inside url1.

    >>> uri1 = URI('http://localhost/foo/bar/')
    >>> uri2 = URI('http://localhost/foo/bar/baz')
    >>> uri1.contains(uri2)
    True

Once the URI is parsed, its parts are accessible.

    >>> uri = URI('https://fish.tree:8666/blee/blah')
    >>> uri.scheme
    'https'
    >>> uri.host
    'fish.tree'
    >>> uri.port
    '8666'
    >>> uri.authority
    'fish.tree:8666'
    >>> uri.path
    '/blee/blah'

    >>> uri = URI('https://localhost/blee/blah')
    >>> uri.scheme
    'https'
    >>> uri.host
    'localhost'
    >>> uri.port is None
    True
    >>> uri.authority
    'localhost'
    >>> uri.path
    '/blee/blah'

The grammar from RFC 3986 does not allow for square brackets in the
query component, but Section 3.4 does say how such delimeter
characters should be handled if found in the component.

    >>> uri = URI('http://www.apple.com/store?delivery=[slow]#horse+cart')
    >>> uri.scheme
    'http'
    >>> uri.host
    'www.apple.com'
    >>> uri.port is None
    True
    >>> uri.path
    '/store'
    >>> uri.query
    'delivery=[slow]'
    >>> uri.fragment
    'horse+cart'

====================
Finding URIs in Text
====================

lazr.uri also knows how to retrieve a list of URIs from a block of
text.  This is intended for uses like finding bug tracker URIs or
similar.

The find_uris_in_text() function returns an iterator that yields URI
objects for each URI found in the text.  Note that the returned URIs
have been canonicalised by the URI class:

  >>> from lazr.uri import find_uris_in_text
  >>> text = '''
  ... A list of URIs:
  ...  * http://localhost/a/b
  ...  * http://launchpad.net
  ...  * MAILTO:joe@example.com
  ...  * xmpp:fred@example.org
  ...  * http://bazaar.launchpad.net/%7ename12/firefox/foo
  ...  * http://somewhere.in/time?track=[02]#wasted-years
  ... '''

  >>> for uri in find_uris_in_text(text):
  ...     print(uri)
  http://localhost/a/b
  http://launchpad.net/
  mailto:joe@example.com
  xmpp:fred@example.org
  http://bazaar.launchpad.net/~name12/firefox/foo
  http://somewhere.in/time?track=[02]#wasted-years


=================
NEWS for lazr.uri
=================

1.0.6 (2021-09-13)
==================

- Adjust versioning strategy to avoid importing pkg_resources, which is slow
  in large environments.

1.0.5 (2020-06-29)
==================

- Add an explicit __hash__ method to lazr.uri.URI.

1.0.4 (2020-06-12)
==================

- Install version.txt with package_data (Stefano Rivera,
  https://bugs.launchpad.net/lazr.uri/+bug/918660).
- Switch from buildout to tox.

1.0.3 (2012-01-18)
==================

- Add compatibility with Python 3 (Thomas Kluyver).

1.0.1 (2009-06-01)
==================

- Eliminate dependency on setuptools_bzr so sdists do not bring bzr ini, among
  others.

1.0 (2009-03-23)
================

- Initial release on PyPI
            

Raw data

            {
    "_id": null,
    "home_page": "https://launchpad.net/lazr.uri",
    "name": "lazr.uri",
    "maintainer": "LAZR Developers",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "lazr-developers@lists.launchpad.net",
    "keywords": "",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/a6/db/310eaccd3639f5a8a6011c3133bb1cac7fd80bb46f8a50406df2966302e4/lazr.uri-1.0.6.tar.gz",
    "platform": "",
    "description": "..\n    This file is part of lazr.uri.\n\n    lazr.uri is free software: you can redistribute it and/or modify it\n    under the terms of the GNU Lesser General Public License as published by\n    the Free Software Foundation, version 3 of the License.\n\n    lazr.uri is distributed in the hope that it will be useful, but\n    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public\n    License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with lazr.uri.  If not, see <http://www.gnu.org/licenses/>.\n\nlazr.uri\n********\n\nThe lazr.uri package includes code for parsing and dealing with URIs.\n\n    >>> import lazr.uri\n    >>> print('VERSION:', lazr.uri.__version__)\n    VERSION: ...\n\n=============\nThe URI class\n=============\n\n    >>> from lazr.uri import URI\n    >>> uri1 = URI('http://localhost/foo/bar?123')\n    >>> uri2 = URI('http://localhost/foo/bar/baz')\n    >>> uri1.contains(uri2)\n    True\n\nThese next two are equivalent, so the answer should be True, even through\nthe \"outside\" one is shorter than the \"inside\" one.\n\n    >>> uri1 = URI('http://localhost/foo/bar/')\n    >>> uri2 = URI('http://localhost/foo/bar')\n    >>> uri1.contains(uri2)\n    True\n\nThe next two are exactly the same.  We consider a url to be inside itself.\n\n    >>> uri1 = URI('http://localhost/foo/bar/')\n    >>> uri2 = URI('http://localhost/foo/bar/')\n    >>> uri1.contains(uri2)\n    True\n\nIn the next case, the string of url2 starts with the string of url1.  But,\nbecause url2 continues within the same path step, url2 is not inside url1.\n\n    >>> uri1 = URI('http://localhost/foo/ba')\n    >>> uri2 = URI('http://localhost/foo/bar')\n    >>> uri1.contains(uri2)\n    False\n\nHere, url2 is url1 plus an extra path step.  So, url2 is inside url1.\n\n    >>> uri1 = URI('http://localhost/foo/bar/')\n    >>> uri2 = URI('http://localhost/foo/bar/baz')\n    >>> uri1.contains(uri2)\n    True\n\nOnce the URI is parsed, its parts are accessible.\n\n    >>> uri = URI('https://fish.tree:8666/blee/blah')\n    >>> uri.scheme\n    'https'\n    >>> uri.host\n    'fish.tree'\n    >>> uri.port\n    '8666'\n    >>> uri.authority\n    'fish.tree:8666'\n    >>> uri.path\n    '/blee/blah'\n\n    >>> uri = URI('https://localhost/blee/blah')\n    >>> uri.scheme\n    'https'\n    >>> uri.host\n    'localhost'\n    >>> uri.port is None\n    True\n    >>> uri.authority\n    'localhost'\n    >>> uri.path\n    '/blee/blah'\n\nThe grammar from RFC 3986 does not allow for square brackets in the\nquery component, but Section 3.4 does say how such delimeter\ncharacters should be handled if found in the component.\n\n    >>> uri = URI('http://www.apple.com/store?delivery=[slow]#horse+cart')\n    >>> uri.scheme\n    'http'\n    >>> uri.host\n    'www.apple.com'\n    >>> uri.port is None\n    True\n    >>> uri.path\n    '/store'\n    >>> uri.query\n    'delivery=[slow]'\n    >>> uri.fragment\n    'horse+cart'\n\n====================\nFinding URIs in Text\n====================\n\nlazr.uri also knows how to retrieve a list of URIs from a block of\ntext.  This is intended for uses like finding bug tracker URIs or\nsimilar.\n\nThe find_uris_in_text() function returns an iterator that yields URI\nobjects for each URI found in the text.  Note that the returned URIs\nhave been canonicalised by the URI class:\n\n  >>> from lazr.uri import find_uris_in_text\n  >>> text = '''\n  ... A list of URIs:\n  ...  * http://localhost/a/b\n  ...  * http://launchpad.net\n  ...  * MAILTO:joe@example.com\n  ...  * xmpp:fred@example.org\n  ...  * http://bazaar.launchpad.net/%7ename12/firefox/foo\n  ...  * http://somewhere.in/time?track=[02]#wasted-years\n  ... '''\n\n  >>> for uri in find_uris_in_text(text):\n  ...     print(uri)\n  http://localhost/a/b\n  http://launchpad.net/\n  mailto:joe@example.com\n  xmpp:fred@example.org\n  http://bazaar.launchpad.net/~name12/firefox/foo\n  http://somewhere.in/time?track=[02]#wasted-years\n\n\n=================\nNEWS for lazr.uri\n=================\n\n1.0.6 (2021-09-13)\n==================\n\n- Adjust versioning strategy to avoid importing pkg_resources, which is slow\n  in large environments.\n\n1.0.5 (2020-06-29)\n==================\n\n- Add an explicit __hash__ method to lazr.uri.URI.\n\n1.0.4 (2020-06-12)\n==================\n\n- Install version.txt with package_data (Stefano Rivera,\n  https://bugs.launchpad.net/lazr.uri/+bug/918660).\n- Switch from buildout to tox.\n\n1.0.3 (2012-01-18)\n==================\n\n- Add compatibility with Python 3 (Thomas Kluyver).\n\n1.0.1 (2009-06-01)\n==================\n\n- Eliminate dependency on setuptools_bzr so sdists do not bring bzr ini, among\n  others.\n\n1.0 (2009-03-23)\n================\n\n- Initial release on PyPI",
    "bugtrack_url": null,
    "license": "LGPL v3",
    "summary": "A self-contained, easily reusable library for parsing, manipulating,",
    "version": "1.0.6",
    "project_urls": {
        "Download": "https://launchpad.net/lazr.uri/+download",
        "Homepage": "https://launchpad.net/lazr.uri"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a6db310eaccd3639f5a8a6011c3133bb1cac7fd80bb46f8a50406df2966302e4",
                "md5": "44c032bb0c78a6f249b8ae4b64bd6b4f",
                "sha256": "5026853fcbf6f91d5a6b11ea7860a641fe27b36d4172c731f4aa16b900cf8464"
            },
            "downloads": -1,
            "filename": "lazr.uri-1.0.6.tar.gz",
            "has_sig": true,
            "md5_digest": "44c032bb0c78a6f249b8ae4b64bd6b4f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 18213,
            "upload_time": "2021-09-13T15:42:36",
            "upload_time_iso_8601": "2021-09-13T15:42:36.075014Z",
            "url": "https://files.pythonhosted.org/packages/a6/db/310eaccd3639f5a8a6011c3133bb1cac7fd80bb46f8a50406df2966302e4/lazr.uri-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-09-13 15:42:36",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "lazr.uri"
}
        
Elapsed time: 0.09455s