
    >e9                        d Z ddlZddlZddlZddlZdedej        fdZdefdZ G d de	          Z
 G d	 d
          Zdeeef         dedej        ej                 fdZ G d d          Z G d de          Z G d de          ZdS )z>provides information about Ubuntu's and Debian's distributions    Nstringreturnc                    d |                      d          D             }t          |          dk    r|\  }}}t          j        |||          S t          |          dk    rO|\  }}|dk    rt          j        ||d          S t          j        ||dz   d          t          j        d          z
  S t          d          )	z9Convert a date string in ISO 8601 into a datetime object.c                 ,    g | ]}t          |          S  )int.0xs     -/usr/lib/python3/dist-packages/distro_info.py
<listcomp>z convert_date.<locals>.<listcomp>   s    ///SVV///    -               zDate not in ISO 8601 format.)splitlendatetimedate	timedelta
ValueError)r   partsyearmonthdays        r   convert_dater      s    //V\\#..///E
5zzQ"uc}T5#...
5zzQuB;;=ub111}T519a0083Ea3H3HHH
3
4
44r   c                      dS )z4Get the data directory based on the module location.z/usr/share/distro-infor   r   r   r   _get_data_dirr!   %   s    ##r   c                   $     e Zd ZdZd fdZ xZS )DistroDataOutdatedzDistribution data outdated.r   Nc                 J    t                                          d           d S )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__s    r   r'   zDistroDataOutdated.__init__-   s/    M	
 	
 	
 	
 	
r   r   N)__name__
__module____qualname____doc__r'   __classcell__r*   s   @r   r#   r#   *   sC        %%
 
 
 
 
 
 
 
 
 
r   r#   c                   8   e Zd ZdZ	 	 	 	 	 	 ddedededej        dej        ej                 dej        ej                 d	ej        ej                 d
ej        ej                 dej        ej                 dej        ej                 ddfdZ	dej        de
fdZdS )DistroReleasez"Represents a distributions releaseNversioncodenameseriescreatedreleaseeoleol_esmeol_ltseol_elts
eol_serverr   c                     || _         || _        || _        || _        || _        || _        || _        |	| _        || _        |
| _	        d S N)
r4   r5   r6   r7   r8   r9   r;   r<   r:   r=   )r)   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   s              r   r'   zDistroRelease.__init__:   sN       $r   r   c                 h    || j         k    o'| j        du p|| j        k    p| j        duo
|| j        k    S )z:Check whether this release is supported on the given date.N)r7   r9   r=   r)   r   s     r   is_supportedzDistroRelease.is_supportedS   sL    t|# 
H ItxIt+G0G	
r   )NNNNNN)r,   r-   r.   r/   strr   r   typingOptionalr'   boolrB   r   r   r   r3   r3   4   s       ,, 37.226263759% %% % 	%
 % /% _X]+% /% /% /(-0% OHM2% 
% % % %2
 
4 
 
 
 
 
 
r   r3   rowcolumnc                 R    |                      |          }|sd S t          |          S r?   )getr   )rG   rH   date_strings      r   	_get_daterL   \   s,    ''&//K t$$$r   c                      e Zd ZdZdeddfdZedee         fd            Zddedee	j
        eef                  fd	Zd
ej        dee         fdZ	 	 dded
e	j        ej                 de	j        e         de	j
        eedf         fdZddede	j        e         de	j        e         fdZ	 dd
e	j        ej                 dede	j
        eef         fdZdedede	j
        eef         fdZ	 dd
e	j        ej                 dede	j
        eef         fdZ	 dd
e	j        ej                 dedee	j
        eef                  fdZdedefdZ	 dd
e	j        ej                 dedee	j
        eef                  fdZdS )
DistroInfozzBase class for distribution information.
    Use DebianDistroInfo or UbuntuDistroInfo instead of using this directly.
    distror   Nc                    || _         t          j                            t	                      |                                dz             }t          |d          5 }t          j        |          }g | _	        |D ]}t          |d         |d         |d         t          |d                   t          |d          t          |d	          t          |d
          t          |d          t          |d          t          |d          
  
        }| j	                            |           	 d d d            n# 1 swxY w Y   t          j                                        | _        d S )Nz.csvzutf-8)encodingr4   r5   r6   r7   r8   r9   zeol-esmzeol-ltszeol-eltsz
eol-server)_distroospathjoinr!   loweropencsv
DictReader	_releasesr3   r   rL   appendr   r   today_date)r)   rO   filenamecsvfile
csv_readerrG   r8   s          r   r'   zDistroInfo.__init__h   su   7<<&1HII(W--- 	/00JDN! / /'	N
OM Y00c9--c5))c9--c9--c:..c<00  %%g..../	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/" ]((**


