Next / Previous / Contents / Shipman's homepage

28. class PageNoField: Page number field

This class inherits from FieldItem, but it doesn't have a .scanField() method because the page number comes from the compiler's PageHeader object.

baseclasses.py
# - - - - -   c l a s s   P a g e N o F i e l d   - - - - -

class PageNoField(FieldItem):
    """Represents a page number field.

      Exports:  As inherited.
    """

28.1. PageNoField.flatten()

Generic field flattener for a page number. Page numbers are always right-justified in the output field.

baseclasses.py
# - - -   P a g e N o F i e l d . f l a t t e n   - - -

#   @staticmethod
    def flatten ( pageNoField ):
        """Flatten a PageNoField.
        """
        if  pageNoField is None:
            return BLANK_PAGE_NO
        else:
            return pageNoField.value.rjust ( PAGE_NO_L )

    flatten  =  staticmethod ( flatten )