1
0
mirror of https://github.com/gryf/pythonhelper.git synced 2025-12-18 12:00:27 +01:00

Deleted non-iterator code. Refactoring complete.

This commit is contained in:
cheater
2012-02-08 08:03:23 +01:00
committed by cheater
parent aee6f328aa
commit a361304e73

View File

@@ -379,71 +379,6 @@ def vimBufferIterator(vimBuffer):
for line in vimBuffer:
yield line + "\n"
def vimBufferIterator2(vimBuffer):
buf = VimReadlineBuffer(vimBuffer)
while True:
line = buf.readline()
if line == '':
break
yield line
# class VimReadlineBuffer() {{{
class VimReadlineBuffer(object):
# DOC {{{
"""A simple wrapper class around a Vim buffer that provides the readline
method.
"""
# }}}
# METHODS {{{
def __init__(self, vimBuffer):
# DOC {{{
"""Initializes instances of VimReadlineBuffer().
Parameters
vimBuffer -- a Vim buffer
"""
# }}}
# CODE {{{
# remember the settings
self.vimBuffer = vimBuffer
# initialize instance attributes {{{
self.currentLine = -1
self.bufferLines = len(vimBuffer)
# }}}
# }}}
def readline(self):
# DOC {{{
"""Returns the next line from the buffer. If the whole buffer has been
read, returns an empty string.
"""
# }}}
# CODE {{{
# increase the current line counter
self.currentLine += 1
# tell if we reached beyond the last line {{{
if (self.currentLine == self.bufferLines):
return ''
# }}}
# Vim stores the lines without the newlines, so add one
return "%s\n" % (self.vimBuffer[self.currentLine],)
# }}}
# }}}
# }}}
def getNearestLineIndex(row, tagLineNumbers):
# DOC {{{
"""Returns the index of 'tagLineNumbers' that contains the line nearest to