Url parsing and editing as an object or in a functional style.
Project description
Url parsing and editing as an object or in a functional style.
>>> from urledit import urledit >>> url = 'forum/showthread.php?s=12345&p=728386#post728386'
Functional style
>>> urledit(url)(scheme='http')(netloc='host.com')(fragment='' ... ).param(s=None).param(a=1).param(b=['x', 'y', 'z']).join() 'http://host.com/forum/showthread.php?p=728386&a=1&b=x&b=y&b=z'
or
>>> urledit(url, scheme='http', netloc='host.com', fragment=''
... ).param(('s', None), ('a', 1), b=['x', 'y', 'z']).join()
'http://host.com/forum/showthread.php?p=728386&a=1&b=x&b=y&b=z'
Object style
>>> u = urledit(url) >>> u.scheme, u.netloc, u.path, u.qs, u.fragment ('', '', 'forum/showthread.php', 's=12345&p=728386', 'post728386')>>> u.scheme, u.netloc, u.fragment = 'http', 'host.com', '' >>> u.join() 'http://host.com/forum/showthread.php?s=12345&p=728386'
Working with query string:
>>> u.query == {'p': '728386', 's': '12345'} True>>> del u.query['s'] >>> u.join() 'http://host.com/forum/showthread.php?p=728386'>>> u.query['a'] = 1 >>> u.query['b'] = ['x', 'y', 'z'] >>> u.join() 'http://host.com/forum/showthread.php?p=728386&a=1&b=x&b=y&b=z'
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
urledit-1.1.0.tar.gz
(2.4 kB
view details)
File details
Details for the file urledit-1.1.0.tar.gz.
File metadata
- Download URL: urledit-1.1.0.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
167bec15e2449fca0047d60d40a90451bdbc1f011518723018821cb8b27bb277
|
|
| MD5 |
88fa75c4cad952c50cd1a8778e8e7fd5
|
|
| BLAKE2b-256 |
0ec1311afe00d7278691dec613a83bec53bbd9929e8630488e6d503cabed71c0
|