o IPa0@sdZddlZddlZddlZddZddZGdddeZGd d d Zd d Z Gd ddZ Gddde Z Gddde Z dS)z>provides information about Ubuntu's and Debian's distributionsNcCs|sd}|Sdd|dD}t|dkr$|\}}}t|||}|St|dkrK|\}}|dkr;t||d}|St||d d td }|Std ) z9Convert a date string in ISO 8601 into a datetime object.NcSsg|]}t|qS)int.0xrr-/usr/lib/python3/dist-packages/distro_info.py sz convert_date..- zDate not in ISO 8601 format.)splitlendatetimedate timedelta ValueError)stringrpartsyearmonthdayrrr convert_dates    rcCsdS)z4Get the data directory based on the module location.z/usr/share/distro-inforrrrr _get_data_dir*srcs eZdZdZfddZZS)DistroDataOutdatedzDistribution data outdated.ctddS)NzDistribution data outdated. Please check for an update for distro-info-data. See /usr/share/doc/distro-info-data/README.Debian for details.super__init__self __class__rrr 2szDistroDataOutdated.__init__)__name__ __module__ __qualname____doc__r __classcell__rrr#rr/src@s0eZdZdZ       dddZddZdS) DistroReleasez"Represents a distributions releaseNc Cs@||_||_||_||_||_||_||_| |_||_| |_ dSN) versioncodenameseriescreatedreleaseeoleol_ltseol_eltseol_esm eol_server) r"r,r-r.r/r0r1r4r2r3r5rrrr ?s zDistroRelease.__init__cCs2||jko|jdup||jkp|jduo||jkS)z:Check whether this release is supported on the given date.N)r/r1r5r"rrrr is_supportedXs  zDistroRelease.is_supported)NNNNNNN)r%r&r'r(r r7rrrrr*9s  r*cCs||vr t||SdSr+)r)rowcolumnrrr _get_dateasr:c@seZdZdZddZeddZdddZd d Zdd d Z dddZ dddZ ddZ dddZ dddZddZdddZd S) DistroInfozzBase class for distribution information. Use DebianDistroInfo or UbuntuDistroInfo instead of using this directly. cCs||_tjt|d}t|ddC}t|}g|_ |D]0}t |d|d|dt |dt |dt |d t |d t |d t |d t |d  }|j |q Wdn1s[wYt j|_dS)Nz.csvzutf-8)encodingr,r-r.r/r0r1zeol-esmzeol-ltszeol-eltsz eol-server)_distroospathjoinrloweropencsv DictReader _releasesr*r:appendrrtoday_date)r"distrofilenamecsvfile csv_readerr8r0rrrr js,  zDistroInfo.__init__cCsdd|jDS)z*List codenames of all known distributions.cSsg|]}|jqSrr.rrrrrsz"DistroInfo.all..rEr!rrrallszDistroInfo.allr-csfddjDS)zList all known distributions.csg|]}|qSr)_formatrresultr"rrrsz&DistroInfo.get_all..rN)r"rRrrQrget_allszDistroInfo.get_allcsfdd|jDS)z?Return all distributions that were available on the given date.csg|] }|jkr|qSr)r/rrrrrz%DistroInfo._avail..rNr6rrTr_availzDistroInfo._availNcCs|S)z3Map codename aliases to the codename they describe.r)r"r0rdefaultrrrr-szDistroInfo.codenamecCs*|jD]}||j|jfvr|jSq|S)z!Map codename or series to version)rEr-r.r,)r"namerXr0rrrr,s  zDistroInfo.versionc@dur|jfdd|D}|st|||dS).rHrVrrPr"rrRdistrosrrTrdevel zDistroInfo.develcCs^|dkr|S|dkr |jS|dkr |jd|jd|jdS|dkr'|jStd|d ) z"Format a given distribution entry.objectr-fullname z ""r0zQOnly codename, fullname, object, and release are allowed result values, but not 'z'.)r.r=r,r-r)r" format_stringr0rrrrPszDistroInfo._formatcrZ)z7Get latest stable distribution based on the given date.Ncs8g|]}|jdur|jkr|jdus|jkr|qSr+r]rrTrrrr^z%DistroInfo.stable..r_r`rarrTrstablerdzDistroInfo.stablecCst)z@Get list of all supported distributions based on the given date.)NotImplementedError)r"rrRrrr supportedszDistroInfo.supportedcCs ||jvS)%Check if the given codename is known.)rOr"r-rrrvalids zDistroInfo.validcs8|durj}|fdd|D}|S)zBGet list of all unsupported distributions based on the given date.Ncs"g|] }|jvr|qSr)r.rPrrRr"rlrrrs"z*DistroInfo.unsupported..)rHrlrVrarrpr unsupporteds  zDistroInfo.unsupportedr-NNr+Nr-)r%r&r'r(r propertyrOrSrVr-r,rcrPrjrlrorqrrrrr;es       r;csneZdZdZfddZdddZddd Zdd d Zdd d ZdddZ dddZ dddZ ddZ Z S)DebianDistroInfoz1provides information about Debian's distributionscr)NDebianrr!r#rrr zDebianDistroInfo.__init__NcCs`|dkr ||}|S|dkr||}|S|dkr!||}|S|dkr,||}|S|}|S)z3Map 'unstable', 'testing', etc. to their codenames.unstabletestingrj oldstable)rcrzrjold)r"r0rrXr-rrrr-s     zDebianDistroInfo.codenamer-cHdur|jfdd|D}t|dkrt|||dS)r[Ncr\r+r]rrTrrrr^z*DebianDistroInfo.devel..r rHrVrrrPrarrTrrcs  zDebianDistroInfo.develcr})z=Get old (stable) Debian distribution based on the given date.Ncs$g|]}|jdur|jkr|qSr+)r0rrTrrrs$z(DebianDistroInfo.old..r r~rrarrTrr|s  zDebianDistroInfo.oldc.durjfddD}|S)zOGet list of all supported Debian distributions based on the given date.Ncs,g|]}|jdus|jkr|qSr+)r1rPrrrRr"rrrs&z.DebianDistroInfo.supported..rHrVrarrrrls zDebianDistroInfo.supportedcr)zSGet list of all LTS supported Debian distributions based on the given date.Nc@g|]}|jdur|jkr|jdur|jkr|qSr+)r1r2rPrrrrr   z2DebianDistroInfo.lts_supported..rrarrr lts_supported zDebianDistroInfo.lts_supportedcr)z\Get list of all Extended LTS supported Debian distributions based on the given date.Ncrr+)r2r3rPrrrrrrz3DebianDistroInfo.elts_supported..rrarrrelts_supportedrzDebianDistroInfo.elts_supportedcrZ)z?Get latest testing Debian distribution based on the given date.NcsHg|] }|jdur |js |jdur|jkr|jdus |jkr|qSr+)r0r,r1rrTrrr&s (z,DebianDistroInfo.testing..r_r`rarrTrrz"s zDebianDistroInfo.testingcCst||p |dvS)rm)ryrzrjr{)r;rornrrrro0rWzDebianDistroInfo.validrsrt)r%r&r'r(r r-rcr|rlrrrzror)rrr#rrvs    rvcsFeZdZdZfddZdddZdd Zdd d Zdd d ZZ S)UbuntuDistroInfoz1provides information about Ubuntu's distributionscr)NUbunturr!r#rrr =rxzUbuntuDistroInfo.__init__Nr-cs<dur|jfdd|jD}|st|||dS)zWGet latest long term support (LTS) Ubuntu distribution based on the given date.Ncs<g|]}|jddkr|jkr|jkrnn|qS)LTSr)r,findr0r1rrTrrrEs6z(UbuntuDistroInfo.lts..r_)rHrErrPrarrTrlts@s zUbuntuDistroInfo.ltscs*fdd|jD}|sdSd|djvS)zIs codename an LTS release?csg|] }|jkr|qSrrMrrrrrrNrUz+UbuntuDistroInfo.is_lts..Frr)rEr,)r"r-rbrrrris_ltsLszUbuntuDistroInfo.is_ltscr)zOGet list of all supported Ubuntu distributions based on the given date.Ncs6g|]}|jks|jdur|jkr|qSr+)r1r5rPrrrrrXs  z.UbuntuDistroInfo.supported..rrarrrrlS zUbuntuDistroInfo.supportedcr)zSGet list of all ESM supported Ubuntu distributions based on the given date.Ncs,g|]}|jdur|jkr|qSr+)r4rPrrrrrds  z2UbuntuDistroInfo.supported_esm..rrarrr supported_esm_rzUbuntuDistroInfo.supported_esmrt) r%r&r'r(r rrrlrr)rrr#rr:s    r) r(rCrr>rr Exceptionrr*r:r;rvrrrrrs (of