Index: dialin/squish/utils.py =================================================================== diff -u -r2844f230ef5c84799b7577e1a2090c0a47a78d51 -rb0d2a02c06ff44d84ddc67452fd2897ab097a9f0 --- dialin/squish/utils.py (.../utils.py) (revision 2844f230ef5c84799b7577e1a2090c0a47a78d51) +++ dialin/squish/utils.py (.../utils.py) (revision b0d2a02c06ff44d84ddc67452fd2897ab097a9f0) @@ -23,19 +23,19 @@ """ a global 2 seconds default wait mehod which is used to wait for GUI animations mostly to make sure the object is avaialable. - :param vDelay: - :return: + :param vDelay: (int) amout of second for delay + :return: none """ time.sleep(vDelay) def toUXX(vValue, vByteCount, vDelimiter): """ converts the value vValue to hex - :param vValue: the value - :param vByteCount: number of bytes the value will take eg. U32=4, ... - :param vDelimiter: the bytes delimiter - :return: + :param vValue: (int) the value + :param vByteCount: (int) number of bytes the value will take eg. U32=4, ... + :param vDelimiter: (str) the output delimiter + :return: hex formated conversion of the vValue """ x = '{0:0{1}X}'.format(int(vValue) & (2**(4*vByteCount)-1), vByteCount, 'x') bytes = partition(x, 2) @@ -45,57 +45,60 @@ def toI32(vValue, vDelimiter = ""): """ a convenient method for toUXX to convert the value vValue to integer 4 bytes - :param vValue: - :param vDelimiter: - :return: + :param vValue: (int) the value + :param vDelimiter: (str) the output delimiter + :return: hex formated conversion of the vValue to int 4 bytes """ return toUXX(vValue, 8, vDelimiter) def toI16(vValue, vDelimiter = ""): """ a convenient method for toUXX to convert the value vValue to integer 2 bytes - :param vValue: - :param vDelimiter: - :return: + :param vValue: (int) the value + :param vDelimiter: (str) the output delimiter + :return: hex formated conversion of the vValue to int 2 bytes """ return toUXX(vValue, 4, vDelimiter) def toI08(vValue, vDelimiter = ""): """ a convenient method for toUXX to convert the value vValue to integer 1 byte - :param vValue: - :param vDelimiter: - :return: + :param vValue: (int) the value + :param vDelimiter: (str) the output delimiter + :return: hex formated conversion of the vValue to int 1 bytes """ return toUXX(vValue, 2, vDelimiter) def toF32(vValue): """ converts value vValue to floating point 4 bytes. - :param vValue: - :return: + :param vValue: (float) the value + :return: hex formated conversion of the vValue to float 4 bytes """ return '{:08X}'.format(struct.unpack('f', vValue))[0],'X') def partition(vString, vPart, vRightDirection=True): """ - - :param vString: - :param vPart: - :param vRightDirection: - :return: + splits the given string into sections of vPart long + and puts the sections from left to right if vRightDirection is False + and puts the sections from right to left if vRightDirection is True + after the split is done + :param vString: (str) the given string + :param vPart: (int) length of the section + :param vRightDirection: (bool) order of sections in the output list + :return: (list) the section of the string vString in list """ return [vString[i: i + vPart] for i in range(0, len(vString), vPart)][::-1 if vRightDirection else 1] def padding(vString, vLen): """ - - :param vString: - :param vLen: - :return: + added zero at the right side of the string to be of length of vLen + :param vString: (str) the string to add trainling zero to + :param vLen: (int) the entire length of the string + :return: (str) padded string """ lStr = len(vString) lPad = int(lStr / vLen) * vLen + ( vLen * (1 if lStr % vLen else 0) ) @@ -104,31 +107,31 @@ def tstStart(vTestName): """ test case start print out with time - :param vTestName: - :return: + :param vTestName: (str) name of the test case + :return: none - prints out on the console """ print(time.strftime("%H:%M:%S Start", time.localtime()) + " - " + vTestName) def tstDone(): """ test case end print out with time - :return: + :return: none - prints out on the console """ print(time.strftime("%H:%M:%S Done ", time.localtime())) def l2ml(vValue): """ converts liter to mili liter - :param vValue: - :return: + :param (int) vValue: the value in liter. + :return: (int) vValue converted to miliiliter. """ return int(round (vValue, 3) * 1000) def ml2l(vValue): """ converts mili liter to liter - :param vValue: - :return: + :param (int) vValue: the value in miliiliter. + :return: (int) vValue converted to liter. """ return vValue / 1000