roman-numerals-py


Nameroman-numerals-py JSON
Version 2.0.0 PyPI version JSON
download
home_pageNone
SummaryDocutils -- Python Documentation Utilities
upload_time2024-11-14 17:50:57
maintainerNone
docs_urlNone
authorAdam Turner
requires_python>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ===============
 roman-numerals
===============

A library for manipulating well-formed Roman numerals.

Integers between 1 and 3,999 (inclusive) are supported.
Numbers beyond this range will return an ``OutOfRangeError``.

The classical system of roman numerals requires that
the same character may not appear more than thrice consecutively,
meaning that 'MMMCMXCIX' (3,999) is the largest well-formed Roman numeral.
The smallest is 'I' (1), as there is no symbol for zero in Roman numerals.

Both upper- and lower-case formatting of roman numerals are supported,
and likewise for parsing strings,
although the entire string must be of the same case.
Numerals that do not adhere to the classical form are rejected
with an ``InvalidRomanNumeralError``.

Example usage
=============

Creating a roman numeral
------------------------

.. code-block:: python

   from roman_numerals import RomanNumeral

   num = RomanNumeral(16)
   assert str(num) == 'XVI'

   num = RomanNumeral.from_string("XVI")
   assert int(num) == 16


Convert a roman numeral to a string
-----------------------------------

.. code-block:: python

   from roman_numerals import RomanNumeral

   num = RomanNumeral(16)
   assert str(num) == 'XVI'
   assert num.to_uppercase() == 'XVI'
   assert num.to_lowercase() == 'xvi'
   assert repr(num) == 'RomanNumeral(16)'


Extract the decimal value of a roman numeral
--------------------------------------------

.. code-block:: python

   from roman_numerals import RomanNumeral

   num = RomanNumeral(42)
   assert int(num) == 42


Invalid input
-------------

.. code-block:: python

   from roman_numerals import RomanNumeral, InvalidRomanNumeralError

   num = RomanNumeral.from_string("Spam!")  # raises InvalidRomanNumeralError
   num = RomanNumeral.from_string("CLL")  # raises InvalidRomanNumeralError
   num = RomanNumeral(0)  # raises OutOfRangeError
   num = RomanNumeral(4_000)  # raises OutOfRangeError


Licence
=======

This project is licenced under the terms of either the Zero-Clause BSD licence
or the CC0 1.0 Universal licence.
See `LICENCE.rst`__ for the full text of both licences.

__ ./LICENCE.rst


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "roman-numerals-py",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Adam Turner",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/bb/6f/aa38863bef8d46f4f606cb6c218cae86b11de930d259cd9e4a352589b030/roman_numerals_py-2.0.0.tar.gz",
    "platform": null,
    "description": "===============\n roman-numerals\n===============\n\nA library for manipulating well-formed Roman numerals.\n\nIntegers between 1 and 3,999 (inclusive) are supported.\nNumbers beyond this range will return an ``OutOfRangeError``.\n\nThe classical system of roman numerals requires that\nthe same character may not appear more than thrice consecutively,\nmeaning that 'MMMCMXCIX' (3,999) is the largest well-formed Roman numeral.\nThe smallest is 'I' (1), as there is no symbol for zero in Roman numerals.\n\nBoth upper- and lower-case formatting of roman numerals are supported,\nand likewise for parsing strings,\nalthough the entire string must be of the same case.\nNumerals that do not adhere to the classical form are rejected\nwith an ``InvalidRomanNumeralError``.\n\nExample usage\n=============\n\nCreating a roman numeral\n------------------------\n\n.. code-block:: python\n\n   from roman_numerals import RomanNumeral\n\n   num = RomanNumeral(16)\n   assert str(num) == 'XVI'\n\n   num = RomanNumeral.from_string(\"XVI\")\n   assert int(num) == 16\n\n\nConvert a roman numeral to a string\n-----------------------------------\n\n.. code-block:: python\n\n   from roman_numerals import RomanNumeral\n\n   num = RomanNumeral(16)\n   assert str(num) == 'XVI'\n   assert num.to_uppercase() == 'XVI'\n   assert num.to_lowercase() == 'xvi'\n   assert repr(num) == 'RomanNumeral(16)'\n\n\nExtract the decimal value of a roman numeral\n--------------------------------------------\n\n.. code-block:: python\n\n   from roman_numerals import RomanNumeral\n\n   num = RomanNumeral(42)\n   assert int(num) == 42\n\n\nInvalid input\n-------------\n\n.. code-block:: python\n\n   from roman_numerals import RomanNumeral, InvalidRomanNumeralError\n\n   num = RomanNumeral.from_string(\"Spam!\")  # raises InvalidRomanNumeralError\n   num = RomanNumeral.from_string(\"CLL\")  # raises InvalidRomanNumeralError\n   num = RomanNumeral(0)  # raises OutOfRangeError\n   num = RomanNumeral(4_000)  # raises OutOfRangeError\n\n\nLicence\n=======\n\nThis project is licenced under the terms of either the Zero-Clause BSD licence\nor the CC0 1.0 Universal licence.\nSee `LICENCE.rst`__ for the full text of both licences.\n\n__ ./LICENCE.rst\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Docutils -- Python Documentation Utilities",
    "version": "2.0.0",
    "project_urls": {
        "Changelog": "https://github.com/AA-Turner/roman-numerals/blob/master/CHANGES.rst",
        "Code": "https://github.com/AA-Turner/roman-numerals/",
        "Download": "https://pypi.org/project/roman-numerals-py/",
        "Issue tracker": "https://github.com/AA-Turner/roman-numerals/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d9d5ca29876e2f5640afc2cc2ff653715244fcc4fea1f189d972b5410144c04d",
                "md5": "85f462cf7d5aeff8894d915d9f152a41",
                "sha256": "36b6d2b2b4e2d3ba53356503dbb525dafa1334f6c31baef6580a5a1194c0c6f9"
            },
            "downloads": -1,
            "filename": "roman_numerals_py-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "85f462cf7d5aeff8894d915d9f152a41",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 4341,
            "upload_time": "2024-11-14T17:50:55",
            "upload_time_iso_8601": "2024-11-14T17:50:55.935958Z",
            "url": "https://files.pythonhosted.org/packages/d9/d5/ca29876e2f5640afc2cc2ff653715244fcc4fea1f189d972b5410144c04d/roman_numerals_py-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bb6faa38863bef8d46f4f606cb6c218cae86b11de930d259cd9e4a352589b030",
                "md5": "d8ee96649c3a8fcc38d1f03c24b533fd",
                "sha256": "2fcf8219331c0ec5a29d5c4c8553f3edd251696496db117f7181d15687e66f5e"
            },
            "downloads": -1,
            "filename": "roman_numerals_py-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d8ee96649c3a8fcc38d1f03c24b533fd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 8747,
            "upload_time": "2024-11-14T17:50:57",
            "upload_time_iso_8601": "2024-11-14T17:50:57.220761Z",
            "url": "https://files.pythonhosted.org/packages/bb/6f/aa38863bef8d46f4f606cb6c218cae86b11de930d259cd9e4a352589b030/roman_numerals_py-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-14 17:50:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AA-Turner",
    "github_project": "roman-numerals",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "roman-numerals-py"
}
        
Elapsed time: 0.66961s