a #|fò ã@sVdZddd„Zdd„Zdd „Zdd d „Zd d„Zdd„Zdd„Zdd„Zddd„Z dS)aì A collection of useful routines to make this tool work (C) 2017 by Sysmocom s.f.m.c. GmbH All Rights Reserved Author: Philipp Maier This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Féú cCs‚|dkr dS|rjd}tdt|ƒ|ƒD]<}||||…}||7}|d dd„|Dƒ¡7}|d7}q$| ¡Sd dd„|Dƒ¡SdS)Nz (no data)Úécss|]}d |¡VqdS©z{:02x}N©Úformat©Ú.0Úx©r ús/home/jenkins/workspace/master-sysmo-usim-tool/a1/default/a2/default/a3/default/a4/default/label/simtester/utils.pyÚ %ózhexdump..Ú css|]}d |¡VqdSrrrr r r r )r)ÚrangeÚlenÚjoinÚrstrip)ÚarrayZmultilneÚwidthÚprefixÚresultÚiÚbufr r r Úhexdumps rcCs g}|D]}| t|ƒ¡q|S)N)ÚappendÚord)ÚstringÚrcÚcr r r Ú ascii_to_list-sr c CsX| t ddd¡¡}z&tttd dd„t |¡Dƒ¡ƒƒWSt dƒgYS0dS)Nrú:cSsg|] }d|‘qS)z%cr )r Úbr r r Ú 9rz$asciihex_to_list..z'Warning: Invalid hex string -- ignored!) Ú translateÚstrÚ maketransÚlistÚmaprrÚ bytearrayÚfromhexÚprint)rr r r Úasciihex_to_list5s &r,ÚfcCs8|rt|ƒddkr||St|ƒddkr4||S|S)Nér)r)rÚfrontZpaddingr r r Ú pad_asciihex@s r0cCs0g}|D]"}| |d@d?|d@d>B¡q|S)Néðéé)r)rrÚar r r Ú swap_nibblesJs r5cCstt|ƒdƒS)Né)Úintr)Zarrr r r Ú list_to_intSsr8cCs:g}td|ƒD]&}|d|d}| ||?d@¡q|S)Nréééÿ)rr)ZinpZ num_bytesÚoutrZ shift_bitsr r r Ú int_to_listXs r=cCst|ƒ}| |¡pdS)Nz (invalid))ÚdictÚget)ÚtableÚnrZ dict_by_nrr r r Ú id_to_strasrBNcCsLtdd„|Dƒƒ}| | ¡¡}|durH|dkr4|Std|t|ƒfƒ‚|S)NcSsg|]\}}| ¡|f‘qSr )Úupper)r rAÚnamer r r r#irzstr_to_id..z!identifier ("%s") not in table %s)r>r?rCÚ ValueErrorr%)r@rZ safe_defaultZ dict_by_nameÚidr r r Ú str_to_idhsrG)Frr)Fr-)N) Ú__doc__rr r,r0r5r8r=rBrGr r r r Ús