(self, file_spec, mode)
return device, dev_param
Get a device object and parameters from a file specification.
Get a device object and parameters from a file specification.
Get a device object and parameters from a file specification .
def _get_device_param(self, file_spec, mode):
        """Get a device object and parameters from a file specification."""
        name = bytes(file_spec)
        split = name.split(b':', 1)
        if len(split) > 1:
            # colon (:) found
            dev_name = split[0].upper() + b':'
            dev_param = split[1]
            try:
                device = self._devices[dev_name]
            except KeyError:
                # not an allowable device or drive name
                # bad file number, for some reason
                raise error.BASICError(error.BAD_FILE_NUMBER)
        else:
            device = self._devices[self._current_device + b':']
            # MS-DOS device aliases - these can't be names of disk files
            if device != self._devices[b'CAS1:'] and name in DOS_DEVICE_FILES:
                if name == b'AUX':
                    device, dev_param = self._devices[b'COM1:'], b''
                elif name == b'CON' and mode == b'I':
                    device, dev_param = self._devices[b'KYBD:'], b''
                elif name == b'CON' and mode == b'O':
                    device, dev_param = self._devices[b'SCRN:'], b''
                elif name == b'PRN':
                    device, dev_param = self._devices[b'LPT1:'], b''
                elif name == b'NUL':
                    device, dev_param = devicebase.NullDevice(), b''
            else:
                # open file on default device
                dev_param = name
        return device, dev_param
def _get_device_param ( self , file_spec , mode ) : name = bytes ( file_spec ) split = name . split ( b':' , 1 ) if len ( split ) > 1 : # colon (:) found dev_name = split [ 0 ] . upper ( ) + b':' dev_param = split [ 1 ] try : device = self . _devices [ dev_name ] except KeyError : # not an allowable device or drive name # bad file number, for some reason raise error . BASICError ( error . BAD_FILE_NUMBER ) else : device = self . _devices [ self . _current_device + b':' ] # MS-DOS device aliases - these can't be names of disk files if device != self . _devices [ b'CAS1:' ] and name in DOS_DEVICE_FILES : if name == b'AUX' : device , dev_param = self . _devices [ b'COM1:' ] , b'' elif name == b'CON' and mode == b'I' : device , dev_param = self . _devices [ b'KYBD:' ] , b'' elif name == b'CON' and mode == b'O' : device , dev_param = self . _devices [ b'SCRN:' ] , b'' elif name == b'PRN' : device , dev_param = self . _devices [ b'LPT1:' ] , b'' elif name == b'NUL' : device , dev_param = devicebase . NullDevice ( ) , b'' else : # open file on default device dev_param = name return device , dev_param