Lf2ddlZddlZddlZdadadaej jddjdDcgc]%}|jrd|jz'c}a da ddZ dZ dZdd Zdd Zdd Zdd Zdd ZddZddZGddeZGddeZdZ dZedk(reyycc}w)NDEBPYTHON3_SUPPORTED,python%sc(ddlm}m}tsTtj j dr5|}td}|j||j|atr|r tjd|}|Sy#|$rtwxYw)Nr) ConfigParser NoOptionErrorz"/usr/share/python3/debian_defaultsDEFAULT) configparserrr _defaultsospathexistsopen read_filecloseget ValueError)namerr config defaultsfilevalues !/usr/share/python3/py3versions.py read_defaultrs8  77>>> ?!^F DEL   \ *    IT MM)T2E    s ,B BcDtd|jdDS)Nc32K|]}t|ywN)int).0parts r z#version_to_tuple..(s:'9tT'9.)tuplesplit)versions rversion_to_tupler''s :w}}S'9: ::c t|jddkDr tdddl}|j|j|j |j |jd}i}t}ttd}d}|jdD]}|j}|d k(r|d vr|jd ttjd }|j|} | s td | jd| jd} } | jd\} } t!| dkr| dvr|j#| n2d}|| }|Dcgc] }|t%|t%| s|"}}d |vr||d <|r|j)||d <|Scc}w#t&$r td wxYw)NrzDtoo many arguments provided for X-Python3-Version: min and max only.r)N=z>=z<=z<=|<=|<<|=)? *(\d\.\d+)$z'error parsing Python3-Version attributer#)Nr+)lenr%roperatoreqgeleltsetsupported_versionsstrip setdefaultrecompilematchgroupraddr' Exceptionunion)vstringr5 operatorsvinfoexact_versions version_range relop_seenfieldvemopvvmajvminfiltopavs rparse_versionsrT+s 7== "_``{{{{(++{{$I EUN*=>MJs#  E>  . .  SU+ ZZ4 5 HHUO H !JKKGGAJ BJD$4y1}[ ""1%! "2.;!@mv$R(*:1*=@?m !@+$2U*j  . 4 4] CE*  L!@ HFG G Hs+:AF< !F<- F7F7F<7F<<Gcts9 td}|jdDcgc]}|jc}a|rtDcgc]}|dd c}StScc}w#t$rgaY1wxYwcc}w)Nz old-versionsr) _old_versionsrr%r<rr-rsrOs r old_versionsrZVs}   0E05 C0@A0@1QWWY0@AM,-}!!"}-- B M .'A$AA$ A5A$$ A21A2cts9 td}|jdDcgc]}|jc}a|rtDcgc]}|dd c}StScc}w#t$rgaY1wxYwcc}w)Nzunsupported-versionsrrV)_unsupported_versionsrr%r<rrXs runsupported_versionsr^ds  ' !78E8= C8H$I8H1QWWY8H$I !454!!"455$$ %J '$& ! '6r[c tts9 td}|jdDcgc]}|j c}atj%tj't(} tj+tj-| |rtD cgc]} | d d c} StScc}w#t $rgd} ddl}|j|dd|j}|j}n3#t$r'tjdj|}YnwxYwd}|D]F}|jd s|jd ddj jd}H|j|Dcgc]}t!j"d d |ncc}w}}|aYvwxYwcc} w)Nzsupported-versionsr)z/usr/bin/apt-cachez--no-all-versionsshowz python3-allrr2F)bufsizeshellstdout zDepends::z\s*(\S+)[ (]?.*z\1rV)default_version_supported_versionsrr%r<r subprocessPopenPIPErc ImportErrorr popenjoin startswithrr>subpopindex_default_versionsortappend) r-rrYcmdrhpfddependslinedefaultrOs rr;r;rs  * !56E6;kk#6F"G6F17796F"G $"%%&9&?&?@P&QRGw'232!!"233""1#H **C -!$$S!+0%JXX -XXchhsm, -G??:."jja0399;AA#FG HHJELMWrvv0%;WMGM") ! **4s_CB>C) G>C G/DG-D1.G0D11G AGF43 GGctstjdatd}t|tjj d|fvrt d|z|a|r tddStS)Nz/usr/bin/python3zdefault-versionz/usr/binzkthe symlink /usr/bin/python3 does not point to the python3 default version. It must be reset to point to %srV)rrr readlinkrrrmr)r-debian_defaults rrfrfst ;;'9:!"34N  Z0XY Y*,:;< <&##r(ctd}t|}td}t|dk(rz|dj |}g}|D]}|j | |j |jtdd}|j|r|j |n td|s td|r|S|Dcgc]}d |z c}S#d}YYxYwcc}w) NTr,r2r1rVrz/No supported python3 versions in version stringzempty set of versionsr) rfrTr;r4 intersectionrtrprqrrrsr) rEr-r1rG supportedvlr&rzrOs rrequested_versionsrsH 7 #E"5I 5zQ$11)< G7!3x ffRXX&6qr&:;.sN6Ms%c*6Mr"z%d.%dpython)r;)minmaxr-supported_versions_listr& version_strs rminmax_supported_versionrs<06N6MNNGG#K+%%r(c eZdZy)ControlFileValueErrorN__name__ __module__ __qualname__r(rrrr(rc eZdZy)MissingVersionValueErrorNrrr(rrrrr(rcd}d}d}t|d5}|Dcgc]}|j}}dddD]}|dk(r|dk7r |dk(rnd}|jdrd}+|jd|zr|}B|jjdsb|dk7r t d |j d d d j}| t d |dk(r| td |S|Scc}w#1swYxYw)zFread the debian/control file, extract the X-Python3-Version field.Nzutf-8)encodingrSourcezSource:z Package: zx-python3-version:z1attribute X-Python3-Version not in Source sectionrer2znot a control filez$no X-Python3-Version in control file)rr<rnlowerrr%rr)fnpkgr&sversionsection controlfileryliness rextract_pyversion_attributersGHG b7 #{*56+$+6 $ 2:'T/hG __Y 'G __[3. /G ZZ\ $ $%9 :(" !TUUzz#q)!,224H#$899 h  *+QR R N)7 $ #sC;C6C;6C;;DcZddlm}d} ||}|jddddd |jd d d dd |jddddd |jddddd |jdddd |jdddd |jdddd dd!"|j\}}tj j tjd}|jr.t|dk(r tt|jy|j rjAd-|d%|d,tjd$y#t$r.}td#|z|tjd$Yd}~yd}~wwxYw#t<$r=tj>jA|d(|d)tjd$YtB$r;tj>jAd*|zt%|j} YwxYw#t$rD}tj>jA|d+|d,tjd$Yd}~yd}~wwxYw).Nr) OptionParserz;[-v] [-h] [-d|--default] [-s|--supported] [-i|--installed] )usagez-dz --defaultz!print the default python3 version store_truerz)helpactiondestz-sz --supportedz$print the supported python3 versionsrz-rz --requestedzprint the python3 versions requested by a build; the argument is either the name of a control file or the value of the X-Python3-Version attribute requestedz-iz --installedz.print the installed supported python3 versions installedz--min-supportedz+print the minimum supported python3 version minsupportedz--max-supportedz+print the maximum supported python3 version maxsupportedz-vz --versionz print just the version number(s)Fr-)rrzrrz%s:r2rdzdebian/controlrz: not a control file: z, zC%s: no X-Python3-Version in control file, using supported versions z:  zusage: )"optparser add_option parse_argsr rrsysargvrzr4printrfr-rexitrrmr;rrrrminrmaxrisfilerrrstderrwriter) rrparseroptsargsprogrammsgr1rrEvss rmainrs% IE6  &F dK>) ; dMA) = dMM* =  dMK) = 'H)@ 'H)@ dK=#L~O""$JD$ggsxx{+G ||D Q  /$"3"34 5 CIN chh)$*;*;<=> CIN chh)$*;*;<=>  s4yA~ &sD,=,=>?  s4yA~ &sD,=,=>? CIN t9>'HAwH ww~~h' ?9"hGG+GT5F5FGB($2C2CD #((2,  We<=  O  %'/3 ' HHQKK ,- JJ$$(/&56HHQK/?JJ$$&H%,&-.,D,=,=>B ?  JJ  7C8 9 HHQKK sa L&!O"M*1O M!$M  MAOO?OOOO P*&:P%%P*__main__r)F)r r>rr rWr]environrr%r<rgrrrr'rTrZr^r;rfrrrrrrrrr)rs0rrs   zz~~&