initial commit

This commit is contained in:
Davidson Gomes
2024-10-30 11:19:09 -03:00
commit 8654a31a4d
3744 changed files with 585542 additions and 0 deletions

View File

@@ -0,0 +1 @@
pip

View File

@@ -0,0 +1,13 @@
Copyright 2014 Ian Cordasco, Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,234 @@
Metadata-Version: 2.1
Name: rfc3986
Version: 2.0.0
Summary: Validating URI References per RFC 3986
Home-page: http://rfc3986.readthedocs.io
Author: Ian Stapleton Cordasco
Author-email: graffatcolmingov@gmail.com
License: Apache 2.0
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
License-File: LICENSE
Provides-Extra: idna2008
Requires-Dist: idna ; extra == 'idna2008'
rfc3986
=======
A Python implementation of `RFC 3986`_ including validation and authority
parsing.
Installation
------------
Use pip to install ``rfc3986`` like so::
pip install rfc3986
License
-------
`Apache License Version 2.0`_
Example Usage
-------------
The following are the two most common use cases envisioned for ``rfc3986``.
Replacing ``urlparse``
``````````````````````
To parse a URI and receive something very similar to the standard library's
``urllib.parse.urlparse``
.. code-block:: python
from rfc3986 import urlparse
ssh = urlparse('ssh://user@git.openstack.org:29418/openstack/glance.git')
print(ssh.scheme) # => ssh
print(ssh.userinfo) # => user
print(ssh.params) # => None
print(ssh.port) # => 29418
To create a copy of it with new pieces you can use ``copy_with``:
.. code-block:: python
new_ssh = ssh.copy_with(
scheme='https'
userinfo='',
port=443,
path='/openstack/glance'
)
print(new_ssh.scheme) # => https
print(new_ssh.userinfo) # => None
# etc.
Strictly Parsing a URI and Applying Validation
``````````````````````````````````````````````
To parse a URI into a convenient named tuple, you can simply:
.. code-block:: python
from rfc3986 import uri_reference
example = uri_reference('http://example.com')
email = uri_reference('mailto:user@domain.com')
ssh = uri_reference('ssh://user@git.openstack.org:29418/openstack/keystone.git')
With a parsed URI you can access data about the components:
.. code-block:: python
print(example.scheme) # => http
print(email.path) # => user@domain.com
print(ssh.userinfo) # => user
print(ssh.host) # => git.openstack.org
print(ssh.port) # => 29418
It can also parse URIs with unicode present:
.. code-block:: python
uni = uri_reference(b'http://httpbin.org/get?utf8=\xe2\x98\x83') # ☃
print(uni.query) # utf8=%E2%98%83
With a parsed URI you can also validate it:
.. code-block:: python
if ssh.is_valid():
subprocess.call(['git', 'clone', ssh.unsplit()])
You can also take a parsed URI and normalize it:
.. code-block:: python
mangled = uri_reference('hTTp://exAMPLe.COM')
print(mangled.scheme) # => hTTp
print(mangled.authority) # => exAMPLe.COM
normal = mangled.normalize()
print(normal.scheme) # => http
print(mangled.authority) # => example.com
But these two URIs are (functionally) equivalent:
.. code-block:: python
if normal == mangled:
webbrowser.open(normal.unsplit())
Your paths, queries, and fragments are safe with us though:
.. code-block:: python
mangled = uri_reference('hTTp://exAMPLe.COM/Some/reallY/biZZare/pAth')
normal = mangled.normalize()
assert normal == 'hTTp://exAMPLe.COM/Some/reallY/biZZare/pAth'
assert normal == 'http://example.com/Some/reallY/biZZare/pAth'
assert normal != 'http://example.com/some/really/bizzare/path'
If you do not actually need a real reference object and just want to normalize
your URI:
.. code-block:: python
from rfc3986 import normalize_uri
assert (normalize_uri('hTTp://exAMPLe.COM/Some/reallY/biZZare/pAth') ==
'http://example.com/Some/reallY/biZZare/pAth')
You can also very simply validate a URI:
.. code-block:: python
from rfc3986 import is_valid_uri
assert is_valid_uri('hTTp://exAMPLe.COM/Some/reallY/biZZare/pAth')
Requiring Components
~~~~~~~~~~~~~~~~~~~~
You can validate that a particular string is a valid URI and require
independent components:
.. code-block:: python
from rfc3986 import is_valid_uri
assert is_valid_uri('http://localhost:8774/v2/resource',
require_scheme=True,
require_authority=True,
require_path=True)
# Assert that a mailto URI is invalid if you require an authority
# component
assert is_valid_uri('mailto:user@example.com', require_authority=True) is False
If you have an instance of a ``URIReference``, you can pass the same arguments
to ``URIReference#is_valid``, e.g.,
.. code-block:: python
from rfc3986 import uri_reference
http = uri_reference('http://localhost:8774/v2/resource')
assert uri.is_valid(require_scheme=True,
require_authority=True,
require_path=True)
# Assert that a mailto URI is invalid if you require an authority
# component
mailto = uri_reference('mailto:user@example.com')
assert uri.is_valid(require_authority=True) is False
Alternatives
------------
- `rfc3987 <https://pypi.python.org/pypi/rfc3987/1.3.4>`_
This is a direct competitor to this library, with extra features,
licensed under the GPL.
- `uritools <https://pypi.python.org/pypi/uritools/0.5.1>`_
This can parse URIs in the manner of RFC 3986 but provides no validation and
only recently added Python 3 support.
- Standard library's `urlparse`/`urllib.parse`
The functions in these libraries can only split a URI (valid or not) and
provide no validation.
Contributing
------------
This project follows and enforces the Python Software Foundation's `Code of
Conduct <https://www.python.org/psf/codeofconduct/>`_.
If you would like to contribute but do not have a bug or feature in mind, feel
free to email Ian and find out how you can help.
The git repository for this project is maintained at
https://github.com/python-hyper/rfc3986
.. _RFC 3986: https://datatracker.ietf.org/doc/html/rfc3986/
.. _Apache License Version 2.0: https://www.apache.org/licenses/LICENSE-2.0

