a
#|fò ã @ sV d Z ddd„Zdd„ Zdd „ Zddd„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é ú c C s‚ | d krdS |rjd}t dt| ƒ|ƒD ]<}| ||| … }||7 }|d dd„ |D ƒ¡7 }|d7 }q$| ¡ S d dd„ | D ƒ¡S d S )Nz (no data)Ú é c s s | ]}d |¡V qdS ©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..Ú
c s s | ]}d |¡V qdS r r r r r r r
) r )ÚrangeÚlenÚjoinÚrstrip)ÚarrayZmultilneÚwidthÚprefixÚresultÚiÚbufr r r Úhexdump s
r c C s g }| D ]}| t|ƒ¡ q|S )N)ÚappendÚord)ÚstringÚrcÚcr r r Ú
ascii_to_list- s r c C sX | t ddd¡¡} z&tttd dd„ t | ¡D ƒ¡ƒƒW S t dƒ g Y S 0 d S )Nr ú:c S s g | ]}d | ‘qS )z%cr )r Úbr r r Ú
9 r z$asciihex_to_list..z'Warning: Invalid hex string -- ignored!)
Ú translateÚstrÚ maketransÚlistÚmapr r Ú bytearrayÚfromhexÚprint)r r r r Úasciihex_to_list5 s &r, Úfc C s8 |rt | ƒd dkr|| S t | ƒd dkr4| | S | S )Né r )r )r ÚfrontZpaddingr r r Úpad_asciihex@ s
r0 c C s0 g }| D ]"}| |d@ d? |d@ d> B ¡ q|S )Néð é é )r )r r Úar r r Úswap_nibblesJ s r5 c C s t t| ƒdƒS )Né )Úintr )Zarrr r r Úlist_to_intS s r8 c C s: g }t d|ƒD ]&}|d | d }| | |? d@ ¡ q|S )Nr é é éÿ )r r )ZinpZ num_bytesÚoutr Z
shift_bitsr r r Úint_to_listX s
r= c C s t | ƒ}| |¡pdS )Nz (invalid))ÚdictÚget)ÚtableÚnrZ
dict_by_nrr r r Ú id_to_stra s rB Nc C sL t dd„ | D ƒƒ}| | ¡ ¡}|d u rH|d kr4|S td|t| ƒf ƒ‚|S )Nc S s g | ]\}}| ¡ |f‘qS r )Úupper)r rA Únamer r r r# i r zstr_to_id..z!identifier ("%s") not in table %s)r> r? rC Ú
ValueErrorr% )r@ r Zsafe_defaultZdict_by_nameÚidr r r Ú str_to_idh s rG )Fr r )Fr- )N)
Ú__doc__r r r, r0 r5 r8 r= rB rG r r r r Ú s