
    VhL                        d Z ddlmZ ddlZddlZddlZddlZ G d d      Z G d d      Z ej                  d	       G d
 d             Z
 ej                  d	       G d d             ZddZy)z5Linux control group constants, classes and utilities.    )annotationsNc                      e Zd ZdZdZdZdZy)
CGroupPathzLinux cgroup path constants.z/sys/fs/cgroupz/sys/fs/cgroup/systemdz$/sys/fs/cgroup/systemd/release_agentN)__name__
__module____qualname____doc__ROOTSYSTEMDSYSTEMD_RELEASE_AGENT     M/home/dcms/DCMS/lib/python3.12/site-packages/ansible_test/_internal/cgroup.pyr   r   
   s    &D&GBr   r   c                      e Zd ZdZdZdZdZy)	MountTypez&Linux filesystem mount type constants.tmpfscgroupcgroup2N)r   r   r   r	   TMPFS	CGROUP_V1	CGROUP_V2r   r   r   r   r      s    0EIIr   r   T)frozenc                  x    e Zd ZU dZded<   ded<   ded<   edd       Zedd	       Zedd
       Z	edd       Z
y)CGroupEntryzNA single cgroup entry parsed from '/proc/{pid}/cgroup' in the proc filesystem.intidstr	subsystempathlib.PurePosixPathpathc                ^    t        j                  t        j                  | j                        S )z(The root path for this cgroup subsystem.)pathlibPurePosixPathr   r
   r   selfs    r   	root_pathzCGroupEntry.root_path"   s     $$Z__dnnEEr   c                    t        j                  | j                  t        | j                        j                  d            S )z(The full path for this cgroup subsystem./)r"   r#   r&   r   r    lstripr$   s    r   	full_pathzCGroupEntry.full_path'   s.     $$T^^S^5J5J35OPPr   c                    |j                  dd      \  }}} | t        |      |j                  d      t        j                  |            S )zOParse the given cgroup line from the proc filesystem and return a cgroup entry.:   )maxsplitzname=)r   r   r    )splitr   removeprefixr"   r#   )clsvaluecidr   r    s        r   parsezCGroupEntry.parse,   sM      %{{3{;Y3x,,W5&&t,
 	
r   c                H     t         fd|j                         D              S )zUParse the given output from the proc filesystem and return a tuple of cgroup entries.c              3  @   K   | ]  }j                  |        y wNr4   .0liner1   s     r   	<genexpr>z$CGroupEntry.loads.<locals>.<genexpr>:        DSYYt_D   tuple
splitlinesr1   r2   s   ` r   loadszCGroupEntry.loads7        D1A1A1CDDDr   N)returnr   )r2   r   rE   r   )r2   r   rE   ztuple[CGroupEntry, ...])r   r   r   r	   __annotations__propertyr&   r*   classmethodr4   rC   r   r   r   r   r      si    XGN
F F Q Q 
 
 E Er   r   c                      e Zd ZU dZded<   ded<   ded<   ded<   ded<   ded	<   d
ed<   d
ed<   ded<   ded<   d
ed<   edd       Zedd       Zy)
MountEntryzUA single mount info entry parsed from '/proc/{pid}/mountinfo' in the proc filesystem.r   mount_id	parent_iddevice_majordevice_minorr   rootr    ztuple[str, ...]optionsfieldsr   typesourcesuper_optionsc                   |j                  d      ^}}}}}}}|dd }	|dd \  }
}}}|
dk(  sJ |j                  d      \  }} | t        |      t        |      t        |      t        |      t        |      t        |      t        |j                  d            t        |	      |t        |      t        |j                  d                  S )zRParse the given mount info line from the proc filesystem and return a mount entry. N-r,   ,)rK   rL   rM   rN   rO   r    rP   rQ   rR   rS   rT   )r/   r   _decode_pathr@   )r1   r2   rK   rL   device_major_minorrO   r    rP   	remainderrQ   	separatormtyperS   rT   rM   rN   s                   r   r4   zMountEntry.parseM   s    
 TYS^S^_bScP)/tWy3B2;BC./	5&-C%7%=%=c%B"l])n\*\*d#d#'--,-=' 3 3C 89
 	
r   c                H     t         fd|j                         D              S )zYParse the given output from the proc filesystem and return a tuple of mount info entries.c              3  @   K   | ]  }j                  |        y wr7   r8   r9   s     r   r<   z#MountEntry.loads.<locals>.<genexpr>k   r=   r>   r?   rB   s   ` r   rC   zMountEntry.loadsh   rD   r   N)r2   r   rE   rJ   )r2   r   rE   ztuple[MountEntry, ...])r   r   r   r	   rF   rH   r4   rC   r   r   r   rJ   rJ   =   sl    _MN


I!!""
 
4 E Er   rJ   c                \    t        j                  dd |       }t        j                  |      S )zBDecode and return a path which may contain octal escape sequences.z(\\[0-7]{3})c                j    t        j                  | j                  d      j                  d      d      S )Nr   asciiunicode_escape)codecsdecodegroupencode)ms    r   <lambda>z_decode_path.<locals>.<lambda>q   s%    V]]1771:;L;LW;UWg-h r   )resubr"   r#   )r2   r    s     r   rZ   rZ   n   s)     66/#hjopD  &&r   )r2   r   rE   r   )r	   
__future__r   re   dataclassesr"   rk   r   r   	dataclassr   rJ   rZ   r   r   r   <module>rp      s    ; "    	C C  d#E E $ED d#-E -E $-E`'r   