s   CD33D7:D7c                 $    d | j         D             S )z*List codenames of all known distributions.c                     g | ]	}|j         
S r   r6   r	   s     r   r   z"DistroInfo.all.<locals>.<listcomp>   s    111Q111r   rZ   )r)   s    r   allzDistroInfo.all~   s     21$.1111r   r5   resultc                 .      fd j         D             S )zList all known distributions.c                 <    g | ]}                     |          S r   )_format)r
   r   rf   r)   s     r   r   z&DistroInfo.get_all.<locals>.<listcomp>   s'    @@@AVQ''@@@r   rd   )r)   rf   s   ``r   get_allzDistroInfo.get_all   s#    @@@@@@@@@r   r   c                 *    fd| j         D             S )z?Return all distributions that were available on the given date.c                 *    g | ]}|j         k    |S r   )r7   r
   r   r   s     r   r   z%DistroInfo._avail.<locals>.<listcomp>   s%    ???aTQY->->->->->r   rd   rA   s    `r   _availzDistroInfo._avail   s    ????4>????r   r8   defaultc                     |S )z3Map codename aliases to the codename they describe.r   r)   r8   r   ro   s       r   r5   zDistroInfo.codename   s	     r   namec                 L    | j         D ]}||j        |j        fv r	|j        c S |S )z!Map codename or series to version)rZ   r5   r6   r4   )r)   rr   ro   r8   s       r   r4   zDistroInfo.version   s@    ~ 	' 	'G('.999&&& :r   c                     | j         fd|                               D             }|st                      |                     ||d                   S )<Get latest development distribution based on the given date.Nc                 \    g | ](}|j         |j         k     |j        |j        k    &|)S r?   r8   r9   rm   s     r   r   z$DistroInfo.devel.<locals>.<listcomp>   G     
 
 
y TAI%5%515=DTUTYMM LYMMr   r]   rn   r#   ri   r)   r   rf   distross    `  r   develzDistroInfo.devel   s     <:D
 
 
 
[[&&
 
 

  	'$&&&||FGBK000r   format_stringc                     |dk    r|S |dk    r|j         S |dk    r | j        dz   |j        z   dz   |j        z   dz   S |dk    r|j        S t	          d|z   d	z             )
z"Format a given distribution entry.objectr5   fullname z ""r8   zQOnly codename, fullname, object, and release are allowed result values, but not 'z'.)r6   rR   r4   r5   r   )r)   r   r8   s      r   ri   zDistroInfo._format   s     H$$NJ&&>!J&&<#%7$>AQQTWWWI%%?"')679=>
 
 	
r   c                     | j         fd|                               D             }|st                      |                     ||d                   S )z7Get latest stable distribution based on the given date.Nc                 \    g | ](}|j         	|j         k    |j        |j        k    &|)S r?   rw   rm   s     r   r   z%DistroInfo.stable.<locals>.<listcomp>   sL     
 
 
y$):):QUYZY^Q^Q^ Q^Q^Q^r   ry   rz   r{   s    `  r   stablezDistroInfo.stable   r~   r   c                     t                      )z@Get list of all supported distributions based on the given date.)NotImplementedError)r)   r   rf   s      r   	supportedzDistroInfo.supported   s     "###r   c                     || j         v S )%Check if the given codename is known.)re   r)   r5   s     r   validzDistroInfo.valid   s    48##r   c                      | j         }                     |           fd                     |          D             }|S )zBGet list of all unsupported distributions based on the given date.Nc                 N    g | ]!}|j         v                    |          "S r   )r6   ri   )r
   r   rf   r)   r   s     r   r   z*DistroInfo.unsupported.<locals>.<listcomp>   s4    cccqYbIbIb4<<**IbIbIbr   )r]   r   rn   )r)   r   rf   r|   r   s   ` ` @r   unsupportedzDistroInfo.unsupported   sT     <:DNN4((	ccccccDKK4E4Ecccr   )r5   NNr?   Nr5   )r,   r-   r.   r/   rC   r'   propertylistre   rD   Unionr3   rj   r   r   rn   rE   r5   r4   r}   ri   r   r   rF   r   r   r   r   r   rN   rN   c   s        +s +t + + + +, 2T#Y 2 2 2 X2A Ac A4]TWEW8X3Y A A A A@8= @T--@ @ @ @ @ 04(,	  ohm, %	
 
mS$.	/    C &/#*> &/Z]J^     JT1 1OHM21CF1	mS(	)1 1 1 1
 
+8
	mS(	)
 
 
 
& JT1 1OHM21CF1	mS(	)1 1 1 1  JT$ $OHM2$CF$	fl=#-.	/$ $ $ $$c $d $ $ $ $
 JT OHM2CF	fl=#-.	/     r   rN   c                       e Zd ZdZd fdZ	 	 ddedej        ej	                 dej        e         dej
        eedf         fdZ	 ddej        ej	                 d
edej
        eef         fdZ	 ddej        ej	                 d
edej
        eef         fdZ	 ddej        ej	                 d
edeej
        eef                  fdZ	 ddej        ej	                 d
edeej
        eef                  fdZ	 ddej        ej	                 d
edeej
        eef                  fdZ	 ddej        ej	                 d
edej
        eef         fdZd	edefdZ xZS )DebianDistroInfoz1provides information about Debian's distributionsr   Nc                 J    t                                          d           d S )NDebianr%   r(   s    r   r'   zDebianDistroInfo.__init__   !    """""r   r8   r   ro   c                     |dk    r|                      |          S |dk    r|                     |          S |dk    r|                     |          S |dk    r|                     |          S |S )z3Map 'unstable', 'testing', etc. to their codenames.unstabletestingr   	oldstable)r}   r   r   oldrq   s       r   r5   zDebianDistroInfo.codename   s{     j  ::d###i<<%%%h;;t$$$k!!88D>>!r   r5   rf   c                     | j         fd|                               D             }t          |          dk     rt                      |                     ||d                   S )ru   Nc                 \    g | ](}|j         |j         k     |j        |j        k    &|)S r?   rw   rm   s     r   r   z*DebianDistroInfo.devel.<locals>.<listcomp>   rx   r   r   r]   rn   r   r#   ri   r{   s    `  r   r}   zDebianDistroInfo.devel   s|     <:D
 
 
 
