Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
64129aa4
Commit
64129aa4
authored
Aug 07, 2001
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Roman numeral conversion to Iterators based on Tino's algorithm.
parent
d41ce08c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
lib/python/ZTUtils/Iterator.py
lib/python/ZTUtils/Iterator.py
+19
-2
No files found.
lib/python/ZTUtils/Iterator.py
View file @
64129aa4
...
...
@@ -84,8 +84,10 @@
##############################################################################
__doc__
=
'''Iterator class
$Id: Iterator.py,v 1.1 2001/04/27 16:38:52 evan Exp $'''
__version__
=
'$Revision: 1.1 $'
[
11
:
-
2
]
$Id: Iterator.py,v 1.2 2001/08/07 20:53:54 evan Exp $'''
__version__
=
'$Revision: 1.2 $'
[
11
:
-
2
]
import
string
class
Iterator
:
'''Simple Iterator class'''
...
...
@@ -123,6 +125,20 @@ class Iterator:
def
Letter
(
self
):
return
self
.
letter
(
base
=
ord
(
'A'
))
def
Roman
(
self
,
rnvalues
=
(
(
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'
))
):
n
=
self
.
index
+
1
s
=
''
for
v
,
r
in
rnvalues
:
rct
,
n
=
divmod
(
n
,
v
)
s
=
s
+
r
*
rct
return
s
def
roman
(
self
,
lower
=
string
.
lower
):
return
lower
(
self
.
Roman
())
def
start
(
self
):
return
self
.
nextIndex
==
1
def
end
(
self
):
...
...
@@ -135,3 +151,4 @@ class Iterator:
def
length
(
self
):
return
len
(
self
.
seq
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment