ó
Č++Qc           @   sÚ   d  Z  d Z d Z d Z d Z d d l Z d e f d     YZ d	 e f d
     YZ d e f d     YZ	 d e f d     YZ
 d, d- d. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 f Z d)   Z e j d* e j  Z d+   Z d S(9   s"   Convert to and from Roman numeralss&   Mark Pilgrim (f8dy@diveintopython.org)s   1.4s   8 August 2001sg  Copyright (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
i˙˙˙˙Nt
   RomanErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s)   /usr/lib/python2.7/dist-packages/roman.pyR       s    t   OutOfRangeErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s)   /usr/lib/python2.7/dist-packages/roman.pyR      s    t   NotIntegerErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s)   /usr/lib/python2.7/dist-packages/roman.pyR      s    t   InvalidRomanNumeralErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s)   /usr/lib/python2.7/dist-packages/roman.pyR      s    t   Mič  t   CMi  t   Diô  t   CDi  t   Cid   t   XCiZ   t   Li2   t   XLi(   t   Xi
   t   IXi	   t   Vi   t   IVi   t   Ii   c         C   s   t  |  t  s t d   n  d |  k  o5 d k  n sI t d   n  d } x; t D]3 \ } } x$ |  | k r | | 7} |  | 8}  qe WqV W| S(   s    convert integer to Roman numerals   decimals can not be convertedi    i  s%   number out of range (must be 1..4999)t    (   t
   isinstancet   intR   R   t   romanNumeralMap(   t   nt   resultt   numeralt   integer(    (    s)   /usr/lib/python2.7/dist-packages/roman.pyt   toRoman(   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
    c         C   s   |  s t  d   n  t j |   s7 t  d |    n  d } d } xR t D]J \ } } x; |  | | t |  !| k r | | 7} | t |  7} qY WqJ W| S(   s    convert Roman numeral to integers   Input can not be blanks   Invalid Roman numeral: %si    (   R   t   romanNumeralPatternt   searchR   t   len(   t   sR   t   indexR   R   (    (    s)   /usr/lib/python2.7/dist-packages/roman.pyt	   fromRomanC   s     
(   R   ič  (   R   i  (   R   iô  (   R	   i  (   R
   id   (   R   iZ   (   R   i2   (   R   i(   (   R   i
   (   R   i	   (   R   i   (   R   i   (   R   i   (   t   __doc__t
   __author__t   __version__t   __date__t   __copyright__t   ret	   ExceptionR    R   R   R   R   R   t   compilet   VERBOSER   R!   (    (    (    s)   /usr/lib/python2.7/dist-packages/roman.pyt   <module>   s4   
		
