Ë v*¶ìæÓøãó—dZdZdZdZdZddlZGd„de«ZGd „d e«ZGd „d e«Z Gd „de«Z dZ d„Z ejdej«Zd„Zy)z"Convert to and from Roman numeralsz&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__©óú9/usr/lib/python3.12/site-packages/docutils/utils/roman.pyrró…r rcó —eZdZy)ÚOutOfRangeErrorNrr r r rrr r rcó —eZdZy)ÚNotIntegerErrorNrr r r rrr r rcó —eZdZy)ÚInvalidRomanNumeralErrorNrr r r rrr r r) )ÚMiè)ÚCMi„)ÚDiô)ÚCDi�)ÚCéd)ÚXCéZ)ÚLé2)ÚXLé()ÚXé )ÚIXé )ÚVé)ÚIVé)ÚIécóÈ—d|cxkrdkstd«‚td«‚t|«|k7r td«‚d}tD]\}}||k\sŒ ||z }||z}||k\rŒŒ|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Úintegers r ÚtoRomanr1+s€à �ŒL�DŠLÜÐEÓFÐFð ÜÐEÓFÐFÜ ˆ1ƒv�‚{ÜÐ=Ó>Ð>à €Fß+ш�Ø�7‹lØ �gÑ ˆFØ �‰LˆAð�7Œlð,ð €Mr 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 có—|s td«‚tj|«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 blankzInvalid Roman numeral: %sr)rÚromanNumeralPatternÚsearchr,Úlen)Úsr.Úindexr/r0s r Ú fromRomanr8Hsš€á Ü&Ð'?Ó@Ð@ä × %Ñ % aÔ (Ü&Ð'BÀQÑ'FÓGÐGà €FØ €Eß+ш�Ø��eœC ›LÑ(Ð)¨WÓ4Ø �gÑ ˆFØ ”S˜“\Ñ !ˆEð��eœC ›LÑ(Ð)¨WÔ4ð,ð €Mr )Ú__doc__Ú __author__Ú __version__Ú__date__Ú __copyright__ÚreÚ Exceptionrrrrr,r1ÚcompileÚVERBOSEr3r8r r r ÚrBswðÙ(à 5€ Ø€ Ø €ð € ó ô"�Ô!Ü'�jÔ'Ü'�jÔ'Ü0˜zÔ0ð €ò ð !�b—j‘jð "ð �‰ó Ðór