Next / Previous / Contents / Shipman's homepage

67. class Net4Field: Four-character net code

This class represents a four-character net field, such as in the MAWS 2007 protocol. See the specification.

This class is identical to Section 66, “class Net2Field: Two-character net code”, which see for more detailed comments.

baseclasses.py
# - - - - -   c l a s s   N e t 4 F i e l d   - - - - -

class Net4Field(FieldItem):
    """Represents a two-character net field.

      Exports: as inherited.
    """

67.1. Net4Field.scanField()

baseclasses.py
# - - -   N e t 4 F i e l d . s c a n F i e l d   - - -

#   @staticmethod
    def scanField ( encounter, scan, fieldName ):
        """Scan a two-character net field.
        """
        #-- 1 --
        # [ if the line in scan contains at least NET4_L characters ->
        #     scan  :=  scan advanced NET4_L
        #     text  :=  next NET4_L characters from scan, uppercased
        #   else ->
        #     Log()  +:=  error message
        #     raise SyntaxError ]
        try:
            text  =  scan.move ( NET4_L ).upper()
        except IndexError:
            scan.syntax ( "Expecting a %d-character net field." %
                         NET4_L )

        #-- 2 --
        setattr ( encounter, NET_ATTR,
                  Net4Field ( encounter, text ) )

    scanField  =  staticmethod ( scanField )