# PyURI
[![Build Status](https://travis-ci.org/nick-allen/pyuri.svg?branch=master)](https://travis-ci.org/nick-allen/pyuri)
[![Coverage Status](https://coveralls.io/repos/github/nick-allen/pyuri/badge.svg?branch=master)](https://coveralls.io/github/nick-allen/pyuri?branch=master)
[![PyPI version](https://badge.fury.io/py/pyuri.svg)](https://badge.fury.io/py/pyuri)
Better URI handling
Tested with Python 2.7 and 3.6
---
## Install
`pip install pyuri`
## Usage
Raw URI string parsing:
```python
from pyuri import URI
uri = URI('http://localhost:80/path/to/file?query=value#/fragment/path')
assert uri.scheme == 'http'
assert uri.host == 'localhost'
assert uri.port == 80
assert uri.path == '/path/to/file'
assert uri.query == 'query=value'
assert uri.fragment == '/fragment/path'
```
Composition by parts
```python
from pyuri import URI
uri = URI(scheme='ftp', host='localhost', port=8000, query='key=value')
assert str(uri) == 'ftp://localhost:8000?key=value'
```
Modification and comparison
```python
from pyuri import URI
uri1 = URI('https://example.com:80')
uri2 = URI('https://example.com:443/new/path')
assert uri1 != uri2
uri1.port = 443
uri1.path = '/new/path'
assert str(uri1) == 'https://example.com:443/new/path'
assert uri1 == uri2
```
Additional helpers
```python
from pyuri import URI
uri = URI('http://localhost:80/path/to/file?repeat=value1&repeat=value2&escape=escaped%20value#/fragment/path')
# Access query parameters as dictionary
assert uri.query_dict() == {
'repeat': ['value1', 'value2'],
'escape': ['escaped value']
}
```
Raw data
{
"_id": null,
"home_page": "https://github.com/nick-allen/pyuri",
"name": "pyuri",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Nick Allen",
"author_email": "nick.allen.cse@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/60/d0/d86b0a2588ca66e9b25bdfe6b8193600fb7f8cf7472cc79d689552d1a27f/pyuri-0.3.1.tar.gz",
"platform": "UNKNOWN",
"description": "# PyURI\n\n[![Build Status](https://travis-ci.org/nick-allen/pyuri.svg?branch=master)](https://travis-ci.org/nick-allen/pyuri)\n[![Coverage Status](https://coveralls.io/repos/github/nick-allen/pyuri/badge.svg?branch=master)](https://coveralls.io/github/nick-allen/pyuri?branch=master)\n[![PyPI version](https://badge.fury.io/py/pyuri.svg)](https://badge.fury.io/py/pyuri)\n\nBetter URI handling\n\nTested with Python 2.7 and 3.6\n\n---\n\n## Install\n\n`pip install pyuri`\n\n## Usage\n\nRaw URI string parsing:\n\n```python\nfrom pyuri import URI\n\nuri = URI('http://localhost:80/path/to/file?query=value#/fragment/path')\n\nassert uri.scheme == 'http'\nassert uri.host == 'localhost'\nassert uri.port == 80\nassert uri.path == '/path/to/file'\nassert uri.query == 'query=value'\nassert uri.fragment == '/fragment/path'\n```\n\nComposition by parts\n\n```python\nfrom pyuri import URI\n\nuri = URI(scheme='ftp', host='localhost', port=8000, query='key=value')\n\nassert str(uri) == 'ftp://localhost:8000?key=value'\n```\n\nModification and comparison\n\n```python\nfrom pyuri import URI\n\nuri1 = URI('https://example.com:80')\nuri2 = URI('https://example.com:443/new/path')\n\nassert uri1 != uri2\n\nuri1.port = 443\nuri1.path = '/new/path'\n\nassert str(uri1) == 'https://example.com:443/new/path'\n\nassert uri1 == uri2\n```\n\nAdditional helpers\n\n```python\nfrom pyuri import URI\n\nuri = URI('http://localhost:80/path/to/file?repeat=value1&repeat=value2&escape=escaped%20value#/fragment/path')\n\n# Access query parameters as dictionary\nassert uri.query_dict() == {\n 'repeat': ['value1', 'value2'],\n 'escape': ['escaped value']\n}\n```",
"bugtrack_url": null,
"license": "MIT",
"summary": "Better URI Handling",
"version": "0.3.1",
"project_urls": {
"Homepage": "https://github.com/nick-allen/pyuri"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d796633b4e8e8cf5367eb702c3b07c8c6d352e7697f99a73e6aa00c85fb0e51e",
"md5": "dc9ad4b73c5637b9f762c3f94f73fcdc",
"sha256": "0db8582a7580fa675108dd48f16af0988ee2598a18e80df803ce06909bd842c6"
},
"downloads": -1,
"filename": "pyuri-0.3.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "dc9ad4b73c5637b9f762c3f94f73fcdc",
"packagetype": "bdist_wheel",
"python_version": "3.6",
"requires_python": null,
"size": 6194,
"upload_time": "2017-03-27T17:48:27",
"upload_time_iso_8601": "2017-03-27T17:48:27.769063Z",
"url": "https://files.pythonhosted.org/packages/d7/96/633b4e8e8cf5367eb702c3b07c8c6d352e7697f99a73e6aa00c85fb0e51e/pyuri-0.3.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "60d0d86b0a2588ca66e9b25bdfe6b8193600fb7f8cf7472cc79d689552d1a27f",
"md5": "16935b50a6432c62334a92e9aaac1dcd",
"sha256": "dc691e7a13aab7664eff1912760c3a53e2acc77f2e5bc4ef46560265ebab7430"
},
"downloads": -1,
"filename": "pyuri-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "16935b50a6432c62334a92e9aaac1dcd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7106,
"upload_time": "2017-03-27T17:47:00",
"upload_time_iso_8601": "2017-03-27T17:47:00.111568Z",
"url": "https://files.pythonhosted.org/packages/60/d0/d86b0a2588ca66e9b25bdfe6b8193600fb7f8cf7472cc79d689552d1a27f/pyuri-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2017-03-27 17:47:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nick-allen",
"github_project": "pyuri",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "pyuri"
}