V!\c@sdZdZdZdZdZddlZdefdYZd efd YZd efd YZ d efdYZ d,d-d.d/d0d1d2d3d4d5d6d7d8f Z d)Z ej d*ejZd+ZdS(9s"Convert to and from Roman numeralss&Mark Pilgrim (f8dy@diveintopython.org)s1.4s 8 August 2001sgCopyright (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 iNt RomanErrorcBseZRS((t__name__t __module__(((s8/tmp/pip-install-usGedi/docutils/docutils/utils/roman.pyRstOutOfRangeErrorcBseZRS((RR(((s8/tmp/pip-install-usGedi/docutils/docutils/utils/roman.pyRstNotIntegerErrorcBseZRS((RR(((s8/tmp/pip-install-usGedi/docutils/docutils/utils/roman.pyRstInvalidRomanNumeralErrorcBseZRS((RR(((s8/tmp/pip-install-usGedi/docutils/docutils/utils/roman.pyRstMitCMitDitCDitCidtXCiZtLi2tXLi(tXi tIXi tVitIVitIicCsd|kodkns(tdnt||krFtdnd}x;tD]3\}}x$||kr||7}||8}qbWqSW|S(s convert integer to Roman numeraliis%number out of range (must be 1..4999)sdecimals can not be convertedt(RtintRtromanNumeralMap(tntresulttnumeraltinteger((s8/tmp/pip-install-usGedi/docutils/docutils/utils/roman.pyttoRoman(s   s8 ^ # 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 cCs|stdntj|s1td|nd}d}xRtD]J\}}x;|||t|!|kr||7}|t|7}qSWqDW|S(s convert Roman numeral to integersInput can not be blanksInvalid Roman numeral: %si(RtromanNumeralPatterntsearchRtlen(tsRtindexRR((s8/tmp/pip-install-usGedi/docutils/docutils/utils/roman.pyt fromRomanCs   (Ri(Ri(Ri(R i(R id(R iZ(R i2(R i((Ri (Ri (Ri(Ri(Ri(t__doc__t __author__t __version__t__date__t __copyright__tret ExceptionRRRRRRtcompiletVERBOSERR (((s8/tmp/pip-install-usGedi/docutils/docutils/utils/roman.pyts4