usr/lib64/python2.7/fpformat.pyc000064400000011137147204502070012404 0ustar00ó zfc@sÁdZddlmZedddƒ[ddlZddd gZejd ƒZyd efd „ƒYZWne k r†d ZnXd „Z d„Z d„Z d„Z d„Zd„ZdS(s8General floating point formatting functions. Functions: fix(x, digits_behind) sci(x, digits_behind) Each takes a number or a string and a number of digits as arguments. Parameters: x: number to be formatted; or a string resembling a number digits_behind: number of digits behind the decimal point iÿÿÿÿ(twarnpy3ks2the fpformat module has been removed in Python 3.0t stackleveliNtfixtscit NotANumbers+^([-+]?)(\d*)((?:\.\d*)?)(([eE][-+]?\d+)?)$cBseZRS((t__name__t __module__(((s /usr/lib64/python2.7/fpformat.pyRssfpformat.NotANumbercCs±tj|ƒ}|d kr't|‚n|jddddƒ\}}}}|jdƒ}|dkrod}n|r‚|d}n|r›t|dƒ}nd}||||fS( sÅReturn (sign, intpart, fraction, expo) or raise an exception: sign is '+' or '-' intpart is 0 or more digits beginning with a nonzero fraction is 0 or more digits expo is an integeriiiit0t+tiN(tdecodertmatchtNoneRtgrouptlstriptint(tstrestsigntintparttfractiontexpparttexpo((s /usr/lib64/python2.7/fpformat.pytextract#s $  cCs¶|dkrUt|ƒ}||| ||}}||kr¬|d||}q¬nW|dkr¬t|ƒ}|| |||}}|| kr¬d| ||}q¬n||fS(s5Remove the exponent by changing intpart and fraction.iR(tlen(RRRtfti((s /usr/lib64/python2.7/fpformat.pytunexpo3s      cCs[t|ƒ}||kr.||d||fSt|ƒ}||dkrYd| dfS||}|||}|dkr&||d}xH|dkr»||dkr®Pn|d}qŽWd|}|d}d}|| tt||ƒdƒdt|ƒ|d}|| ||}}n|dkr@||| fS|| d| dfSdS(s*Round or extend the fraction to size digs.RiR t5it9N(Rtchrtord(RRtdigsRRttotalt nextdigittn((s /usr/lib64/python2.7/fpformat.pyt roundfracAs,       8 cCsìt|ƒtdƒkr't|ƒ}nyt|ƒ\}}}}Wntk rW|SXt|||ƒ\}}t|||ƒ\}}x$|r®|ddkr®|d}q‹W|dkrÄd}n|dkrà||d|S||SdS(s‡Format x as [-]ddd.ddd with 'digs' digits after the point and at least one digit before. If digs <= 0, the point is suppressed.R iRit.N(ttypetreprRRRR$(txR RRRR((s /usr/lib64/python2.7/fpformat.pyR[s   cCsÂt|ƒtdƒkr't|ƒ}nt|ƒ\}}}}|s§x.|ru|ddkru|d}|d}qHW|rž|d|d}}|d}qÔd}n-|t|ƒd}|d|d|}}td|ƒ}t|||ƒ\}}t|ƒdkrB|d|d|d |t|ƒd}}}n||}|dkri|d|}ntt|ƒƒ}ddt|ƒ|}|dkr¬d|}n d |}|d |S( s¥Format x as [-]d.dddE[+-]ddd with 'digs' digits after the point and exactly one digit before. If digs is <= 0, one digit is kept and the point is suppressed.R iRiiÿÿÿÿR%it-Rte(R&R'RRtmaxR$tabs(R(R RRRRRR*((s /usr/lib64/python2.7/fpformat.pyRks6       cCsZy<x5tdƒ\}}|Gt||ƒGt||ƒGHqWWnttfk rUnXdS(sInteractive test run.sEnter (x, digs): N(tinputRRtEOFErrortKeyboardInterrupt(R(R ((s /usr/lib64/python2.7/fpformat.pyttest‹s '(t__doc__twarningsRtret__all__tcompileR t ValueErrorRt TypeErrorRRR$RRR0(((s /usr/lib64/python2.7/fpformat.pyt s