Next / Previous / Contents / Shipman's homepage

21. class Heading: Information for the running head

This class encapsulates everything needed to produce the static content for the running head.

Headers contain these elements:

Depending on the specific page format, these elements may occur either in “right-hand order,” as above, or in “left-hand order,” with the elements reversed so that the page number is on the left, as with duplex verso pages.

listext2
# - - - - -   c l a s s   H e a d i n g

class Heading(object):
    '''Represents the contents of the running head.

      Exports:
        Heading(inputFile):
          [ (Args() is valid) and
            (inputFile is an InputFile instance) ->
              return a new Heading instance representing the
              header content for Args() and inputFile ]
        .inputFile:     [ as passed to constructor, read-only ]
        .rightContent(pages, flowName):
          [ (pages is a page-sequence et.Element) and
            (flowName is the name of a simpl-page-master) ->
              pages  +:=  a new static-content for flowName showing
                  self with the page number on the right side ]
        .leftContent(pages, flowName):
          [ (pages is a page-sequence et.Element) and
            (flowName is the name of a simpl-page-master) ->
              pages  +:=  a new static-content for flowName showing
                  self with the page number on the left side ]

      State/Invariants:
        .__timestamp:
          [ modification timestamp for Args().inFileName as
            "YYYY-MM-DD HH:MM:SS" ]
        .__pathPart:
          [ absolute path to directory for Args().inFileName, ending
            with a '/' ]
        .__filePart:    [ file name part of Args().inFileName ]
    '''

21.1. Heading.__init__(): Constructor

listext2
# - - -   H e a d i n g . _ _ i n i t _ _

    def __init__(self, inputFile):
        '''Constructor.
        '''
        #-- 1
        self.inputFile = inputFile

The other state items for the instance are derived from the name of the input file: its modification time, directory path name, and file name.

listext2
        #-- 2
        # [ self.__timestamp  :=  as invariant ]
        self.__getModTime()

        #-- 3
        # [ self.__pathPart  :=  as invariant
        #   self.__filePart  :=  as invariant ]
        self.__getPaths()