mò …õOc@s×dZdZdZdZdZdkZdefd„ƒYZdefd „ƒYZd efd „ƒYZ d efd „ƒYZ d+d,d-d.d/d0d1d2d3d4d5d6d7f Z d(„Z ei d)eiƒZd*„ZdS(8s"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 Nt RomanErrorcBstZRS(N(t__name__t __module__(((tn/home/project-web/docutils/web-update/infrastructure/update-dir/aux/snapshots/docutils/docutils/utils/roman.pyRstOutOfRangeErrorcBstZRS(N(RR(((RRstNotIntegerErrorcBstZRS(N(RR(((RRstInvalidRomanNumeralErrorcBstZRS(N(RR(((RRstMiètCMi„tDiôtCDi�tCidtXCiZtLi2tXLi(tXi tIXi tVitIVitIicCs•d|jo djnp td‚nt|ƒ|jo td‚nd}x=tD]5\}}x&||jo||7}||8}qgWqXW|S(s convert integer to Roman numeraliiˆs%number out of range (must be 1..4999)sdecimals can not be convertedtN(tnRtintRtresulttromanNumeralMaptnumeraltinteger(RRRR((RttoRoman(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œ|p td‚nti|ƒptd|‚nd}d}xTtD]L\}}x=|||t |ƒ!|jo||7}|t |ƒ7}qWWqHW|S(s convert Roman numeral to integersInput can not be blanksInvalid Roman numeral: %siN( tsRtromanNumeralPatterntsearchRtindexRRRtlen(RRRRR((Rt fromRomanCs   (Riè(Ri„(R iô(R i�(R id(R iZ(R i2(Ri((Ri (Ri (Ri(Ri(Ri(t__doc__t __author__t __version__t__date__t __copyright__tret ExceptionRRRRRRtcompiletVERBOSERR!( R&RRRRRR#R%R'RRR$R!((Rt?s -