HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //proc/thread-self/root/lib/python3.6/site-packages/docutils/utils/__pycache__/roman.cpython-36.pyc
3

w2�e
�@s�dZdZdZdZdZddlZGdd�de�ZGd	d
�d
e�ZGdd�de�Z	Gd
d�de�Z
d;Zd)d*�Zej
d+ej�Zd,d-�ZdS)<z"Convert to and from Roman numeralsz&Mark Pilgrim ([email protected])z1.4z
8 August 2001agCopyright (c) 2001 Mark Pilgrim

This program is part of "Dive Into Python", a free Python tutorial for
experienced programmers.  Visit http://diveintopython.org/ for the
latest version.

This program is free software; you can redistribute it and/or modify
it under the terms of the Python 2.1.1 license, available at
http://www.python.org/2.1.1/license.html
�Nc@seZdZdS)�
RomanErrorN)�__name__�
__module__�__qualname__�rr�/usr/lib/python3.6/roman.pyrsrc@seZdZdS)�OutOfRangeErrorN)rrrrrrrrsrc@seZdZdS)�NotIntegerErrorN)rrrrrrrr	sr	c@seZdZdS)�InvalidRomanNumeralErrorN)rrrrrrrr
sr
�M���CM��D���CD��C�d�XC�Z�L�2�XL�(�X�
�IX�	�V��IV��I�cCsld|kodkns td��t|�|kr4td��d}x.tD]&\}}x||krb||7}||8}qHWq>W|S)z convert integer to Roman numeralri�z%number out of range (must be 1..4999)zdecimals can not be converted�)r�intr	�romanNumeralMap)�n�result�numeral�integerrrr�toRoman(s
r,a8
    ^                   # beginning of string
    M{0,4}              # thousands - 0 to 4 M's
    (CM|CD|D?C{0,3})    # hundreds - 900 (CM), 400 (CD), 0-300 (0 to 3 C's),
                        #            or 500-800 (D, followed by 0 to 3 C's)
    (XC|XL|L?X{0,3})    # tens - 90 (XC), 40 (XL), 0-30 (0 to 3 X's),
                        #        or 50-80 (L, followed by 0 to 3 X's)
    (IX|IV|V?I{0,3})    # ones - 9 (IX), 4 (IV), 0-3 (0 to 3 I's),
                        #        or 5-8 (V, followed by 0 to 3 I's)
    $                   # end of string
    cCsr|std��tj|�s"td|��d}d}xBtD]:\}}x0|||t|��|krh||7}|t|�7}q:Wq0W|S)z convert Roman numeral to integerzInput can not be blankzInvalid Roman numeral: %sr)r
�romanNumeralPattern�searchr'�len)�sr)�indexr*r+rrr�	fromRomanCs
r2�rr�r
r�rr�rr�rr�rr�rr�rr�rr�rr�rr �r!r"�r#r$)
r3r4r5r6r7r8r9r:r;r<r=r>r?)�__doc__�
__author__�__version__Z__date__Z
__copyright__�re�	Exceptionrrr	r
r'r,�compile�VERBOSEr-r2rrrr�<module>s4