Skip to main content

Computing a domain name by it's index

Project description

https://img.shields.io/pypi/v/domain_name_label_indexes.svg https://img.shields.io/travis/ralexander-phi/domain_name_label_indexes.svg Documentation Status

This library helps generate minimal domain name labels in an ordered fashion. The following rules apply:

  • The label can contain only 0-9, a-z, and hyphen (-)

  • The label cannot begin or end with a hyphen

  • The label cannot contain two hyphens in a row

  • The label must be between 1 and 63 characters long

Note:

  • Unicode / Punycode are not considered (I.E., domains starting with xn– will not be generated).

  • Binary labels are not considered

Specifically, this library defines an ordering to domains such that they may be looked up by index. Domains are orders such that shorter domains occur earlier and domains of the same length occur in sorted order. The ordering begins as:

0 -> “0”

1 -> “1”

10 -> “a”

35 -> “z”

36 -> “00”

72 -> “10”

1331 -> “zz”

1332 -> “0-0”

  • Free software: MIT license

Features

Given an index, compute the corresposing domain name.

generate_domain_name_label(index: int)

For example:

generate_domain_name_label(0) => “0”

generate_domain_name_label(37) => “01”

Given an index, compute the length of the domain name.

compute_domain_length(index: int)

For example:

compute_domain_length(0) => 1

compute_domain_length(36) => 2

Find the first index that produces a domain of a given length.

first_index_with_domain_length(length: int)

For example:

first_index_with_domain_length(1) => 0

first_index_with_domain_length(2) => 36

Compute the number of domains that have a given length.

count_domains_with_length(length: int)

For example:

count_domains_with_length(1) => 36

count_domains_with_length(2) => 1296

Compute the index for a domain name label.

index_of_domain_name_label(label: str)

For example:

index_of_domain_name_label(“google”) => 1191294986

index_of_domain_name_label(“yahoo”) => 64297428

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

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

domain_name_label_indexes-0.1.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

domain_name_label_indexes-0.1.1-py2.py3-none-any.whl (5.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file domain_name_label_indexes-0.1.1.tar.gz.

File metadata

  • Download URL: domain_name_label_indexes-0.1.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.9.2 requests/2.28.1 setuptools/44.1.1 requests-toolbelt/0.10.1 tqdm/4.64.1 CPython/3.9.2

File hashes

Hashes for domain_name_label_indexes-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8497d191a93f0679107af4faa6308fd84cfdc7b5ecd3bef65963ae3b9f71ce6a
MD5 de74f70d263e4d47def49fcfda0a9c74
BLAKE2b-256 230f405332a8431b80a172db1466cac65b173ea4eb421b07814bf9a1b4db0c21

See more details on using hashes here.

File details

Details for the file domain_name_label_indexes-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: domain_name_label_indexes-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.9.2 requests/2.28.1 setuptools/44.1.1 requests-toolbelt/0.10.1 tqdm/4.64.1 CPython/3.9.2

File hashes

Hashes for domain_name_label_indexes-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c693bcb968c5f24c786a66a03294aba0ae486bc8e30ae2102cf47fdeac9b90f3
MD5 e4844134e21c025097bdfad8f3432e67
BLAKE2b-256 fb208c15f023a5f7fecf966c860b68499d8a95dd15ec78f31498392ee50c6f9a

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