Next / Previous / Contents / Shipman's homepage

20. class InputFile: Input sliced to fit

This class represents the entire input file, with each line broken into pieces that will fit into a column. Each piece is an instance of Section 22, “class OutBlock: One output block”.

listext2
# - - - - -   c l a s s   I n p u t F i l e

class InputFile(object):
    '''Represents the input file with long lines broken up.

      Exports:
        InputFile(inFile, bodyLayout):
          [ (inFile is a readable file-like object) and
            (bodyLayout is a BodyLayout instance) ->
              return a new InputFile instance representing the contents
              of inFile, with line and column breaks applied where
              specified by Args() and bodyLayout ]
        .genBlocks():
          [ generate the contents of self as a sequence of
            OutBlock instances ]
        .nInLines:       [ number of input lines, read-only ]
        .nOutLines:      [ number of output lines, read-only ]
        .nOutCols:       [ number of output columns, read-only ]
        .nOverflows:     [ number of oversized input lines, read-only ]
        .nOutPages:      [ total number of pages ]

      State/Invariants:
        .__blockList:
          [ a sequence of OutBlock instances representing the
            output lines of self ]
    '''

20.1. InputFile.genBlocks(): Generate contained blocks

listext2
# - - -   I n p u t F i l e . g e n B l o c k s

    def genBlocks(self):
        return iter(self.__blockList)