540 @type str |
540 @type str |
541 @param dataFormat format of the text |
541 @param dataFormat format of the text |
542 @type str |
542 @type str |
543 @return converted text |
543 @return converted text |
544 @rtype bytearray |
544 @rtype bytearray |
545 """ |
545 @exception ValueError raised to indicate an invalid dataFormat |
546 assert dataFormat in self.__formatAndValidators.keys() |
546 parameter |
|
547 """ |
|
548 if dataFormat not in self.__formatAndValidators.keys(): |
|
549 raise ValueError("Bad value for 'dataFormat' parameter.") |
547 |
550 |
548 if dataFormat == "hex": # hex format |
551 if dataFormat == "hex": # hex format |
549 ba = bytearray(QByteArray.fromHex( |
552 ba = bytearray(QByteArray.fromHex( |
550 bytes(txt, encoding="ascii"))) |
553 bytes(txt, encoding="ascii"))) |
551 elif dataFormat == "dec": # decimal format |
554 elif dataFormat == "dec": # decimal format |
569 @type bytearray |
572 @type bytearray |
570 @param dataFormat format of the text |
573 @param dataFormat format of the text |
571 @type str |
574 @type str |
572 @return formatted text |
575 @return formatted text |
573 @rtype str |
576 @rtype str |
574 """ |
577 @exception ValueError raised to indicate an invalid dataFormat |
575 assert dataFormat in self.__formatAndValidators.keys() |
578 parameter |
|
579 """ |
|
580 if dataFormat not in self.__formatAndValidators.keys(): |
|
581 raise ValueError("Bad value for 'dataFormat' parameter.") |
576 |
582 |
577 if dataFormat == "hex": # hex format |
583 if dataFormat == "hex": # hex format |
578 txt = "{0:x}".format(self.__bytearray2int(array)) |
584 txt = "{0:x}".format(self.__bytearray2int(array)) |
579 elif dataFormat == "dec": # decimal format |
585 elif dataFormat == "dec": # decimal format |
580 txt = "{0:d}".format(self.__bytearray2int(array)) |
586 txt = "{0:d}".format(self.__bytearray2int(array)) |