[[&&
 
 

 w<<!$&&&||FGBK000r   c                     | j         fd|                               D             }t          |          dk     rt                      |                     ||d                   S )z=Get old (stable) Debian distribution based on the given date.Nc                 8    g | ]}|j         	|j         k    |S r?   )r8   rm   s     r   r   z(DebianDistroInfo.old.<locals>.<listcomp>  s.    ___193HTUVU^M^M^1M^M^M^r   r   r   r   r{   s    `  r   r   zDebianDistroInfo.old  sk     <:D____dkk$//___w<<!$&&&||FGBK000r   c                 d      j          fd                               D             }|S )zOGet list of all supported Debian distributions based on the given
        date.Nc                 `    g | ]*}|j         |j         k                        |          +S r?   )r9   ri   r
   r   r   rf   r)   s     r   r   z.DebianDistroInfo.supported.<locals>.<listcomp>  sC     
 
 
()!%-SW[\[`S`S`DLL##S`S`S`r   r]   rn   r{   s   ``` r   r   zDebianDistroInfo.supported  sX    
 <:D
 
 
 
 
 
-1[[->->
 
 
 r   c                 d      j          fd                               D             }|S )zSGet list of all LTS supported Debian distributions based on the given
        date.Nc                     g | ]<}|j         3|j         k    r(|j        |j        k    &                    |          =S r?   )r9   r;   ri   r   s     r   r   z2DebianDistroInfo.lts_supported.<locals>.<listcomp>%  sY     
 
 
!dQUll&419+<+< LL## ,=+<+<r   r   r{   s   ``` r   lts_supportedzDebianDistroInfo.lts_supported  X    
 <:D
 
 
 
 
 
[[&&
 
 
 r   c                 d      j          fd                               D             }|S )z\Get list of all Extended LTS supported Debian distributions based on
        the given date.Nc                     g | ]<}|j         3|j         k    r(|j        |j        k    &                    |          =S r?   )r;   r<   ri   r   s     r   r   z3DebianDistroInfo.elts_supported.<locals>.<listcomp>4  s[     
 
 
	%$*:*:'DAJ,>,> LL## -?,>,>r   r   r{   s   ``` r   elts_supportedzDebianDistroInfo.elts_supported-  r   r   c                     | j         fd|                               D             }|st                      |                     ||d                   S )z?Get latest testing Debian distribution based on the given date.Nc                 x    g | ]6}|j         |j        s$|j         |j         k     "|j        |j        k    4|7S r?   )r8   r4   r9   rm   s     r   r   z,DebianDistroInfo.testing.<locals>.<listcomp>B  s_     
 
 
	!ai!	%$*:*:QUYZY^Q^Q^  R_Q^Q^r   ry   rz   r{   s    `  r   r   zDebianDistroInfo.testing<  ss     <:D
 
 
 
[[&&
 
 
  	'$&&&||FGBK000r   c                 @    t                               | |          p|dv S )r   )r   r   r   r   )rN   r   r   s     r   r   zDebianDistroInfo.validL  s,    h// 
8 @
 4
 	
r   r+   r   r   )r,   r-   r.   r/   r'   rC   rD   rE   r   r   r   r3   r5   r}   r   r   r   r   r   r   rF   r   r0   r1   s   @r   r   r      s       ;;# # # # # # 04(,	  ohm, %	
 
mS$.	/   $ JT1 1OHM21CF1	mS(	)1 1 1 1  JT	1 	1OHM2	1CF	1	mS(	)	1 	1 	1 	1 JT
 
OHM2
CF
	fl=#-.	/
 
 
 
 JT OHM2CF	fl=#-.	/     JT OHM2CF	fl=#-.	/     JT1 1OHM21CF1	mS(	)1 1 1 1 
c 
d 
 
 
 
 
 
 
 
r   r   c            
       B    e Zd ZdZd fdZ	 ddej        ej                 de	dej
        ee	f         fdZde	defd	Z	 ddej        ej                 de	deej
        ee	f                  fd
Z	 ddej        ej                 de	deej
        ee	f                  fdZ xZS )UbuntuDistroInfoz1provides information about Ubuntu's distributionsr   Nc                 J    t                                          d           d S )NUbuntur%   r(   s    r   r'   zUbuntuDistroInfo.__init__Y  r   r   r5   r   rf   c                     | j         fd| j        D             }|st                      |                     ||d                   S )zWGet latest long term support (LTS) Ubuntu distribution based on the
        given date.Nc                     g | ]J}|j                             d           dk     |j        '|j        .|j        cxk    r|j        k    En n|KS )LTSr   )r4   findr8   r9   rm   s     r   r   z(UbuntuDistroInfo.lts.<locals>.<listcomp>c  sr     
 
 
y~~e$$))ai)AE)aiSWF`F`F`F`[\[`F`F`F`F`F` F`F`F`r   ry   )r]   rZ   r#   ri   r{   s    `  r   ltszUbuntuDistroInfo.lts\  si    
 <:D
 
 
 
