[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/common/src/utils TextUtils.py
From: |
Jason Cater |
Subject: |
gnue/common/src/utils TextUtils.py |
Date: |
Wed, 30 Apr 2003 16:38:29 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jason Cater <address@hidden> 03/04/30 16:38:28
Modified files:
common/src/utils: TextUtils.py
Log message:
added roman numeral converter for gnue reports
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/utils/TextUtils.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: gnue/common/src/utils/TextUtils.py
diff -c gnue/common/src/utils/TextUtils.py:1.5
gnue/common/src/utils/TextUtils.py:1.6
*** gnue/common/src/utils/TextUtils.py:1.5 Mon Apr 28 18:11:05 2003
--- gnue/common/src/utils/TextUtils.py Wed Apr 30 16:38:28 2003
***************
*** 69,71 ****
--- 69,90 ----
'mm': 25.4}[unit.lower()] * multiplier
return value
+
+
+ #
+ # Convert an integer to a roman numeral
+ #
+ def intToRoman(num):
+ n = int(num) # just in case
+ rv = ""
+ for dec, rom in (
+ (1000, 'M'), (900, 'CM', ),
+ (500, 'D'), (400, 'CD'), (100, 'C'),
+ (90, 'XC'),(50, 'L'), (40, 'XL'),
+ (10, 'X'), (9, 'IX'), (5, 'V'),
+ (4, 'IV'), (1, 'I') ):
+ while (n >= dec):
+ n -= dec;
+ rv += rom;
+ return rv
+