(self, data, msg_format="original", filename=None)
ApiMsg Constructor

        Args:
            data       : bytes array with the data to send through an API
                         message.
            msg_format : message format corresponding to the input data array.
                         It could be the original data ("original"), the
                         encapsulated version of the original data
                         ("encapsulated"), the encrypted version ("encrypted"),
                         or the FEC-encoded format ("fec_encoded").
            filename   : Name of the file represented by the input data, when
                         the data corresponds to a file.
ApiMsg Constructor
ApiMsg Constructor
def __init__(self, data, msg_format="original", filename=None):
        """ApiMsg Constructor

        Args:
            data       : bytes array with the data to send through an API
                         message.
            msg_format : message format corresponding to the input data array.
                         It could be the original data ("original"), the
                         encapsulated version of the original data
                         ("encapsulated"), the encrypted version ("encrypted"),
                         or the FEC-encoded format ("fec_encoded").
            filename   : Name of the file represented by the input data, when
                         the data corresponds to a file.
        """
        assert (isinstance(data, bytes))
        assert (msg_format in data_formats), "Unknown message format"

        # Data containers
        self.data = {
            'original': None,  # Original data, before encapsulation
            'encapsulated': None,  # After encapsulation
            'encrypted': None,  # After encryption
            'fec_encoded': None  # After forward error correction
        }

        # The input data fills one of the containers:
        self.data[msg_format] = data
        logger.debug("{} message has {:d} bytes".format(
            msg_format.replace("_", " ").title(), len(data)))

        # When the file name is empty, use a timestamp:
        self.filename = filename if filename is not None else \
            time.strftime("%Y%m%d%H%M%S")
        if (filename is not None):
            logger.debug("File name: {}".format(filename))
def __init__ ( self , data , msg_format = "original" , filename = None ) : assert ( isinstance ( data , bytes ) ) assert ( msg_format in data_formats ) , "Unknown message format" # Data containers self . data = { 'original' : None , # Original data, before encapsulation 'encapsulated' : None , # After encapsulation 'encrypted' : None , # After encryption 'fec_encoded' : None # After forward error correction } # The input data fills one of the containers: self . data [ msg_format ] = data logger . debug ( "{} message has {:d} bytes" . format ( msg_format . replace ( "_" , " " ) . title ( ) , len ( data ) ) ) # When the file name is empty, use a timestamp: self . filename = filename if filename is not None else time . strftime ( "%Y%m%d%H%M%S" ) if ( filename is not None ) : logger . debug ( "File name: {}" . format ( filename ) )