diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-14 12:38:36 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-21 14:49:15 +0100 |
| commit | 02eb0c9f257435595889d15577e4641b2242d0a1 (patch) | |
| tree | d919592bd4632d23a8d13ec291a0812d4d0b93d7 /python/helpers.py | |
| parent | d8eeb99d9106b93c0a30e3ab8849d7687d2a6f29 (diff) | |
| download | lilliput-ae-implem-02eb0c9f257435595889d15577e4641b2242d0a1.tar.xz | |
[implem-python] Suppression de paramètres redondants
Création d'un nouveau module "helpers" qui contiendra les fonctions
utilisées par les deux modes.
Diffstat (limited to 'python/helpers.py')
| -rw-r--r-- | python/helpers.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/python/helpers.py b/python/helpers.py new file mode 100644 index 0000000..34949a4 --- /dev/null +++ b/python/helpers.py @@ -0,0 +1,25 @@ +from constants import BLOCK_BYTES + + +def ArrayToBlockbytesMatrix(array) : + length = len(array) + pad = 0 + if(length % BLOCK_BYTES == 0) : + number_blocks = int(length / BLOCK_BYTES) + else : + number_blocks = int((length + (BLOCK_BYTES - (length % BLOCK_BYTES))) / BLOCK_BYTES) + pad = 1 + + matrix = [[0] * BLOCK_BYTES for block in range(0, number_blocks - pad)] + if(pad == 1) : + matrix.append([0] * (length % BLOCK_BYTES)) + + for byte in range(0, length) : + matrix[int(byte / BLOCK_BYTES)][byte % BLOCK_BYTES] = array[byte] + + return matrix + + +def BlockbytesMatrixToBytes(matrix): + return bytes(byte for block in matrix for byte in block) + |
