domain-name-label-indexes


Namedomain-name-label-indexes JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/ralexander-phi/domain_name_label_indexes
SummaryComputing a domain name by it's index
upload_time2022-12-26 13:01:40
maintainer
docs_urlNone
authorRobert Alexander
requires_python>=3.6
licenseMIT license
keywords domain_name_label_indexes
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =========================
Domain Name Label Indexes
=========================


.. image:: https://img.shields.io/pypi/v/domain_name_label_indexes.svg
        :target: https://pypi.python.org/pypi/domain_name_label_indexes

.. image:: https://img.shields.io/travis/ralexander-phi/domain_name_label_indexes.svg
        :target: https://travis-ci.com/ralexander-phi/domain_name_label_indexes

.. image:: https://readthedocs.org/projects/domain-name-label-indexes/badge/?version=latest
        :target: https://domain-name-label-indexes.readthedocs.io/en/latest/?version=latest
        :alt: 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.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ralexander-phi/domain_name_label_indexes",
    "name": "domain-name-label-indexes",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "domain_name_label_indexes",
    "author": "Robert Alexander",
    "author_email": "raalexander.phi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/23/0f/405332a8431b80a172db1466cac65b173ea4eb421b07814bf9a1b4db0c21/domain_name_label_indexes-0.1.1.tar.gz",
    "platform": null,
    "description": "=========================\nDomain Name Label Indexes\n=========================\n\n\n.. image:: https://img.shields.io/pypi/v/domain_name_label_indexes.svg\n        :target: https://pypi.python.org/pypi/domain_name_label_indexes\n\n.. image:: https://img.shields.io/travis/ralexander-phi/domain_name_label_indexes.svg\n        :target: https://travis-ci.com/ralexander-phi/domain_name_label_indexes\n\n.. image:: https://readthedocs.org/projects/domain-name-label-indexes/badge/?version=latest\n        :target: https://domain-name-label-indexes.readthedocs.io/en/latest/?version=latest\n        :alt: Documentation Status\n\nThis library helps generate minimal domain name labels in an ordered fashion.\nThe following rules apply:\n\n* The label can contain only 0-9, a-z, and hyphen (-)\n* The label cannot begin or end with a hyphen\n* The label cannot contain two hyphens in a row\n* The label must be between 1 and 63 characters long\n\nNote:\n\n* Unicode / Punycode are not considered (I.E., domains starting with `xn--` will not be generated).\n* Binary labels are not considered\n\nSpecifically, this library defines an ordering to domains such that they may be looked up by index.\nDomains are orders such that shorter domains occur earlier and domains of the same length occur in sorted order.\nThe ordering begins as:\n\n    0    -> \"0\"\n\n    1    -> \"1\"\n\n    ...\n\n    10   -> \"a\"\n\n    ...\n\n    35   -> \"z\"\n\n    36   -> \"00\"\n\n    ...\n\n    72   -> \"10\"\n\n    ...\n\n    1331 -> \"zz\"\n\n    1332 -> \"0-0\"\n\n* Free software: MIT license\n\n\nFeatures\n--------\n\n\nGiven an index, compute the corresposing domain name.\n\n    generate_domain_name_label(index: int)\n\nFor example:\n\n    generate_domain_name_label(0) => \"0\"\n\n    generate_domain_name_label(37) => \"01\"\n\n\n\nGiven an index, compute the length of the domain name.\n\n    compute_domain_length(index: int)\n\nFor example:\n\n    compute_domain_length(0) => 1\n\n    compute_domain_length(36) => 2\n\n\nFind the first index that produces a domain of a given length.\n\n    first_index_with_domain_length(length: int)\n\nFor example:\n\n    first_index_with_domain_length(1) => 0\n\n    first_index_with_domain_length(2) => 36\n\n\n\nCompute the number of domains that have a given length.\n\n    count_domains_with_length(length: int)\n\nFor example:\n\n    count_domains_with_length(1) => 36\n\n    count_domains_with_length(2) => 1296\n\nCompute the index for a domain name label.\n\n    index_of_domain_name_label(label: str)\n\nFor example:\n\n    index_of_domain_name_label(\"google\") => 1191294986\n\n    index_of_domain_name_label(\"yahoo\")  =>   64297428\n\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n",
    "bugtrack_url": null,
    "license": "MIT license",
    "summary": "Computing a domain name by it's index",
    "version": "0.1.1",
    "split_keywords": [
        "domain_name_label_indexes"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "e4844134e21c025097bdfad8f3432e67",
                "sha256": "c693bcb968c5f24c786a66a03294aba0ae486bc8e30ae2102cf47fdeac9b90f3"
            },
            "downloads": -1,
            "filename": "domain_name_label_indexes-0.1.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e4844134e21c025097bdfad8f3432e67",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 5043,
            "upload_time": "2022-12-26T13:01:37",
            "upload_time_iso_8601": "2022-12-26T13:01:37.991993Z",
            "url": "https://files.pythonhosted.org/packages/fb/20/8c15f023a5f7fecf966c860b68499d8a95dd15ec78f31498392ee50c6f9a/domain_name_label_indexes-0.1.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "de74f70d263e4d47def49fcfda0a9c74",
                "sha256": "8497d191a93f0679107af4faa6308fd84cfdc7b5ecd3bef65963ae3b9f71ce6a"
            },
            "downloads": -1,
            "filename": "domain_name_label_indexes-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "de74f70d263e4d47def49fcfda0a9c74",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 7144,
            "upload_time": "2022-12-26T13:01:40",
            "upload_time_iso_8601": "2022-12-26T13:01:40.389850Z",
            "url": "https://files.pythonhosted.org/packages/23/0f/405332a8431b80a172db1466cac65b173ea4eb421b07814bf9a1b4db0c21/domain_name_label_indexes-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-26 13:01:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ralexander-phi",
    "github_project": "domain_name_label_indexes",
    "lcname": "domain-name-label-indexes"
}
        
Elapsed time: 0.05961s