(self, fileob)
Read the metadata values from a file object.
Read the metadata values from a file object.
Read the metadata values from a file object .
def read_file(self, fileob):
        """Read the metadata values from a file object."""
        msg = message_from_file(fileob)
        self._fields['Metadata-Version'] = msg['metadata-version']

        # When reading, get all the fields we can
        for field in _ALL_FIELDS:
            if field not in msg:
                continue
            if field in _LISTFIELDS:
                # we can have multiple lines
                values = msg.get_all(field)
                if field in _LISTTUPLEFIELDS and values is not None:
                    values = [tuple(value.split(',')) for value in values]
                self.set(field, values)
            else:
                # single line
                value = msg[field]
                if value is not None and value != 'UNKNOWN':
                    self.set(field, value)
def read_file ( self , fileob ) : msg = message_from_file ( fileob ) self . _fields [ 'Metadata-Version' ] = msg [ 'metadata-version' ] # When reading, get all the fields we can for field in _ALL_FIELDS : if field not in msg : continue if field in _LISTFIELDS : # we can have multiple lines values = msg . get_all ( field ) if field in _LISTTUPLEFIELDS and values is not None : values = [ tuple ( value . split ( ',' ) ) for value in values ] self . set ( field , values ) else : # single line value = msg [ field ] if value is not None and value != 'UNKNOWN' : self . set ( field , value )