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
26e2a24a
Commit
26e2a24a
authored
Dec 13, 2001
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Iterator better at recognizing Python 2.2 iterators.
parent
b6c7f455
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
+22
-8
lib/python/ZTUtils/Iterator.py
lib/python/ZTUtils/Iterator.py
+22
-8
No files found.
lib/python/ZTUtils/Iterator.py
View file @
26e2a24a
...
...
@@ -18,8 +18,8 @@ The Iterator() function accepts either a sequence or a Python
iterator. The next() method fetches the next item, and returns
true if it succeeds.
$Id: Iterator.py,v 1.
4 2001/12/12 02:21:56
evan Exp $'''
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
$Id: Iterator.py,v 1.
5 2001/12/13 18:35:32
evan Exp $'''
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
import
string
...
...
@@ -31,12 +31,12 @@ class Iterator:
nextIndex
=
0
def
__init__
(
self
,
seq
):
self
.
seq
=
seq
if
hasattr
(
seq
,
'next'
)
:
i
nner
=
iterInner
else
:
inner
=
seqInner
self
.
_inner
=
inner
self
.
_prep_next
=
inner
.
prep_next
for
inner
in
seqInner
,
iterInner
:
i
f
inner
.
_supports
(
seq
):
self
.
_inner
=
inner
self
.
_prep_next
=
inner
.
prep_next
return
raise
TypeError
,
"Iterator does not support %s"
%
`seq`
def
__getattr__
(
self
,
name
):
try
:
...
...
@@ -134,6 +134,13 @@ class InnerBase:
class
SeqInner
(
InnerBase
):
'''Inner class for sequence Iterators'''
def
_supports
(
self
,
ob
):
try
:
ob
[
0
]
except
TypeError
:
return
0
except
:
pass
return
1
def
prep_next
(
self
,
it
):
i
=
it
.
nextIndex
try
:
...
...
@@ -157,6 +164,13 @@ except NameError:
class
IterInner
(
InnerBase
):
'''Iterator inner class for Python iterators'''
def
_supports
(
self
,
ob
):
try
:
if
hasattr
(
ob
,
'next'
)
and
(
ob
is
iter
(
ob
)):
return
1
except
:
return
0
def
prep_next
(
self
,
it
):
try
:
it
.
_next
=
it
.
seq
.
next
()
...
...
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