a sUgf† ã@s@ddlZddlmZddlmZedœdd„ZGdd„dƒZdS) éN)ÚOptional)Ú resources)Ú subdir_namecCsdddl}d}tj}|j|jfdkrVt d¡ d¡ |¡ ¡D]}||  ¡7}|d7}q<|j |dd S) zMHelper function that compiles ASN.1 syntax from all files within given subdirrNÚ)éé z pySim.esimZasn1Ú Zder)Úcodec) Ú asn1toolsÚsysÚ version_infoÚmajorÚminorrÚfilesÚjoinpathÚiterdirÚ read_textZcompile_string)rr Zasn_txtZ__verÚi©rú€/home/jenkins/workspace/gerrit-pysim-build/JOB_TYPE/test/a1/default/a3/default/a4/default/label/simtester/pySim/esim/__init__.pyÚcompile_asn1_subdirs  rc@s|eZdZdeeeeeedœdd„Zeeedœdd„ƒZ e eddœd d „ƒZ deed œd d „Z dd„Z dd„Zdd„ZdS)ÚActivationCodeNF)ÚhostnameÚtokenÚoidÚ cc_requiredcCsBd|vrtdƒ‚||_d|vr&tdƒ‚||_||_||_d|_dS)Nú$z $ sign not permitted in hostnamez$ sign not permitted in tokené)Ú ValueErrorrrrrÚformat)ÚselfrrrrrrrÚ__init__szActivationCode.__init__)ÚacÚreturncCs¢|ddkrtd|dƒ‚| d¡}dddœ}| d¡|d<| d¡|d<| d¡|d <t|ƒr|| d¡}|d kr|||d <t|ƒrž| d¡}|dkržd |d <|S)NrÚ1zUnsupported AC_Format '%s'!rF)rrrrrrrTr)rÚsplitÚpopÚlen)r"Z ac_elementsÚdrZccrrrrÚ decode_str#s$  þ  zActivationCode.decode_strcCs(| |¡}||d|d|d|dƒS)zBCreate new instance from SGP.22 section 4.1 string representation.rrrr)r))Úclsr"r(rrrÚ from_string9s zActivationCode.from_string)Ú for_qrcoder#cCs\|r d}nd}|d|j|j|jf7}|jr<|d|j7}n|jrJ|d7}|jrX|d7}|S)zQConvert from internal representation to SGP.22 section 4.1 string representation.zLPA:rz%d$%s$%sz$%srz$1©rrrrr)r r,ÚretrrrÚ to_string?szActivationCode.to_stringcCs| ¡S)N)r/©r rrrÚ__str__NszActivationCode.__str__cCs*ddl}| ¡}| |jdd¡| ¡S)z*Encode internal representation to QR code.rNT)r,)ÚqrcodeZQRCodeZadd_datar/Z make_image)r r2ZqrrrrÚ to_qrcodeQszActivationCode.to_qrcodecCsd|j|j|j|j|jfS)NzLActivationCode(format=%u, hostname='%s', token='%s', oid=%s, cc_required=%s)r-r0rrrÚ__repr__Xs üzActivationCode.__repr__)NF)F)Ú__name__Ú __module__Ú __qualname__ÚstrrÚboolr!Ú staticmethodÚdictr)Ú classmethodr+r/r1r3r4rrrrrs r)r ÚtypingrÚ importlibrr8rrrrrrÚs