METADATA 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. Metadata-Version: 2.1
  2. Name: lazr.uri
  3. Version: 1.0.6
  4. Summary: A self-contained, easily reusable library for parsing, manipulating,
  5. Home-page: https://launchpad.net/lazr.uri
  6. Maintainer: LAZR Developers
  7. Maintainer-email: lazr-developers@lists.launchpad.net
  8. License: LGPL v3
  9. Download-URL: https://launchpad.net/lazr.uri/+download
  10. Platform: UNKNOWN
  11. Classifier: Development Status :: 5 - Production/Stable
  12. Classifier: Intended Audience :: Developers
  13. Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
  14. Classifier: Operating System :: OS Independent
  15. Classifier: Programming Language :: Python
  16. Classifier: Programming Language :: Python :: 2
  17. Classifier: Programming Language :: Python :: 2.7
  18. Classifier: Programming Language :: Python :: 3
  19. Classifier: Programming Language :: Python :: 3.5
  20. Classifier: Programming Language :: Python :: 3.6
  21. Classifier: Programming Language :: Python :: 3.7
  22. Classifier: Programming Language :: Python :: 3.8
  23. Description-Content-Type: text/x-rst
  24. Requires-Dist: setuptools
  25. Requires-Dist: importlib-metadata ; python_version < "3.8"
  26. Provides-Extra: docs
  27. Requires-Dist: Sphinx ; extra == 'docs'
  28. Provides-Extra: test
  29. Requires-Dist: zope.testrunner ; extra == 'test'
  30. ..
  31. This file is part of lazr.uri.
  32. lazr.uri is free software: you can redistribute it and/or modify it
  33. under the terms of the GNU Lesser General Public License as published by
  34. the Free Software Foundation, version 3 of the License.
  35. lazr.uri is distributed in the hope that it will be useful, but
  36. WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  37. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  38. License for more details.
  39. You should have received a copy of the GNU Lesser General Public License
  40. along with lazr.uri. If not, see <http://www.gnu.org/licenses/>.
  41. lazr.uri
  42. ********
  43. The lazr.uri package includes code for parsing and dealing with URIs.
  44. >>> import lazr.uri
  45. >>> print('VERSION:', lazr.uri.__version__)
  46. VERSION: ...
  47. =============
  48. The URI class
  49. =============
  50. >>> from lazr.uri import URI
  51. >>> uri1 = URI('http://localhost/foo/bar?123')
  52. >>> uri2 = URI('http://localhost/foo/bar/baz')
  53. >>> uri1.contains(uri2)
  54. True
  55. These next two are equivalent, so the answer should be True, even through
  56. the "outside" one is shorter than the "inside" one.
  57. >>> uri1 = URI('http://localhost/foo/bar/')
  58. >>> uri2 = URI('http://localhost/foo/bar')
  59. >>> uri1.contains(uri2)
  60. True
  61. The next two are exactly the same. We consider a url to be inside itself.
  62. >>> uri1 = URI('http://localhost/foo/bar/')
  63. >>> uri2 = URI('http://localhost/foo/bar/')
  64. >>> uri1.contains(uri2)
  65. True
  66. In the next case, the string of url2 starts with the string of url1. But,
  67. because url2 continues within the same path step, url2 is not inside url1.
  68. >>> uri1 = URI('http://localhost/foo/ba')
  69. >>> uri2 = URI('http://localhost/foo/bar')
  70. >>> uri1.contains(uri2)
  71. False
  72. Here, url2 is url1 plus an extra path step. So, url2 is inside url1.
  73. >>> uri1 = URI('http://localhost/foo/bar/')
  74. >>> uri2 = URI('http://localhost/foo/bar/baz')
  75. >>> uri1.contains(uri2)
  76. True
  77. Once the URI is parsed, its parts are accessible.
  78. >>> uri = URI('https://fish.tree:8666/blee/blah')
  79. >>> uri.scheme
  80. 'https'
  81. >>> uri.host
  82. 'fish.tree'
  83. >>> uri.port
  84. '8666'
  85. >>> uri.authority
  86. 'fish.tree:8666'
  87. >>> uri.path
  88. '/blee/blah'
  89. >>> uri = URI('https://localhost/blee/blah')
  90. >>> uri.scheme
  91. 'https'
  92. >>> uri.host
  93. 'localhost'
  94. >>> uri.port is None
  95. True
  96. >>> uri.authority
  97. 'localhost'
  98. >>> uri.path
  99. '/blee/blah'
  100. The grammar from RFC 3986 does not allow for square brackets in the
  101. query component, but Section 3.4 does say how such delimeter
  102. characters should be handled if found in the component.
  103. >>> uri = URI('http://www.apple.com/store?delivery=[slow]#horse+cart')
  104. >>> uri.scheme
  105. 'http'
  106. >>> uri.host
  107. 'www.apple.com'
  108. >>> uri.port is None
  109. True
  110. >>> uri.path
  111. '/store'
  112. >>> uri.query
  113. 'delivery=[slow]'
  114. >>> uri.fragment
  115. 'horse+cart'
  116. ====================
  117. Finding URIs in Text
  118. ====================
  119. lazr.uri also knows how to retrieve a list of URIs from a block of
  120. text. This is intended for uses like finding bug tracker URIs or
  121. similar.
  122. The find_uris_in_text() function returns an iterator that yields URI
  123. objects for each URI found in the text. Note that the returned URIs
  124. have been canonicalised by the URI class:
  125. >>> from lazr.uri import find_uris_in_text
  126. >>> text = '''
  127. ... A list of URIs:
  128. ... * http://localhost/a/b
  129. ... * http://launchpad.net
  130. ... * MAILTO:joe@example.com
  131. ... * xmpp:fred@example.org
  132. ... * http://bazaar.launchpad.net/%7ename12/firefox/foo
  133. ... * http://somewhere.in/time?track=[02]#wasted-years
  134. ... '''
  135. >>> for uri in find_uris_in_text(text):
  136. ... print(uri)
  137. http://localhost/a/b
  138. http://launchpad.net/
  139. mailto:joe@example.com
  140. xmpp:fred@example.org
  141. http://bazaar.launchpad.net/~name12/firefox/foo
  142. http://somewhere.in/time?track=[02]#wasted-years
  143. =================
  144. NEWS for lazr.uri
  145. =================
  146. 1.0.6 (2021-09-13)
  147. ==================
  148. - Adjust versioning strategy to avoid importing pkg_resources, which is slow
  149. in large environments.
  150. 1.0.5 (2020-06-29)
  151. ==================
  152. - Add an explicit __hash__ method to lazr.uri.URI.
  153. 1.0.4 (2020-06-12)
  154. ==================
  155. - Install version.txt with package_data (Stefano Rivera,
  156. https://bugs.launchpad.net/lazr.uri/+bug/918660).
  157. - Switch from buildout to tox.
  158. 1.0.3 (2012-01-18)
  159. ==================
  160. - Add compatibility with Python 3 (Thomas Kluyver).
  161. 1.0.1 (2009-06-01)
  162. ==================
  163. - Eliminate dependency on setuptools_bzr so sdists do not bring bzr ini, among
  164. others.
  165. 1.0 (2009-03-23)
  166. ================
  167. - Initial release on PyPI