View File

@@ -0,0 +1,32 @@
rfc3986-2.0.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
rfc3986-2.0.0.dist-info/LICENSE,sha256=wN3OM7-sSApmveQMWQ7eJkekyKcp3LDSzkbAFEc9Xdg,564
rfc3986-2.0.0.dist-info/METADATA,sha256=8iAp0pjPLq6lJOaX0GpV840JnMQPsPF17XkDfv_jqM4,6630
rfc3986-2.0.0.dist-info/RECORD,,
rfc3986-2.0.0.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
rfc3986-2.0.0.dist-info/top_level.txt,sha256=Z10Qesb0UV9AbxlTIV9AnOAwk-343WnE85K8xfN4OmA,8
rfc3986/__init__.py,sha256=VtXD-MwjEoc_pNP7rqJVuJ6w3TcJ3Yb244KQa2w-Ooc,1565
rfc3986/__pycache__/__init__.cpython-310.pyc,,
rfc3986/__pycache__/_mixin.cpython-310.pyc,,
rfc3986/__pycache__/abnf_regexp.cpython-310.pyc,,
rfc3986/__pycache__/api.cpython-310.pyc,,
rfc3986/__pycache__/builder.cpython-310.pyc,,
rfc3986/__pycache__/compat.cpython-310.pyc,,
rfc3986/__pycache__/exceptions.cpython-310.pyc,,
rfc3986/__pycache__/iri.cpython-310.pyc,,
rfc3986/__pycache__/misc.cpython-310.pyc,,
rfc3986/__pycache__/normalizers.cpython-310.pyc,,
rfc3986/__pycache__/parseresult.cpython-310.pyc,,
rfc3986/__pycache__/uri.cpython-310.pyc,,
rfc3986/__pycache__/validators.cpython-310.pyc,,
rfc3986/_mixin.py,sha256=85fedVeQZisISFWh7tHQnB9A84RHPRb0C902Wd8hgtk,13297
rfc3986/abnf_regexp.py,sha256=IGFLR6B2x-YaLsz5zWV9HPEAIduESedFgqQVPk_dnTk,9048
rfc3986/api.py,sha256=c7mGh2ljJJevPp082KIUku2nGON170n5FiLrADBeT-A,3862
rfc3986/builder.py,sha256=_o4i-TJ8nOeBg4hPQCjF9dRuFULR0Zeg-3IAXnFaj_U,12709
rfc3986/compat.py,sha256=SQj7DiNC3D0G_Zd7Kjxh1h54g8FxbFz31pXFhvKA8KQ,1620
rfc3986/exceptions.py,sha256=9yvXMuvQRbVwR-v29zpj6cqqcYZxrDzYNKYms_G-BE8,3614
rfc3986/iri.py,sha256=yCALCLjUZEc-IZkxExto-Fxdo-6sAZMD1tchIEwkQZo,5477
rfc3986/misc.py,sha256=jMaNrvvnMTRQEEPF93N2HD-qhVYtXp7g2oiya4tuaHM,4114
rfc3986/normalizers.py,sha256=k4_B4HhuoG0b9Lv2xUyXrFpI-uCKDxyHgQgcG4GTqRM,5261
rfc3986/parseresult.py,sha256=XdYJDXUFuDyL8PVAKGPxKCvlDrYZ5j8vR68ncXXJW2w,14599
rfc3986/uri.py,sha256=c4Xd44p4yFL6P1B4_EYDwhOM5k8OoKHaw2T9D7J3dec,5183
rfc3986/validators.py,sha256=KHqajfy8JMcmHz16sl0WSrWP2Qr_D8PU1827xh6tb7Q,13676

View File

@@ -0,0 +1,6 @@
Wheel-Version: 1.0
Generator: bdist_wheel (0.37.1)
Root-Is-Purelib: true
Tag: py2-none-any
Tag: py3-none-any

View File

@@ -0,0 +1 @@
rfc3986