🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

urledit

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

urledit

Url parsing and editing as an object or in a functional style.

1.1.0
PyPI
Maintainers
1

urledit

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'

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts