mirror of
https://github.com/gryf/pythonhelper.git
synced 2025-12-19 04:20:20 +01:00
Initial iterator-based implementation.
This commit is contained in:
@@ -154,7 +154,7 @@ class SimplePythonTagsParser(object):
|
|||||||
Parameters
|
Parameters
|
||||||
|
|
||||||
source -- source for which the tags will be generated. It must
|
source -- source for which the tags will be generated. It must
|
||||||
provide callable method readline (i.e. as file objects do).
|
be a generator.
|
||||||
"""
|
"""
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@@ -182,14 +182,7 @@ class SimplePythonTagsParser(object):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# go through all the lines in the source and localize all Python tags in it {{{
|
# go through all the lines in the source and localize all Python tags in it {{{
|
||||||
while 1:
|
for line in self.source:
|
||||||
# get next line
|
|
||||||
line = self.source.readline()
|
|
||||||
|
|
||||||
# finish when we reach the end of the source {{{
|
|
||||||
if (line == ''):
|
|
||||||
break
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
# increase line number
|
# increase line number
|
||||||
lineNumber += 1
|
lineNumber += 1
|
||||||
@@ -383,7 +376,12 @@ class SimplePythonTagsParser(object):
|
|||||||
|
|
||||||
|
|
||||||
def vimBufferIterator(vimBuffer):
|
def vimBufferIterator(vimBuffer):
|
||||||
return VimReadlineBuffer(vimBuffer)
|
buf = VimReadlineBuffer(vimBuffer)
|
||||||
|
while True:
|
||||||
|
line = buf.readline()
|
||||||
|
if line == '':
|
||||||
|
break
|
||||||
|
yield line
|
||||||
|
|
||||||
# class VimReadlineBuffer() {{{
|
# class VimReadlineBuffer() {{{
|
||||||
class VimReadlineBuffer(object):
|
class VimReadlineBuffer(object):
|
||||||
|
|||||||
Reference in New Issue
Block a user