HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/__pycache__/roman.cpython-312.pyc
�

"*_P��*�ddlmZ	dZdZdZdZddlZddlZddlZddl	Z	Gd�de
�ZGd	�d
e�ZGd�de�Z
Gd
�de�ZdZd�Zej"dej$�Zd�Zd�Zd�Zedk(re	j0e��yy)�)�print_functionz&Mark Pilgrim (f8dy@diveintopython.org)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��eZdZy)�
RomanErrorN��__name__�
__module__�__qualname__���'/usr/lib/python3/dist-packages/roman.pyrr���rrc��eZdZy)�OutOfRangeErrorNrr
rrrrr
rrc��eZdZy)�NotIntegerErrorNrr
rrrr#r
rrc��eZdZy)�InvalidRomanNumeralErrorNrr
rrrr'r
rr)
)�Mi�)�CMi�)�Di�)�CDi�)�C�d)�XC�Z)�L�2)�XL�()�X�
)�IX�	)�V�)�IV�)�I�c���t|t�std��d|cxkrdkstd��td��|dk(ryd}tD]\}}||k\s�||z
}||z}||k\r��|S)z convert integer to Roman numeralzdecimals can not be converted���i�z%number out of range (must be 0..4999)r�N�)�
isinstance�intrr�romanNumeralMap)�n�result�numeral�integers    r�toRomanr5;s����a����=�>�>���M�T�M��E�F�F�
��E�F�F�	�A�v��
�F�+������7�l��g��F�
��L�A��7�l���Mra8
    ^                   # 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
    c��|std��|dk(rytj|�std|z��d}d}tD]B\}}|||t	|�z|k(s�||z
}|t	|�z
}|||t	|�z|k(r�(�D|S)z convert Roman numeral to integerzInput can not be blankr,rzInvalid Roman numeral: %s)r�romanNumeralPattern�searchr0�len)�sr2�indexr3r4s     r�	fromRomanr<\s����&�'?�@�@�	�C�x���%�%�a�(�&�'B�Q�'F�G�G�
�F�
�E�+�"������e�c�'�l�*�+�w�6��g��F��S��\�!�E���e�c�'�l�*�+�w�6�"��Mrc���tjdd��}|jdd��|jddd	d
d��|j�}|j|_|S)
N�romanz)convert between roman and arabic numerals)�prog�description�numberzthe value to convert)�helpz-rz	--reverse�
store_trueFz<convert roman to numeral (case insensitive) [default: False])�action�defaultrB)�argparse�ArgumentParser�add_argument�
parse_argsrA)�parser�argss  rrIrIqsp��
�
$�
$�
�?��F�����'=��>�
����k���
K�	�M�����D��+�+�D�K��Krc�$�t�}|jr@|jj�}t	|�}t|�tjSt
|j�}t|�}t|�tjS)N)
rI�reverserA�upperr<�printr/r5�os�EX_OK)rK�u�r�ir1s     r�mainrU�sf���<�D��|�|��K�K������a�L��
�a���8�8�O�	
�������A�J��
�a��
�8�8�Or�__main__)�
__future__r�
__author__�__version__�__date__�
__copyright__rFrP�re�sys�	Exceptionrrrrr0r5�compile�VERBOSEr7r<rIrUr�exitr
rr�<module>rbs���%�)�
5�
�����	�
��	�	�
�	��	�	�j�	�	�j�	�	�z�	�
���(!�b�j�j�
"�
���
���*�"��z���C�H�H�T�V��r