^
 
 

  	'$&&&||FGBK000r   c                 P    fd| j         D             }|sdS d|d         j        v S )zIs codename an LTS release?c                 *    g | ]}|j         k    |S r   rc   )r
   r   r5   s     r   r   z+UbuntuDistroInfo.is_lts.<locals>.<listcomp>n  s%    EEEH0D0D10D0D0Dr   Fr   r   )rZ   r4   )r)   r5   r|   s    ` r   is_ltszUbuntuDistroInfo.is_ltsl  s=    EEEEdnEEE 	5
***r   c                 d      j          fd                               D             }|S )zOGet list of all supported Ubuntu distributions based on the given
        date.Nc                     g | ]<}|j         r|j         k    s|j        |j        k    &                    |          =S r?   )r9   r=   ri   r   s     r   r   z.UbuntuDistroInfo.supported.<locals>.<listcomp>z  s]     
 
 

 !%--Q\-E$RSR^J^J^ LL##J^J^J^r   r   r{   s   ``` r   r   zUbuntuDistroInfo.supporteds  X    
 <:D
 
 
 
 
 
[[&&
 
 

 r   c                 d      j          fd                               D             }|S )zSGet list of all ESM supported Ubuntu distributions based on the
        given date.Nc                 `    g | ]*}|j         	|j         k                        |          +S r?   )r:   ri   r   s     r   r   z2UbuntuDistroInfo.supported_esm.<locals>.<listcomp>  sE     
 
 
y$):): LL##):):):r   r   r{   s   ``` r   supported_esmzUbuntuDistroInfo.supported_esm  r   r   r+   r   )r,   r-   r.   r/   r'   rD   rE   r   r   rC   r   r3   r   rF   r   r   r   r   r0   r1   s   @r   r   r   V  sV       ;;# # # # # # JT1 1OHM21CF1	mS(	)1 1 1 1 +s +t + + + + JT OHM2CF	fl=#-.	/    JT OHM2CF	fl=#-.	/       r   r   )r/   rX   r   rS   rD   rC   r   r   r!   	Exceptionr#   r3   dictrE   rL   rN   r   r   r   r   r   <module>r      s   E D 



  				 5 5 5 5 5 5$s $ $ $ $

 
 
 
 
 
 
 
%
 %
 %
 %
 %
 %
 %
 %
P%4S> %3 %6?8=3Q % % % %{ { { { { { { {|r
 r
 r
 r
 r
z r
 r
 r
j7 7 7 7 7z 7 7 7 7 7r   