Skip to content

Commit

Permalink
- replace home-rolled conversion with purpose-built module
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Apr 14, 2019
1 parent 464121d commit 196cc59
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 41 deletions.
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -63,6 +63,7 @@
'Acquisition',
'ExtensionClass>=4.1a1',
'RestrictedPython >= 4.0a1',
'roman',
'six',
'zExceptions',
'zope.sequencesort',
Expand Down
44 changes: 3 additions & 41 deletions src/DocumentTemplate/DT_InSV.py
Expand Up @@ -16,6 +16,8 @@
from math import sqrt
import re

import roman

try:
import Missing
mv = Missing.Value
Expand Down Expand Up @@ -81,47 +83,7 @@ def Roman(self, num):
# Force number to be an integer value
num = int(num) + 1

# Initialize roman as an empty string
roman = ''

while num >= 1000:
num = num - 1000
roman = '%sM' % roman

while num >= 500:
num = num - 500
roman = '%sD' % roman

while num >= 100:
num = num - 100
roman = '%sC' % roman

while num >= 50:
num = num - 50
roman = '%sL' % roman

while num >= 10:
num = num - 10
roman = '%sX' % roman

while num >= 5:
num = num - 5
roman = '%sV' % roman

while num < 5 and num >= 1:
num = num - 1
roman = '%sI' % roman

# Replaces special cases in Roman Numerals

roman = roman.replace('DCCCC', 'CM')
roman = roman.replace('CCCC', 'CD')
roman = roman.replace('LXXXX', 'XC')
roman = roman.replace('XXXX', 'XL')
roman = roman.replace('VIIII', 'IX')
roman = roman.replace('IIII', 'IV')

return roman
return roman.toRoman(num)

def value(self, index, name):
data = self.data
Expand Down

0 comments on commit 196cc59

Please sign in to comment.