
    \d$                         g d Z ddlZddlZddlZddlmZ ddlmZ defdZ	dddd	d	d
Z
 G d d          Z e            Ze                                ZdS ))secondsshortPythonVersionPlatformplatformplatformType    N)time)Optionalreturnc                  0    dt           j        dd         z  S )z?
    Returns the Python version as a dot-separated string.
    z%s.%s.%sN   )sysversion_info     6lib/python3.11/site-packages/twisted/python/runtime.pyr   r      s     (!,,,r   win32posixjava)ntcer   r   zorg.python.modules.osc                   H   e Zd ZU dZe                    ej                  Ze	e
         ed<    ee          Zej        Z	 dde	e
         de	e
         ddfdZdefdZde	e
         fd	Zdefd
ZdefdZdefdZdefdZdefdZdde
defdZdefdZdefdZdefdZdS )r   zC
    Gives us information about the platform we're running on.
    typeNnamer   r
   c                 ^    |t                               |          | _        |	|| _        d S d S )N)knownPlatformsgetr   	_platform)selfr   r   s      r   __init__zPlatform.__init__,   s8     &**400DI%DNNN  r   c                     | j         dk    S )z
        Do we know about this platform?

        @return: Boolean indicating whether this is a known platform or not.
        Nr   r   s    r   isKnownzPlatform.isKnown4   s     yD  r   c                     | j         S )zX
        Get platform type.

        @return: Either 'posix', 'win32' or 'java'
        r!   r"   s    r   getTypezPlatform.getType<   s     yr   c                     | j         dk    S )z
        Check if current platform is macOS.

        @return: C{True} if the current platform has been detected as macOS.
        darwin)r   r"   s    r   isMacOSXzPlatform.isMacOSXD   s     ~))r   c                 b    t          j        dt          d           |                                 S )a   
        Are we running in Windows NT?

        This is deprecated and always returns C{True} on win32 because
        Twisted only supports Windows NT-derived platforms at this point.

        @return: C{True} if the current platform has been detected as
            Windows NT.
        zgtwisted.python.runtime.Platform.isWinNT was deprecated in Twisted 13.0. Use Platform.isWindows instead.   )
stacklevel)warningswarnDeprecationWarning	isWindowsr"   s    r   isWinNTzPlatform.isWinNTL   s:     	<		
 	
 	
 	
 ~~r   c                 2    |                                  dk    S )z
        Are we running in Windows?

        @return: C{True} if the current platform has been detected as
            Windows.
        r   )r%   r"   s    r   r/   zPlatform.isWindows^   s     ||~~((r   c                 Z    t           j        dk    ot          j                    j        dk    S )z
        Check if current platform is Windows Vista or Windows Server 2008.

        @return: C{True} if the current platform has been detected as Vista
        r      )r   r   getwindowsversionmajorr"   s    r   isVistazPlatform.isVistag   s'     |w&M3+@+B+B+HA+MMr   c                 6    | j                             d          S )z
        Check if current platform is Linux.

        @return: C{True} if the current platform has been detected as Linux.
        linux)r   
startswithr"   s    r   isLinuxzPlatform.isLinuxo   s     ~((111r   /proc/1/cgroup_initCGroupLocationc                 J   |                                  sdS ddlm}  ||          }|                                rgd |                                                    d          D             }|D ]3}t          |          dk    r|d                             d          r d	S 4dS )
z
        Check if the current platform is Linux in a Docker container.

        @return: C{True} if the current platform has been detected as Linux
            inside a Docker container.
        Fr   )FilePathc                 8    g | ]}|                     d           S )   :)split).0xs     r   
<listcomp>z%Platform.isDocker.<locals>.<listcomp>   s/       "#  r      
r   r*   s   /docker/T)r:   twisted.python.filepathr>   exists
getContentrA   lenr9   )r   r<   r>   initCGroupscontrolGroupsgroups         r   isDockerzPlatform.isDockerw   s     ||~~ 	5444444 h233 
	  '2'='='?'?'E'Ee'L'L  M '    u::??uQx':':;'G'G?44ur   c                 n    |                                  rdS 	 t          j         dS # t          $ r Y dS w xY w)z
        Check for symlink support usable for Twisted's purposes.

        @return: C{True} if symlinks are supported on the current platform,
                 otherwise C{False}.
        FT)r/   ossymlinkAttributeErrorr"   s    r   _supportsSymlinkszPlatform._supportsSymlinks   sT     >> 	 5

 t "   uus   & 
44c                 6    	 ddl }|duS # t          $ r Y dS w xY w)zy
        Can threads be created?

        @return: C{True} if the threads are supported on the current platform.
        r   NF)	threadingImportError)r   rT   s     r   supportsThreadszPlatform.supportsThreads   s@    	D(( 	 	 	55	s   
 
c                     	 ddl m}m} n# t          $ r Y dS w xY w	 t	          j         |                       n# |$ r Y dS w xY wdS )zf
        Return C{True} if we can use the inotify API on this platform.

        @since: 10.1
        r   )INotifyErrorinitFT)twisted.python._inotifyrX   rY   rU   rO   close)r   rX   rY   s      r   supportsINotifyzPlatform.supportsINotify   s    	BBBBBBBBB 	 	 	55		HTTVV 	 	 	55	ts    
: AA)NN)r;   )__name__
__module____qualname____doc__r   r   rO   r   r   r	   str__annotations__staticmethodr   r   r   r   r   boolr#   r%   r(   r0   r/   r6   r:   rM   rR   rV   r\   r   r   r   r   r   #   s          ),,RW55D(3-555l7##GI EI& &SM&4<SM&	& & & &! ! ! ! !#    *$ * * * *         $)4 ) ) ) )N N N N N2 2 2 2 2 C t    84    2          r   r   )__all__rO   r   r,   r   r   typingr	   ra   r   r   r   r   r%   r   r   r   r   <module>rg      s   
   
			 



                   -C - - - - 
# e e e e e e e eP 8::!!r   