Next / Previous / Contents / Shipman's homepage

23. Scan.__findInput(): Find the input stream

logscan.py
# - - -   S c a n . _ _ f i n d I n p u t

    def __findInput(self, inFile):
        '''Take care of opening the input if necessary.

          [ if inFile is a string ->
              if inFile can be opened for reading ->
                self.fileName  :=  inFile
                self.file  :=  that file, so opened
              else -> raise IOError
                self.fileName = None
                self.file  :=  inFile ]
        '''
        #-- 1 --
        # [ if inFile is not a string ->
        #     self.fileName  :=  None
        #     self.file  :=  inFile
        #     return
        #   else ->
        #     self.fileName  :=  inFile ]
        if not isinstance(inFile, basestring):
            self.fileName = None
            self.file = inFile
            return
        self.fileName = inFile

        #-- 2 --
        # [ if inFile can be opened for reading ->
        #     self.file  :=  that file, so opened
        #   else -> raise IOError ]
        self.file = open(inFile)