Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
fixdiv.FileContext Class Reference

List of all members.

Public Member Functions

def __init__
def fill
def readline
def truncate
def __getitem__
def report

Public Attributes

 fp
 window
 lineno
 eoflookahead
 lookahead
 buffer

Detailed Description

Definition at line 315 of file fixdiv.py.


Constructor & Destructor Documentation

def fixdiv.FileContext.__init__ (   self,
  fp,
  window = 5,
  lineno = 1 
)

Definition at line 316 of file fixdiv.py.

00316 
00317     def __init__(self, fp, window=5, lineno=1):
00318         self.fp = fp
00319         self.window = 5
00320         self.lineno = 1
00321         self.eoflookahead = 0
00322         self.lookahead = []
        self.buffer = []

Member Function Documentation

def fixdiv.FileContext.__getitem__ (   self,
  index 
)

Definition at line 340 of file fixdiv.py.

00340 
00341     def __getitem__(self, index):
00342         self.fill()
00343         bufstart = self.lineno - len(self.buffer)
00344         lookend = self.lineno + len(self.lookahead)
00345         if bufstart <= index < self.lineno:
00346             return self.buffer[index - bufstart]
00347         if self.lineno <= index < lookend:
00348             return self.lookahead[index - self.lineno]
        raise KeyError

Here is the call graph for this function:

def fixdiv.FileContext.fill (   self)

Definition at line 323 of file fixdiv.py.

00323 
00324     def fill(self):
00325         while len(self.lookahead) < self.window and not self.eoflookahead:
00326             line = self.fp.readline()
00327             if not line:
00328                 self.eoflookahead = 1
00329                 break
            self.lookahead.append(line)

Here is the caller graph for this function:

Definition at line 330 of file fixdiv.py.

00330 
00331     def readline(self):
00332         self.fill()
00333         if not self.lookahead:
00334             return ""
00335         line = self.lookahead.pop(0)
00336         self.buffer.append(line)
00337         self.lineno += 1
        return line

Here is the call graph for this function:

Here is the caller graph for this function:

def fixdiv.FileContext.report (   self,
  first,
  last = None,
  mark = "*" 
)

Definition at line 349 of file fixdiv.py.

00349 
00350     def report(self, first, last=None, mark="*"):
00351         if last is None:
00352             last = first
00353         for i in range(first, last+1):
00354             try:
00355                 line = self[first]
00356             except KeyError:
00357                 line = "<missing line>"
00358             print(mark, chop(line))

Here is the call graph for this function:

Definition at line 338 of file fixdiv.py.

00338 
00339     def truncate(self):
        del self.buffer[-window:]

Member Data Documentation

Definition at line 322 of file fixdiv.py.

Definition at line 320 of file fixdiv.py.

Definition at line 317 of file fixdiv.py.

Definition at line 319 of file fixdiv.py.

Definition at line 321 of file fixdiv.py.

Definition at line 318 of file fixdiv.py.


The documentation for this class was generated from the following file: