pax_global_header00006660000000000000000000000064147073100550014514gustar00rootroot0000000000000052 comment=1e04e1e6f38db08618c29f1bf609c964c0affe44 domain2idna-1.12.2/000077500000000000000000000000001470731005500137645ustar00rootroot00000000000000domain2idna-1.12.2/.ci/000077500000000000000000000000001470731005500144355ustar00rootroot00000000000000domain2idna-1.12.2/.ci/list_of_domain000066400000000000000000000010171470731005500173450ustar00rootroot00000000000000lifehacĸer.com möli.com müller.de teeniemösen.com teenmädchen.com tegelhof-rügen.de # This is a commented line in the middle of nowhere telefonkönig.de tennisschläger-tennissaiten.de tierhäuser.de tinipó.hu trädgårdsväxter.com transenschwänze.com traumfüsse.com türkei-antik.de # This is a commented line with äüéáóṕĺẃéŕźúíóṕáśǵḱĺýćǘnḿ türkenboy.com türkenboys.com türkenmösen.com türkischeboys.com türkischelolita.com zorlasikiş.com züri.ch аррӏе.com 援交.com 短.codomain2idna-1.12.2/.coveragerc000066400000000000000000000013341470731005500161060ustar00rootroot00000000000000[run] branch = False omit = # omit the following directory */pbr/* */site-packages/* /home/travis/virtualenv/* *.eggs/* */distutils/* setup.py [report] skip_covered = False show_missing = True # Regexes for lines to exclude from consideration exclude_lines = # Have to re-enable the standard pragma pragma: no cover # Don't complain about missing debug-only code: def __repr__ if self\.debug # Don't complain if tests don't hit defensive assertion code: raise AssertionError raise NotImplementedError # Don't complain if non-runnable code isn't run: if __name__ == .__main__.: ignore_errors = True fail_under = 70 [html] directory = coverage_html_report domain2idna-1.12.2/.github/000077500000000000000000000000001470731005500153245ustar00rootroot00000000000000domain2idna-1.12.2/.github/FUNDING.yml000066400000000000000000000003621470731005500171420ustar00rootroot00000000000000# These are supported funding model platforms github: [funilrys] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] ko_fi: funilrys # Replace with a single Ko-fi username custom: ["https://www.paypal.me/funilrys"] domain2idna-1.12.2/.github/ISSUE_TEMPLATE/000077500000000000000000000000001470731005500175075ustar00rootroot00000000000000domain2idna-1.12.2/.github/ISSUE_TEMPLATE/00-bug.yml000066400000000000000000000104711470731005500212270ustar00rootroot00000000000000name: Bug Report description: Report a but or issue. title: BUG | My Awesome Bug labels: - bug projects: - funilrys/6 assignees: - funilrys body: - type: markdown attributes: value: |+ Thanks for taking the time to fill out this bug report! Please be patient and rest assured that we will get back to you as soon as possible. To help us understand and reproduce the issue, please provide as much information as possible. If you have a question or need help, please ask in our [Discussions](https://github.com/funilrys/PyFunceble/discussions) section. - type: textarea id: problem attributes: label: What is the problem you are experiencing? description: Please describe the problem you are experiencing. placeholder: | I am experiencing a problem where... value: | I am experiencing a problem where... validations: required: true - type: textarea id: reproduction attributes: label: How can we reproduce the problem? description: Please describe how we can reproduce the problem. placeholder: | To reproduce the problem: 1. 2. 3. 4. value: | To reproduce the problem: 1. 2. 3. 4. validations: required: true - type: textarea id: screenshot attributes: label: Do you have a screenshot? description: | If applicable to the problem, please provide some screenshots to help explain the problem. placeholder: |
Screenshot
value: |
Screenshot
validations: required: false - type: textarea id: expected attributes: label: What did you expect to happen? description: Please describe what you expected to happen. placeholder: | I expected that... value: | I expected that... validations: required: true - type: textarea id: workaround attributes: label: Is there a workaround? description: Please describe if there is a workaround. placeholder: | I found a workaround... value: | I found a workaround... validations: required: false - type: textarea id: configuration attributes: label: How did you configure PyFunceble? description: | Please provide a representation of the non-default configuration you used or the content of your `.PyFunceble.overwrite.yaml` file. placeholder: | ```yaml # .PyFunceble.overwrite.yaml # Your configuration here. ``` value: | ```yaml .PyFunceble.overwrite.yaml # Your configuration here ``` validations: required: false - type: dropdown id: OS attributes: label: Which Operating System did you use? description: | Please select the operating system you used. multiple: true options: - Arch Linux - Debian 12 - Debian 11 - Debian 10 - Ubuntu 24.04 LTS - Ubuntu 23.10 - Ubuntu 22.04 LTS - Ubuntu 20.04 LTS - Linux Other - Unix or *BSD like OS - MacOS - Windows 10 - Windows 11 - Windows Server 2016 - Windows Server 2019 - Windows Server 2022 validations: required: false - type: dropdown id: python_version attributes: label: Which Python Version did you use? description: | Please select the Python version you used. multiple: true options: - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" validations: required: false - type: input id: pyFunceble_version attributes: label: Which PyFunceble Version did you use? description: | Please provides the output of the `pyfunceble --version` command. validations: required: false - type: textarea id: additional attributes: label: Additional context description: Please provide any additional context related to the problem. placeholder: | I would like to add... value: | I would like to add... validations: required: false domain2idna-1.12.2/.github/ISSUE_TEMPLATE/01-feature-request.yml000066400000000000000000000051131470731005500235710ustar00rootroot00000000000000name: Feature Request description: Suggest an idea for this project. title: "Feature Request | My Awesome Idea" labels: - enhancement projects: - funilrys/6 assignees: - funilrys body: - type: markdown attributes: value: |+ Thanks for taking the time to fill out this feature request! lease be patient and rest assured that we will get back to you as soon as possible. To help us understand and reproduce the issue, please provide as much information as possible. If you have a question or need help, please ask in our [Discussions](https://github.com/funilrys/PyFunceble/discussions) section. - type: textarea id: feature attributes: label: What is the feature you'd like to request? description: Please describe the feature you'd like to request. placeholder: | I'd like to request a feature that... value: | I'd like to request a feature that... validations: required: true - type: textarea id: problem attributes: label: What problem are you trying to solve? description: Please describe the problem you are trying to solve. placeholder: | I'm trying to solve a problem where... value: | I'm trying to solve a problem where... validations: required: true - type: textarea id: solution attributes: label: What solution would you like to see? description: Please describe the solution you'd like to see. placeholder: | I'd like to see a solution that... value: | I'd like to see a solution that... validations: required: true - type: textarea id: alternatives attributes: label: Are there any alternatives you've considered? description: Please describe any alternatives you've considered. placeholder: | I've considered alternatives such as... value: | I've considered alternatives such as... validations: required: false - type: textarea id: additional attributes: label: Additional context description: Please provide any additional context or screenshots. placeholder: | I would like to add... value: | I would like to add... validations: required: false # - type: checkboxes # id: terms # attributes: # label: Code of Conduct # description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.org/todo). # options: # - label: I agree to follow this project's Code of Conduct # required: true domain2idna-1.12.2/.github/ISSUE_TEMPLATE/03-documentation.yml000066400000000000000000000026721470731005500233320ustar00rootroot00000000000000name: Documentation Improvement Request description: Suggestions for improving the documentation. title: "Documentation | My Awesome Idea" labels: - documentation projects: - funilrys/6 assignees: - funilrys body: - type: markdown attributes: value: |+ Thanks for taking the time to fill out this documentation improvement request! lease be patient and rest assured that we will get back to you as soon as possible. To help us understand and reproduce the issue, please provide as much information as possible. If you have a question or need help, please ask in our [Discussions](https://github.com/funilrys/PyFunceble/discussions) section. - type: textarea id: description attributes: label: What is missing or not easy to understand? description: | Please describe what is missing or not easy to understand in the documentation. placeholder: | I've found it hard to understand how... value: | I've found it hard to understand how... validations: required: true - type: textarea id: suggestion attributes: label: What is your suggestion or improvement? description: | A clear description of your suggestion and what you would like to improve and how you would like to improve it. placeholder: | I suggest that we... value: | I suggest that we... validations: required: true domain2idna-1.12.2/.github/ISSUE_TEMPLATE/config.yml000066400000000000000000000004701470731005500215000ustar00rootroot00000000000000blank_issues_enabled: false contact_links: - name: Discussions url: https://github.com/funilrys/PyFunceble/discussions about: Please ask and answer questions here. - name: Documentation url: https://docs.pyfunceble.com about: Find more information about PyFunceble through our documentation. domain2idna-1.12.2/.github/workflows/000077500000000000000000000000001470731005500173615ustar00rootroot00000000000000domain2idna-1.12.2/.github/workflows/branches.yml000066400000000000000000000066321470731005500217000ustar00rootroot00000000000000name: Branches Development Workflow on: pull_request: branches: - "**" - "!master" push: branches: - "**" - "!master" schedule: - cron: "0 0 * * *" jobs: lint: name: Lint domain2idna runs-on: "${{ matrix.os }}" strategy: fail-fast: false matrix: python_version: - "3.12" os: - ubuntu-latest steps: - uses: actions/checkout@v4 name: Clone repository - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} - name: Install dependencies run: | pip install --upgrade pip pip install --upgrade .[dev] pip install pylint - name: Lint with Pylint run: pylint domain2idna test: needs: [lint] name: "[${{ matrix.os }}-py${{ matrix.python_version }}] Test domain2idna" runs-on: "${{ matrix.os }}" strategy: fail-fast: false matrix: python_version: - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" os: - ubuntu-latest - macos-latest - windows-latest steps: - uses: actions/checkout@v4 name: Clone repository - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} - name: Install dependencies run: | pip install --upgrade pip pip install --upgrade .[test] pip install coveralls - name: Test as defined by tox.ini run: | tox -c tox.ini - name: Upload Coverage continue-on-error: true run: | coveralls env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} COVERALLS_PARALLEL: true coveralls: needs: test name: Finish Coveralls runs-on: "${{ matrix.os }}" strategy: fail-fast: false matrix: python_version: - "3.12" os: - ubuntu-latest steps: - name: Sending finish flag to coveralls.io uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} parallel-finished: true cli-test: needs: [lint] name: "[${{ matrix.os }}-py${{ matrix.python_version }}] CLI Test" runs-on: "${{ matrix.os }}" strategy: fail-fast: false matrix: python_version: - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" os: - ubuntu-latest - macos-latest - windows-latest steps: - uses: actions/checkout@v4 name: Clone repository - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} - name: Install dependencies run: | pip install --upgrade pip pip install --upgrade . - name: Run inline test run: | domain2idna -d аррӏе.com domain2idna -s аррӏе.com google.com - name: Run test from file run: | domain2idna -f .ci/list_of_domain domain2idna -f .ci/list_of_domain -o list_of_domain_converted cat list_of_domain_converteddomain2idna-1.12.2/.github/workflows/main.yml000066400000000000000000000105301470731005500210270ustar00rootroot00000000000000name: Main Deployment Workflow on: pull_request: branches: - master push: branches: - master schedule: - cron: "0 0 * * *" jobs: lint: name: Lint domain2idna runs-on: "${{ matrix.os }}" strategy: fail-fast: false matrix: python_version: - "3.12" os: - ubuntu-latest steps: - uses: actions/checkout@v4 name: Clone repository - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} - name: Install dependencies run: | pip install --upgrade pip pip install --upgrade .[dev] pip install pylint - name: Lint with Pylint run: pylint domain2idna test: needs: [lint] name: "[${{ matrix.os }}-py${{ matrix.python_version }}] Test domain2idna" runs-on: "${{ matrix.os }}" strategy: fail-fast: false matrix: python_version: - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" os: - ubuntu-latest - macos-latest - windows-latest steps: - uses: actions/checkout@v4 name: Clone repository - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} - name: Install dependencies run: | pip install --upgrade pip pip install --upgrade .[test] pip install coveralls - name: Test as defined by tox.ini run: | tox -c tox.ini coveralls: needs: test name: Finish Coveralls runs-on: "${{ matrix.os }}" strategy: fail-fast: false matrix: python_version: - "3.12" os: - ubuntu-latest steps: - name: Sending finish flag to coveralls.io uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} parallel-finished: true cli-test: needs: [lint] name: "[${{ matrix.os }}-py${{ matrix.python_version }}] Integration Test" runs-on: "${{ matrix.os }}" strategy: fail-fast: false matrix: python_version: - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" os: - ubuntu-latest - macos-latest - windows-latest steps: - uses: actions/checkout@v4 name: Clone repository - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} - name: Install dependencies run: | pip install --upgrade pip pip install --upgrade . - name: Run inline test run: | domain2idna -d аррӏе.com domain2idna -s аррӏе.com google.com - name: Run test from file run: | domain2idna -f .ci/list_of_domain domain2idna -f .ci/list_of_domain -o list_of_domain_converted cat list_of_domain_converted deploy_to_pypi: needs: [test, cli-test] name: "Deploy 📦 to the PyPi" environment: release permissions: id-token: write attestations: write if: github.event_name == 'push' && github.ref == 'refs/heads/master' runs-on: "${{ matrix.os }}" strategy: fail-fast: false matrix: python_version: - "3.12" os: - ubuntu-latest steps: - uses: actions/checkout@v4 name: Clone repository - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} - name: Install dependencies run: | pip install --upgrade pip pip install twine wheel setuptools - name: Build 📦 run: | python setup.py sdist bdist_wheel - name: Check 📦 run: | twine check dist/* - name: Attest 📦 uses: actions/attest-build-provenance@v1 with: subject-path: "dist/*" - name: Publish 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: skip-existing: true domain2idna-1.12.2/.gitignore000066400000000000000000000045451470731005500157640ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # pyenv .python-version # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # pyenv .python-version # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ domain2idna-1.12.2/LICENSE000066400000000000000000000022341470731005500147720ustar00rootroot00000000000000MIT License Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023, 2024 Nissar Chababy Copyright (c) 2019, 2020, 2021, 2022, 2023, 2024 PyFunceble Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. domain2idna-1.12.2/MANIFEST.in000066400000000000000000000003211470731005500155160ustar00rootroot00000000000000include requirements*.txt include .coveragerc include LICENSE recursive-include docs *.bat recursive-include docs *.py recursive-include docs *.rst recursive-include docs Makefile recursive-include tests *.py domain2idna-1.12.2/README.md000066400000000000000000000060601470731005500152450ustar00rootroot00000000000000![image](https://raw.githubusercontent.com/PyFunceble/logo/dev/Green/HD/RM.png)
# domains2idna **The tool to convert domains to the famous IDNA format.** This project provides a tool for list or hosts file maintainer that can converts domain to the Punycode/IDNA format. ## Documentation as the place to be! Want to know more about **domain2idna**? We invite you to read the documentation at ! Want a local copy!? We get you covered! Simply run the following and enjoy the documentation! $ # We move to the docs directory $ cd docs/ $ # We build the documentation $ make html $ # We run the documentation with our favorite browser. $ chromium _builld/html/index.html ## What can domain2idna do ? - Read a given domain and convert it to the Punycode/IDNA format. - Read a given URL and convert its base to Punycode/IDNA format. - Read a file and convert all non-commented line to the Punycode/IDNA format. - Print the converted data on the screen. - Save into a file the converted data. - Return the converted data (when used as a module). - Ignore commented inputs (starts with `#`) ## License MIT License Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023, 2024 Nissar Chababy Copyright (c) 2019, 2020, 2021, 2022, 2023, 2024 PyFunceble Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.domain2idna-1.12.2/docs/000077500000000000000000000000001470731005500147145ustar00rootroot00000000000000domain2idna-1.12.2/docs/Makefile000066400000000000000000000011401470731005500163500ustar00rootroot00000000000000# Minimal makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build SPHINXPROJ = domain2idna SOURCEDIR = . BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)domain2idna-1.12.2/docs/code.rst000066400000000000000000000010631470731005500163600ustar00rootroot00000000000000Code documentation ================== .. automodule:: domain2idna :members: Helpers ------- Problematic ^^^^^^^^^^^ How can we write, read and delete a file without having to write everytime the same thing? Code documentation ^^^^^^^^^^^^^^^^^^ .. automodule::domain2idna.helpers :members: :code:`File()` """""""""""""" .. autoclass:: domain2idna.helpers.File :members: Converter --------- Code documentation ^^^^^^^^^^^^^^^^^^ .. automodule::domain2idna.converter :members: .. autoclass:: domain2idna.converter.Converter :members: domain2idna-1.12.2/docs/conf.py000066400000000000000000000132041470731005500162130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # import os import sys sys.path.insert(0, os.path.abspath("..")) from setup import get_version # -- Project information ----------------------------------------------------- project = "domain2idna" copyright = "2018, 2019, Nissar Chababy (@funilrys) | 2019, PyFunceble" author = "Nissar Chababy (@funilrys)" # The short X.Y version version = get_version() # -- General configuration --------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ "sphinx.ext.autodoc", "sphinx.ext.todo", "sphinx.ext.coverage", "sphinx.ext.ifconfig", "sphinx.ext.viewcode", ] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = ".rst" # The master toctree document. master_doc = "index" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path . exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # The name of the Pygments (syntax highlighting) style to use. pygments_style = "sphinx" # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = "sphinx_rtd_theme" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # # html_theme_options = {} # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] # Custom sidebar templates, must be a dictionary that maps document names # to template names. # # The default sidebars (for documents that don't match any pattern) are # defined by theme itself. Builtin themes are using these templates by # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', # 'searchbox.html']``. # # html_sidebars = {} # -- Options for HTMLHelp output --------------------------------------------- # Output file base name for HTML help builder. htmlhelp_basename = "domain2idnadoc" # -- Options for LaTeX output ------------------------------------------------ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ( master_doc, "domain2idna.tex", "domain2idna Documentation", "Nissar Chababy (@funilrys)", "manual", ) ] # -- Options for manual page output ------------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [(master_doc, "domain2idna", "domain2idna Documentation", [author], 1)] # -- Options for Texinfo output ---------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ( master_doc, "domain2idna", "domain2idna Documentation", author, "domain2idna", "One line description of project.", "Miscellaneous", ) ] # -- Options for Epub output ------------------------------------------------- # Bibliographic Dublin Core info. epub_title = project epub_author = author epub_publisher = author epub_copyright = copyright # The unique identifier of the text. This can be a ISBN number # or the project homepage. # # epub_identifier = '' # A unique identification for the text. # # epub_uid = '' # A list of files that should not be packed into the epub file. epub_exclude_files = ["search.html"] # -- Extension configuration ------------------------------------------------- # -- Options for todo extension ---------------------------------------------- # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True domain2idna-1.12.2/docs/index.rst000066400000000000000000000023701470731005500165570ustar00rootroot00000000000000The tool to convert domains to the famous IDNA format. ====================================================== .. image:: https://travis-ci.com/PyFunceble/domain2idna.svg?branch=master :target: https://travis-ci.com/PyFunceble/domain2idna .. image:: https://coveralls.io/repos/github/PyFunceble/domain2idna/badge.svg?branch=master :target: https://coveralls.io/github/PyFunceble/domain2idna?branch=master .. image:: https://api.codacy.com/project/badge/Grade/7fc14987068e409e9ddb70195f2485ab :target: https://www.codacy.com/manual/funilrys/domain2idna?utm_source=github.com&utm_medium=referral&utm_content=PyFunceble/domain2idna&utm_campaign=Badge_Grade .. image:: https://img.shields.io/github/license/PyFunceble/domain2idna.svg :target: https://github.com/PyFunceble/domain2idna/blob/master/LICENSE .. image:: https://img.shields.io/github/release/PyFunceble/domain2idna.svg :target: https://github.com/PyFunceble/domain2idna/releases/latest .. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/ambv/black .. toctree:: :maxdepth: 2 :caption: Content installation usage code issues Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` domain2idna-1.12.2/docs/installation.rst000066400000000000000000000047111470731005500201520ustar00rootroot00000000000000Requirements ============ Here is the list of requirements: - Python 3.6.2+ && Python < 4 - :code:`colorama` Python 3.6.8+ && Python < 4 ------------------------------ The specification :code:`3.6.8+` is because we test domain2idna (daily) in all version from :code:`3.6.8`. Otherwise, more semantically, domain2idna is written for all Python 3.6+ version. colorama -------- As we want to add some coloration, we choose :code:`colorama` for the job as it offers a portable awesome solution. Get and install domain2idna =========================== Using :code:`pip` ----------------- Choose your repository, install and enjoy domain2idna! From PyPi ^^^^^^^^^ :: $ pip3 install --user domain2idna .. note:: We recommend the :code:`--user` flag which installs the required dependencies at the user level. More information about it can be found on `pip documentation`_. .. warning:: We do not recommend the :code:`--user` flag when using :code:`domain2idna` into containers like - for example - Travis CI. From GitHub ^^^^^^^^^^^ :: $ pip3 install --user git+https://github.com/PyFunceble/domain2idna.git@master#egg=domain2idna .. note:: We recommend the :code:`--user` flag which installs the required dependencies at the user level. More information about it can be found on `pip documentation`_. .. warning:: We do not recommend the :code:`--user` flag when using :code:`domain2idna` into containers like - for example - Travis CI. .. _pip documentation: https://pip.pypa.io/en/stable/reference/pip_install/?highlight=--user#cmdoption-user Using :code:`conda` ------------------- :: $ conda install -c pyfunceble domain2idna Pure Python method ------------------ Execute the following and enjoy domain2idna! We clone the repository. :: $ git clone https://github.com/PyFunceble/domain2idna.git We move to the cloned directory. :: $ cd domain2idna We test the package before installating. :: $ python3 setup.py test We install domain2idna. :: $ python3 setup.py install --user .. note:: We recommend the :code:`--user` flag which installs the required dependencies at the user level. More information about it can be found on `pip documentation`_. .. warning:: We do not recommend the :code:`--user` flag when using :code:`domain2idna` into containers like - for example - Travis CI. First steps =========== Make sure that you can run the following without any issue and enjoy domain2idna!! :: $ domain2idna --version domain2idna-1.12.2/docs/issues.rst000066400000000000000000000004411470731005500167600ustar00rootroot00000000000000Issues ====== Have or found an issue with :code:`domain2idna`? Please follow one of the following. * Fill a `new issue`_. * Send a email to contactTATATAfunilrysTODTOTODcom. .. _new issue: https://github.com/PyFunceble/domain2idna/issues/new .. _keybase.io: https://keybase.io/funilrys domain2idna-1.12.2/docs/make.bat000066400000000000000000000014571470731005500163300ustar00rootroot00000000000000@ECHO OFF pushd %~dp0 REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set SOURCEDIR=. set BUILDDIR=_build set SPHINXPROJ=domain2idna if "%1" == "" goto help %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point echo.to the full path of the 'sphinx-build' executable. Alternatively you echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% goto end :help %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% :end popd domain2idna-1.12.2/docs/usage.rst000066400000000000000000000035511470731005500165560ustar00rootroot00000000000000Usage ===== As a Python module ------------------ Here's an example which show us how domain2idna can be used a python module. :: #!/usr/bin/env python3 """ This module uses domains2idna to convert a given domain. Author: Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom Contributors: Let's contribute to this example!! Repository: https://github.com/PyFunceble/domain2idna """ from domain2idna import domain2idna DOMAINS = [ "bittréẋ.com", "bịllogram.com", "coinbȧse.com", "cryptopiạ.com", "cṙyptopia.com" ] # The following return the result of the whole list. print("UTF-8 domains: %s" % DOMAINS) print("Converted domains: %s" % domain2idna(DOMAINS)) # The following return the result of only one element. print("UTF-8 domain: %s" % DOMAINS[0]) print( "Converted domain: %s" % domain2idna(DOMAINS[0])) From a terminal --------------- Here is the list of available command when calling :code:`domain2idna` from a terminal. :: usage: domain2idna [-h] [-s SUBJECT [SUBJECT ...]] [-e ENCODING] [-f FILE] [-o OUTPUT] [-v] domain2idna - The tool to convert a domain or a file with a list of domain to the famous IDNA format. optional arguments: -h, --help show this help message and exit -s SUBJECT [SUBJECT ...], --subject SUBJECT [SUBJECT ...] Sets the subjects to convert. -e ENCODING, --encoding ENCODING Sets the encoding to use. -f FILE, --file FILE Sets the file to read to get the domain(s) to convert. -o OUTPUT, --output OUTPUT Sets the file where we write the converted domain(s). -v, --version show program's version number and exit Crafted with ♥ by Nissar Chababy (Funilrys)domain2idna-1.12.2/domain2idna/000077500000000000000000000000001470731005500161515ustar00rootroot00000000000000domain2idna-1.12.2/domain2idna/__about__.py000066400000000000000000000031561470731005500204360ustar00rootroot00000000000000""" domain2idna - The tool to convert a domain or a file with a list of domain to the famous IDNA format. Author: Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom Contributors: Let's contribute to domains2idna!! Project link: https://github.com/PyFunceble/domain2idna Project documentation: http://domain2idna.readthedocs.io License: :: MIT License Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023, 2024 Nissar Chababy Copyright (c) 2019, 2020, 2021, 2022, 2023, 2024 PyFunceble Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ __version__ = "1.12.2" domain2idna-1.12.2/domain2idna/__init__.py000066400000000000000000000051401470731005500202620ustar00rootroot00000000000000""" domain2idna - The tool to convert a domain or a file with a list of domain to the famous IDNA format. Author: Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom Contributors: Let's contribute to domains2idna!! Project link: https://github.com/PyFunceble/domain2idna Project documentation: http://domain2idna.readthedocs.io License: :: MIT License Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023, 2024 Nissar Chababy Copyright (c) 2019, 2020, 2021, 2022, 2023, 2024 PyFunceble Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import warnings from .converter import Converter def domain2idna(subject, encoding="utf-8"): """ Process the conversion of the given subject. :param subject: The subject to convert. :type subject: str, list :param str encoding: The encoding to provide. :rtype: list, str """ return Converter(subject, original_encoding=encoding).get_converted() def get(domain_to_convert): # pragma: no cover """ This function is a passerelle between the front and the backend of this module. :param str domain_to_convert: The domain to convert. :return: str: if a string is given. list: if a list is given. :rtype: str, list .. deprecated:: 1.10.0 Use :func:`~domain2idna.domain2idna` instead. """ warnings.warn( "`domain2idna.get` will be removed in future version. " "Please use `domain2idna.domain2idna` instead.", DeprecationWarning, ) return domain2idna(domain_to_convert) domain2idna-1.12.2/domain2idna/cli.py000066400000000000000000000126451470731005500173020ustar00rootroot00000000000000""" domain2idna - The tool to convert a domain or a file with a list of domain to the famous IDNA format. This submodule provides everything related to the CLI. Author: Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom Contributors: Let's contribute to domains2idna!! Project link: https://github.com/PyFunceble/domain2idna Project documentation: http://domain2idna.readthedocs.io License: :: MIT License Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023, 2024 Nissar Chababy Copyright (c) 2019, 2020, 2021, 2022, 2023, 2024 PyFunceble Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import argparse from colorama import Fore, Style from colorama import init as initiate_colorama from .__about__ import __version__ from .converter import Converter from .helpers import File def subjects(subject_to_convert, output=None, encoding="utf-8"): """ This function convert the given domain to IDNA format. :param str domain_to_convert: The domain to convert. :param str output: The output of the conversion. If not set, we output to stdout. :param str encoding: The encoding to provide. :raise ValueError: If the given :code:`domain_to_convert` is empty. """ if subject_to_convert: if not isinstance(subject_to_convert, list): subject_to_convert = [subject_to_convert] converted = Converter( subject_to_convert, original_encoding=encoding ).get_converted() if output: File(output).write("\n".join(converted)) else: print("\n".join(converted)) else: raise ValueError("Could not understand .") def file(file_to_convert, output=None, encoding="utf-8"): """ This function read a file and convert each line of the file to IDNA. :param str file_to_convert: The file to convert :param str output: The output of the conversion. If not set, we output to stdout. :param str encoding: The encoding to provide. """ if file_to_convert: converted = [] try: to_convert = File(file_to_convert).read(encoding=encoding).split("\n") except (UnicodeEncodeError, UnicodeDecodeError): # pragma: no cover to_convert = File(file_to_convert).read(encoding="ISO-8859-1").split("\n") converted = Converter(to_convert).get_converted() if output: File(output).write("\n".join(converted)) else: print("\n".join(converted)) def tool(): # pragma: no cover """ Provides the CLI. """ if __name__ == "domain2idna.cli": initiate_colorama(autoreset=True) # pylint: disable=consider-using-f-string parser = argparse.ArgumentParser( description="domain2idna - The tool to convert a domain or a file with \ a list of domain to the famous IDNA format.", epilog="Crafted with %s by %s" % ( Fore.RED + "♥" + Fore.RESET, Style.BRIGHT + Fore.CYAN + "Nissar Chababy (Funilrys)" + Style.RESET_ALL, ), ) parser.add_argument("-d", "--domain", type=str, help=argparse.SUPPRESS) parser.add_argument( "-s", "--subject", type=str, nargs="+", help="Sets the subjects to convert.", default=[], ) parser.add_argument( "-e", "--encoding", type=str, help="Sets the encoding to use.", default="utf-8", ) parser.add_argument( "-f", "--file", type=str, help="Sets the file to read to get the domain(s) to convert.", ) parser.add_argument( "-o", "--output", type=str, help="Sets the file where we write the converted domain(s).", ) parser.add_argument( "-v", "--version", action="version", version="%(prog)s " + __version__ ) args = parser.parse_args() subject = args.subject if args.domain: subject.append(args.domain) if subject: subjects(subject, args.output, encoding=args.encoding) elif args.file: file(args.file, args.output, encoding=args.encoding) domain2idna-1.12.2/domain2idna/converter.py000066400000000000000000000107241470731005500205360ustar00rootroot00000000000000""" domain2idna - The tool to convert a domain or a file with a list of domain to the famous IDNA format. Provides the base to all other sublogic(s). Author: Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom Contributors: Let's contribute to domains2idna!! Project link: https://github.com/PyFunceble/domain2idna Project documentation: http://domain2idna.readthedocs.io License: MIT License Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023, 2024 Nissar Chababy Copyright (c) 2019, 2020, 2021, 2022, 2023, 2024 PyFunceble Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from urllib.parse import urlparse class Converter: """ Provides a base for every core logic we add. :param subject: The subject to convert. :type subject: str, list :param str original_encoding: The encoding to provide as output. """ to_ignore = [ "0.0.0.0", "localhost", "127.0.0.1", "localdomain", "local", "broadcasthost", "allhosts", "allnodes", "allrouters", "localnet", "loopback", "mcastprefix", ] def __init__(self, subject, original_encoding="utf-8"): self.subject = subject self.encoding = original_encoding def convert_to_idna(self, subject, original_encoding="utf-8"): """ Converts the given subject to IDNA. :param str subject: The subject to convert. :rtype: str """ if subject in self.to_ignore: return subject if "://" not in subject: try: return subject.encode("idna").decode(original_encoding) except UnicodeError: # pragma: no cover return subject if subject.startswith("://"): to_convert = urlparse(f"https://{subject[3:]}").netloc converted = self.convert_to_idna(to_convert) return subject.replace(to_convert, converted) parsed_url = urlparse(subject) result = ( f"{parsed_url.scheme}://{self.convert_to_idna(parsed_url.netloc)}" f"{parsed_url.path}" ) if parsed_url.params: result += f";{parsed_url.params}" if parsed_url.query: result += f"?{parsed_url.query}" if parsed_url.fragment: result += f"#{parsed_url.fragment}" return result def __get_converted(self, subject): """ Process the actual conversion. :param str subject: The subject to convert. :rtype: str """ if ( not subject or not subject.strip() or subject in self.to_ignore or subject.startswith("#") ): return subject if "#" in subject and "://" not in subject: comment = " " + subject[subject.find("#") :] subject = subject[: subject.find("#")].strip() else: comment = "" return ( " ".join( [ self.convert_to_idna(x, original_encoding=self.encoding) for x in subject.split() ] ) + comment ).strip() def get_converted(self): """ Provides the converted data. """ if isinstance(self.subject, list): return [self.__get_converted(x) for x in self.subject] return self.__get_converted(self.subject) domain2idna-1.12.2/domain2idna/helpers.py000066400000000000000000000055431470731005500201740ustar00rootroot00000000000000""" domain2idna - The tool to convert a domain or a file with a list of domain to the famous IDNA format. This submodule contains all helpers that are used by other submodules. Author: Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom Contributors: Let's contribute to domains2idna!! Project link: https://github.com/PyFunceble/domain2idna Project documentation: http://domain2idna.readthedocs.io License: MIT License Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023, 2024 Nissar Chababy Copyright (c) 2019, 2020, 2021, 2022, 2023, 2024 PyFunceble Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from os import remove class File: """ File treatment/manipulations. :param str filename: A path to the file to manipulate. """ def __init__(self, filename): self.file = filename def write(self, data_to_write): """ Writes or appends data into the given file path. :param str data_to_write: The data to write. """ if data_to_write and isinstance(data_to_write, str): with open(self.file, "w", encoding="utf-8") as file: file.write(data_to_write) def read(self, encoding=None): """ Reads a given file path and return its content. :param str encoding: The encoding to use when opening the file. :rtype: str """ if not encoding: encoding = "utf-8" with open(self.file, "r", encoding=encoding) as file: funilrys = file.read() return funilrys def delete(self): """ Deletes a given file path. .. warning:: We handle the case that the file does not exist. """ try: remove(self.file) except OSError: pass domain2idna-1.12.2/meta.yaml000066400000000000000000000015031470731005500155750ustar00rootroot00000000000000{% set name = "domain2idna" %} {% set version = "%%version%%" %} package: name: "{{ name|lower }}" version: "{{ version }}" source: path: ./ build: number: 0 entry_points: - domain2idna=domain2idna.cli:tool noarch: python script: "{{ PYTHON }} -m pip install . -vv" requirements: host: - colorama - pip - python - setuptools run: - colorama - python - setuptools test: imports: - domain2idna commands: - domain2idna --version - domain2idna --help - domain2idna -s bittréẋ.com about: home: "https://github.com/PyFunceble/domain2idna" license: MIT license_family: MIT license_file: summary: "The tool to convert a domain or a file with a list of domain to the famous IDNA format." doc_url: dev_url: extra: recipe-maintainers: - funilrys domain2idna-1.12.2/requirements.dev.txt000066400000000000000000000000321470731005500200200ustar00rootroot00000000000000black flake8 isort pylint domain2idna-1.12.2/requirements.test.txt000066400000000000000000000000151470731005500202220ustar00rootroot00000000000000tox coverage domain2idna-1.12.2/requirements.txt000066400000000000000000000000341470731005500172450ustar00rootroot00000000000000setuptools>=65.5.1 colorama domain2idna-1.12.2/setup.cfg000066400000000000000000000005641470731005500156120ustar00rootroot00000000000000[isort] profile = black [flake8] max-line-length = 88 extend-ignore = E203 [pylint] max-line-length = 88 [pylint.'MESSAGES CONTROL'] disable = too-many-statements, too-many-locals, too-many-arguments, too-many-instance-attributes, too-many-lines, too-many-public-methods, no-self-argument [pylint.'SIMILARITIES'] min-similarity-lines = 40 domain2idna-1.12.2/setup.py000066400000000000000000000107371470731005500155060ustar00rootroot00000000000000""" domain2idna - The tool to convert a domain or a file with a list of domain to the famous IDNA format. Author: Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom Contributors: Let's contribute to domain2idna!! Repository: https://github.com/PyFunceble/domain2idna License: MIT License Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023, 2024 Nissar Chababy Copyright (c) 2019, 2020, 2021, 2022, 2023, 2024 PyFunceble Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import os import re from setuptools import setup def get_requirements(*, mode="standard"): """ This function extract all requirements from requirements.txt. """ mode2files = { "standard": ["requirements.txt"], "dev": ["requirements.dev.txt"], "test": ["requirements.test.txt"], } mode2files["full"] = [y for x in mode2files.values() for y in x] result = set() for file in mode2files[mode]: with open(file, "r", encoding="utf-8") as file_stream: for line in file_stream: line = line.strip() if not line or line.startswith("#"): continue if "#" in line: line = line[: line.find("#")].strip() if not line: continue result.add(line) return list(result) def get_version(): """ This function will extract the version from domain2idna/__about__.py """ to_match = re.compile(r'__version__.*=\s+"(.*)"') if os.path.exists("domain2idna/__about__.py"): about_path = "domain2idna/__about__.py" elif os.path.exists("../domain2idna/__about__.py"): about_path = "../domain2idna/__about__.py" else: raise FileNotFoundError("No __about__.py found.") with open(about_path, encoding="utf-8") as file_stream: extracted = to_match.findall(file_stream.read())[0] return extracted def get_long_description(): # pragma: no cover """ This function return the long description. """ return open("README.md", encoding="utf-8").read() if __name__ == "__main__": setup( name="domain2idna", version=get_version(), python_requires=">=3.6.2, <4", description="The tool to convert a domain or a file with a list of domain to the " "famous IDNA format.", long_description=get_long_description(), long_description_content_type="text/markdown", install_requires=get_requirements(mode="standard"), extras_require={ "test": get_requirements(mode="test"), "dev": get_requirements(mode="dev"), "full": get_requirements(mode="full"), }, author="funilrys", author_email="contact@funilrys.com", license="MIT https://raw.githubusercontent.com/PyFunceble/domain2idna/master/LICENSE", url="https://github.com/PyFunceble/domain2idna", platforms=["any"], packages=["domain2idna"], keywords=["Python", "domain", "idna"], classifiers=[ "Environment :: Console", "Topic :: Internet", "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Programming Language :: Python", "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", ], entry_points={"console_scripts": ["domain2idna=domain2idna.cli:tool"]}, ) domain2idna-1.12.2/tests/000077500000000000000000000000001470731005500151265ustar00rootroot00000000000000domain2idna-1.12.2/tests/__init__.py000066400000000000000000000000001470731005500172250ustar00rootroot00000000000000domain2idna-1.12.2/tests/test_cli.py000066400000000000000000000145761470731005500173230ustar00rootroot00000000000000#!/usr/bin/env python3 """ domain2idna - The tool to convert a domain or a file with a list of domain to the famous IDNA format. Tests the API endpoints. Author: Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom Contributors: Let's contribute to domains2idna!! Project link: https://github.com/PyFunceble/domain2idna Project documentation: http://domain2idna.readthedocs.io License: MIT License Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023, 2024 Nissar Chababy Copyright (c) 2019, 2020, 2021, 2022, 2023, 2024 PyFunceble Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ # pylint: disable=duplicate-code import sys from io import StringIO from os import path from unittest import TestCase from unittest import main as launch_tests from domain2idna.cli import file, subjects from domain2idna.helpers import File class BaseStdout(TestCase): """ This class is the one we use when we want to catch stdout. """ def setUp(self): """ Setup stdout. """ sys.stdout = StringIO() def tearDown(self): sys.stdout.close() sys.stdout = sys.__stdout__ class TestCLI(BaseStdout): """ This class will test domain2idna.__init__. """ def setUp(self): """ Setup all cross tests variables. """ self.domain_to_test = ["ṁỵetherwallet.com", "xn--etherwallet-tv8eq7f.com\n"] self.domains_to_test = [ "bịllogram.com", "0.0.0.0 ṁỵetherwallet.com", "coinbȧse.com", "cryptopiạ.com", "bittréẋ.com", "cṙyptopia.com", ] self.converted = [ "xn--bllogram-g80d.com", "0.0.0.0 xn--etherwallet-tv8eq7f.com", "xn--coinbse-30c.com", "xn--cryptopi-ux0d.com", "xn--bittr-fsa6124c.com", "xn--cyptopia-4e0d.com", ] self.empty_inputs = ["", " ", " ", None, False] def test_domain(self): """ This method will test domain2idna.domain() """ BaseStdout.setUp(self) expected = self.domain_to_test[-1] subjects(self.domain_to_test[0], None) actual = sys.stdout.getvalue() self.assertEqual(expected, actual) def test_domain_output(self): """ This method will test domain2idna.domain() for the case that we want the output into a file. """ output_file = "this_file_is_a_ghost" expected = False actual = path.isfile(output_file) self.assertEqual(expected, actual) expected = self.domain_to_test[-1][:-1] subjects(self.domain_to_test[0], output_file) actual = File(output_file).read() self.assertEqual(expected, actual) File(output_file).delete() expected = False actual = path.isfile(output_file) self.assertEqual(expected, actual) def test_empty_domain(self): """ This method will test domain2idna.domain() for the case that an empty string is given. """ for empty_domain in self.empty_inputs: self.assertRaises( ValueError, lambda: subjects(empty_domain), # pylint: disable=cell-var-from-loop ) def test_file(self): """ This method will test domain2idna.file(). """ file_to_pass = "this_file_is_a_ghost" BaseStdout.setUp(self) expected = False actual = path.isfile(file_to_pass) self.assertEqual(expected, actual) File(file_to_pass).write("\n".join(self.domains_to_test)) expected = True actual = path.isfile(file_to_pass) self.assertEqual(expected, actual) expected = "\n".join(self.domains_to_test) actual = File(file_to_pass).read() self.assertEqual(expected, actual) expected = "\n".join(self.converted) + "\n" file(file_to_pass, None) actual = sys.stdout.getvalue() self.assertEqual(expected, actual) File(file_to_pass).delete() expected = False actual = path.isfile(file_to_pass) self.assertEqual(expected, actual) def test_file_output(self): """ This method will test domain2idna.file() for the case we want the results in a file. """ file_to_pass = "this_file_is_a_ghost" output_file = "this_file_is_a_converted_ghost" expected = False actual = path.isfile(file_to_pass) self.assertEqual(expected, actual) File(file_to_pass).write("\n".join(self.domains_to_test)) expected = True actual = path.isfile(file_to_pass) self.assertEqual(expected, actual) expected = "\n".join(self.domains_to_test) actual = File(file_to_pass).read() self.assertEqual(expected, actual) expected = "\n".join(self.converted) file(file_to_pass, output_file) actual = File(output_file).read() self.assertEqual(expected, actual) File(file_to_pass).delete() File(output_file).delete() expected = False actual = path.isfile(file_to_pass) self.assertEqual(expected, actual) expected = False actual = path.isfile(output_file) self.assertEqual(expected, actual) if __name__ == "__main__": launch_tests() domain2idna-1.12.2/tests/test_converter.py000066400000000000000000000124071470731005500205520ustar00rootroot00000000000000#!/usr/bin/env python3 """ domain2idna - The tool to convert a domain or a file with a list of domain to the famous IDNA format. Tests the converter itself. Author: Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom Contributors: Let's contribute to domains2idna!! Project link: https://github.com/PyFunceble/domain2idna Project documentation: http://domain2idna.readthedocs.io License: MIT License Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023, 2024 Nissar Chababy Copyright (c) 2019, 2020, 2021, 2022, 2023, 2024 PyFunceble Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from unittest import TestCase from unittest import main as launch_tests from domain2idna.converter import Converter class TestConverter(TestCase): """ Tests Converter. """ def test_to_idna_single(self): """ Runs and tests Converter """ domain_to_test = "ṁỵetherwallet.com" expected = "xn--etherwallet-tv8eq7f.com" actual = Converter(domain_to_test).get_converted() self.assertEqual(expected, actual) def test_to_idna_multiple(self): """ Runs and tests Converter. """ domains_to_test = [ "bịllogram.com", "bittréẋ.com", "cryptopiạ.com", "coinbȧse.com", "cṙyptopia.com", "0.0.0.0 ṁỵetherwallet.com", "0.0.0.0/8", ] expected = [ "xn--bllogram-g80d.com", "xn--bittr-fsa6124c.com", "xn--cryptopi-ux0d.com", "xn--coinbse-30c.com", "xn--cyptopia-4e0d.com", "0.0.0.0 xn--etherwallet-tv8eq7f.com", "0.0.0.0/8", ] actual = Converter(domains_to_test).get_converted() self.assertEqual(expected, actual) def test_to_idna_multiple_urls(self): """ Runs and tests Converter. """ domains_to_test = [ "http://bịllogram.com", "https://bittréẋ.com/path;parameters?query#fragment", "ftp://cryptopiạ.com", "git://coinbȧse.com", "://coinbȧse.com/hello_world", ] expected = [ "http://xn--bllogram-g80d.com", "https://xn--bittr-fsa6124c.com/path;parameters?query#fragment", "ftp://xn--cryptopi-ux0d.com", "git://xn--coinbse-30c.com", "://xn--coinbse-30c.com/hello_world", ] actual = Converter(domains_to_test).get_converted() self.assertEqual(expected, actual) def test_commented_line(self): """ Tests that the comments are returned normally. """ comments = [ "# Hello, World!", "# This is another commented line", "cryptopiạ.com # This is a comment at the end of a line.", "# This is a commented line with bittréẋ.com", "# cryptopiạ.com", ] expected = [ "# Hello, World!", "# This is another commented line", "xn--cryptopi-ux0d.com # This is a comment at the end of a line.", "# This is a commented line with bittréẋ.com", "# cryptopiạ.com", ] actual = Converter(comments).get_converted() self.assertEqual(expected, actual) def test_hosts_file_format(self): """ Tests that the hosts file format is always respected. """ given = [ "0.0.0.0 bịllogram.com", "127.0.0.1 bittréẋ.com", "0.0.0.0 cryptopiạ.com", "127.0.0.1 coinbȧse.com", "0.0.0.0 cṙyptopia.com", ] expected = [ "0.0.0.0 xn--bllogram-g80d.com", "127.0.0.1 xn--bittr-fsa6124c.com", "0.0.0.0 xn--cryptopi-ux0d.com", "127.0.0.1 xn--coinbse-30c.com", "0.0.0.0 xn--cyptopia-4e0d.com", ] actual = Converter(given).get_converted() self.assertEqual(expected, actual) given = "0.0.0.0 bịllogram.com" expected = "0.0.0.0 xn--bllogram-g80d.com" actual = Converter(given).get_converted() self.assertEqual(expected, actual) if __name__ == "__main__": launch_tests() domain2idna-1.12.2/tests/test_helpers.py000066400000000000000000000075431470731005500202120ustar00rootroot00000000000000#!/usr/bin/env python3 """ domain2idna - The tool to convert a domain or a file with a list of domain to the famous IDNA format. Tests the helpers. Author: Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom Contributors: Let's contribute to domains2idna!! Project link: https://github.com/PyFunceble/domain2idna Project documentation: http://domain2idna.readthedocs.io License: MIT License Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023, 2024 Nissar Chababy Copyright (c) 2019, 2020, 2021, 2022, 2023, 2024 PyFunceble Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from os import path from unittest import TestCase from unittest import main as launch_tests from domain2idna.helpers import File class TestFile(TestCase): """ Tests helpers.File. """ def test_write_delete(self): """ Tests helpers.File.write along with helpers.File.delete. """ expected = "Hello, World! I'm PyFunceble" File("hi").write(expected) with open("hi") as file: actual = file.read() self.assertEqual(expected, actual) expected = False File("hi").delete() actual = path.isfile("hi") self.assertEqual(expected, actual) def test_write_overwrite_delete(self): """ Tests helpers.File.write along with helpers.File.delete. """ expected = "Hello, World! I'm PyFunceble" File("hi").write(expected) with open("hi") as file: actual = file.read() self.assertEqual(expected, actual) expected = "Hello, World! Python is great, you should consider learning it!" File("hi").write(expected) with open("hi") as file: actual = file.read() self.assertEqual(expected, actual) expected = False File("hi").delete() actual = path.isfile("hi") self.assertEqual(expected, actual) def test_read_delete(self): """ Tests helpers.File.read along with helpers.File.delete. """ expected = "Hello, World! This has been written by Fun Ilrys." File("hi").write(expected) actual = File("hi").read() self.assertEqual(expected, actual) expected = False File("hi").delete() actual = path.isfile("hi") self.assertEqual(expected, actual) def test_delete_not_exist(self): """ Tests helpers.File.delete for the case that the file does not exists. """ filename = "this_file_is_a_ghost" expected = False actual = path.isfile(filename) self.assertEqual(expected, actual) File(filename).delete() expected = False actual = path.isfile(filename) self.assertEqual(expected, actual) if __name__ == "__main__": launch_tests() domain2idna-1.12.2/tests/test_init.py000066400000000000000000000061241470731005500175050ustar00rootroot00000000000000#!/usr/bin/env python3 """ domain2idna - The tool to convert a domain or a file with a list of domain to the famous IDNA format. Tests the API endpoints. Author: Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom Contributors: Let's contribute to domains2idna!! Project link: https://github.com/PyFunceble/domain2idna Project documentation: http://domain2idna.readthedocs.io License: MIT License Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023, 2024 Nissar Chababy Copyright (c) 2019, 2020, 2021, 2022, 2023, 2024 PyFunceble Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ # pylint: disable=duplicate-code from unittest import TestCase from unittest import main as launch_tests from domain2idna import domain2idna class TestInit(TestCase): """ This class will test domain2idna.__init__. """ def setUp(self): """ Setup all cross tests variables. """ self.domain_to_test = ["ṁỵetherwallet.com", "xn--etherwallet-tv8eq7f.com\n"] self.domains_to_test = [ "bittréẋ.com", "bịllogram.com", "coinbȧse.com", "cryptopiạ.com", "cṙyptopia.com", "0.0.0.0 ṁỵetherwallet.com", ] self.converted = [ "xn--bittr-fsa6124c.com", "xn--bllogram-g80d.com", "xn--coinbse-30c.com", "xn--cryptopi-ux0d.com", "xn--cyptopia-4e0d.com", "0.0.0.0 xn--etherwallet-tv8eq7f.com", ] self.empty_inputs = ["", " ", " ", None, False] def test_get(self): """ This method will test domain2idna.get """ expected = self.converted actual = domain2idna(self.domains_to_test) self.assertEqual(expected, actual) expected = self.empty_inputs actual = domain2idna(self.empty_inputs) self.assertEqual(expected, actual) expected = None actual = domain2idna(None) self.assertEqual(expected, actual) if __name__ == "__main__": launch_tests() domain2idna-1.12.2/tox.ini000066400000000000000000000003621470731005500153000ustar00rootroot00000000000000[tox] recreate = True [testenv] setenv = PYTHONIOENCODING = utf-8 deps = -rrequirements.txt -rrequirements.test.txt commands = coverage run -m unittest discover tests coverage xml coverage html coverage report -m