Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 2øªj¦ã@sÂdZddlmZmZddlmZmZddl Z ddl Z dZ dZ Gdd„de ƒZd d „Zdd d „Zdd d„Zdd„Ze jdƒZe jdƒZe jdƒZddddœZiZd dd„Zdd„Zedkr¾eƒdS)!asstruct.py -- SuperStruct Higher level layer on top of the struct module, enabling to bind names to struct elements. The interface is similar to struct, except the objects passed and returned are not tuples (or argument lists), but dictionaries or instances. Just like struct, we use fmt strings to describe a data structure, except we use one line per element. Lines are separated by newlines or semi-colons. Each line contains either one of the special struct characters ('@', '=', '<', '>' or '!') or a 'name:formatchar' combo (eg. 'myFloat:f'). Repetitions, like the struct module offers them are not useful in this context, except for fixed length strings (eg. 'myInt:5h' is not allowed but 'myString:5s' is). The 'x' fmt character (pad byte) is treated as 'special', since it is by definition anonymous. Extra whitespace is allowed everywhere. The sstruct module offers one feature that the "normal" struct module doesn't: support for fixed point numbers. These are spelled as "n.mF", where n is the number of bits before the point, and m the number of bits after the point. Fixed point numbers get converted to floats. pack(fmt, object): 'object' is either a dictionary or an instance (or actually anything that has a __dict__ attribute). If it is a dictionary, its keys are used for names. If it is an instance, it's attributes are used to grab struct elements from. Returns a string containing the data. unpack(fmt, data, object=None) If 'object' is omitted (or None), a new dictionary will be returned. If 'object' is a dictionary, it will be used to add struct elements to. If it is an instance (or in fact anything that has a __dict__ attribute), an attribute will be added for each struct element. In the latter two cases, 'object' itself is returned. unpack2(fmt, data, object=None) Convenience function. Same as unpack, except data may be longer than needed. The returned value is a tuple: (object, leftoverdata). calcsize(fmt) like struct.calcsize(), but uses our own fmt strings: it returns the size of the data in bytes. é)Ú fixedToFloatÚ floatToFixed)ÚtobytesÚtostrNz1.2z4Copyright 1998, Just van Rossum c@s eZdZdS)ÚErrorN)Ú__name__Ú __module__Ú __qualname__©r r ú;/tmp/pip-build-_d5lkt3n/fonttools/fontTools/misc/sstruct.pyr:src Csˆt|dd�\}}}g}t|tƒs&|j}xH|D]@}||}||krPt|||ƒ}nt|tƒrbt|ƒ}|j|ƒq,Wtj |ft |ƒŽ}|S)NT)Ú keep_pad_byte) Ú getformatÚ isinstanceÚdictÚ__dict__Úfl2fiÚstrrÚappendÚstructÚpackÚtuple) ÚfmtÚobjÚ formatstringÚnamesÚfixesÚelementsÚnameÚvalueÚdatar r r r=s   rc Csº|dkr i}t|ƒ}t|ƒ\}}}t|tƒr2|}n|j}tj||ƒ}xptt|ƒƒD]`}||} ||} | |kr~t | || ƒ} n,t| t ƒrªy t | ƒ} Wnt k r¨YnX| || <qRW|S)N) rr rrrrÚunpackÚrangeÚlenÚfi2flÚbytesrÚUnicodeDecodeError) rrrrrrÚdrÚirrr r r r Ms(     r cCs(t|ƒ}t||d|…|ƒ||d…fS)N)Úcalcsizer )rrrÚlengthr r r Úunpack2esr*cCst|ƒ\}}}tj|ƒS)N)r rr()rrrrr r r r(isr(z`\s*([A-Za-z_][A-Za-z_0-9]*)\s*:\s*([xcbB?hHiIlLqQfd]|[0-9]+[ps]|([0-9]+)\.([0-9]+)(F))\s*(#.*)?$z\s*([x@=<>!])\s*(#.*)?$z \s*(#.*)?$ÚbÚhÚl)ééé Fc Csdt|dd�}yt|\}}}W�n8tk �rXtjd|ƒ}d}g}i}�xø|D]ð}tj|ƒrbqRtj|ƒ}|r�|jdƒ}|dkrŽ|rŽt dƒ‚nªt j|ƒ}|sªt d|ƒ‚|jdƒ} |jd ƒ}|sÊ|dkrÔ|j | ƒ|jd ƒ�r:t |jd ƒƒ} t |jd ƒƒ} | | } | dk�rt dƒ‚t | }|jdƒdk�s2t‚| || <||}qRW|||ft|<YnX|||fS)NÚascii)Úencodingz[ ;]ÚéÚxz a special fmt char must be firstzsyntax error in fmt: '%s'ééér.r/r0z)fixed point must be 8, 16 or 32 bits longéÚF)r.r/r0)rÚ _formatcacheÚKeyErrorÚreÚsplitÚ_emptyREÚmatchÚ_extraREÚgrouprÚ _elementRErÚintÚ_fixedpointmappingsÚAssertionError) rr rrrÚlinesÚlineÚmZ formatcharrÚbeforeÚafterÚbitsr r r r ‡sF                 r cCs¦d}tdt|ƒƒGdd„dtƒ}|ƒ}d|_d|_d|_d|_d |_d |_d |_ d |_ d |_ t ||ƒ}td t |ƒƒtt||ƒƒ|ƒ}t|||ƒtt|ƒƒdS)Na  # comments are allowed > # big endian (see documentation for struct) # empty lines are allowed: ashort: h along: l abyte: b # a byte achar: c astr: 5s afloat: f; adouble: d # multiple "statements" are allowed afixed: 16.16F abool: ? apad: x zsize:c@s eZdZdS)z_test..fooN)rrr r r r r ÚfooÁsrMiÿiÿÿÿéÚaZ12345gà?gø?Tzdata:)Úprintr(ÚobjectZashortZalongZabyteZacharZastrZafloatZadoubleZafixedZaboolrÚreprr Úvars)rrMr'rÚi2r r r Ú_test®s&  rUÚ__main__)N)N)F)Ú__doc__ZfontTools.misc.fixedToolsrr#rrZfontTools.misc.textToolsrrrr=Ú __version__Ú __copyright__Ú Exceptionrrr r*r(ÚcompilerCrAr?rEr;r rUrr r r r Ú/s.     ')