Skip to main content

The library makes parsing and manipulation of URL🌐 and Email address📧 easy.

Project description

netcleanser

The library makes parsing and manipulation of URL🌐 and Email address📧 easy.

ci license release python-version pypi

Install

pip install netcleanser

How to use

Email

>>> from netcleanser import Email
>>> email = Email('shinichi.takayanagi@gmail.com')
>>> email.domain
'gmail.com'
>>> email.local_part
'shinichi.takayanagi'
>>> email.is_valid
True
>>> email.value
'shinichi.takayanagi@gmail.com'

This Email class is settable and dictable

# As a dict key
>>> x = {email: 1}
>>> x[email]
1
# As elemtns of set
>>> email2 = Email("nakamichiworks@gmail.com")
>>> {email, email, email, email2, email2}
{Email(value='nakamichiworks@gmail.com)', Email(value='shinichi.takayanagi@gmail.com)'}

Email.build() allows you to create dummy email address specifing the only part of local_part or domain

>>> Email.build(local_part = "hoge")
Email(value='hoge@dummy.com)'
>>> Email.build(domain = "hoge.com")
Email(value='dummy@hoge.com)'

Url

>>> from netcleanser import Url
>>> url = Url('https://www.google.com/search?q=auhuhe')
>>> url.scheme
'https'
>>> url.host
'www.google.com'
>>> url.domain
'www.google.com'
>>> url.registered_domain
'google.com'
>>> url.netloc
'www.google.com'
>>> url.path
'/search'
>>> url.query
'q=auhuhe'
>>> url.is_valid
True
>>> url.is_accessible
True
>>> url.value
'https://www.google.com/search?q=auhuhe'
>>> str(url)
'https://www.google.com/search?q=auhuhe'
>>> url.contains_www
True
>>> url.remove_query()
Url(host='www.google.com', username='None', password='None', scheme='https', port='None', path='/search', query='', fragment='')
>>> url.remove_www()
Url(host='google.com', username='None', password='None', scheme='https', port='None', path='/search', query='q=auhuhe', fragment='')

This Url class is settable and dictable

>>> x = {url: 123}
>>> x[Url('https://www.google.com/search?q=auhuhe')]
123
>>> {url, url, Url('https://google.com'), url}
{Url(host='www.google.com', username='None', password='None', scheme='https', port='None', path='/search', query='q=auhuhe', fragment=''), Url(host='google.com', username='None', password='None', scheme='https', port='None', path='', query='', fragment='')}

Thanks

Url class strongly depends on awesome purl package, thanks!

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

netcleanser-0.2.3.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

netcleanser-0.2.3-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file netcleanser-0.2.3.tar.gz.

File metadata

  • Download URL: netcleanser-0.2.3.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.0 Darwin/19.6.0

File hashes

Hashes for netcleanser-0.2.3.tar.gz
Algorithm Hash digest
SHA256 c35579112eeef0482993545b68c47ce8a00f5e56d9e15cf75069ebfb59dc71c3
MD5 7749800c3f4dd8c6a09657d81cb1bcfa
BLAKE2b-256 da48494f45da8374c34dea6c3cabefca7347c5b159c898221c42fbc06f30c821

See more details on using hashes here.

File details

Details for the file netcleanser-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: netcleanser-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.0 Darwin/19.6.0

File hashes

Hashes for netcleanser-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2d35f11000b1e73a3ca5460a883c6e2ff8e076ecf0f9e9a6e93a5e8c323ea93a
MD5 6f4dbeb902653df07f9ab20450f471db
BLAKE2b-256 5447a1fe93f83857dec7efcd7a84b0eff0fea4e1d6363e79f68b89f0bf0de799

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page