o
    b$                     @   sv   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dZ	ddd	d
d
dZ
G dd dZe Ze ZdS ))secondsshortPythonVersionPlatformplatformplatformType    N)time)Optionalreturnc                   C   s   dt jdd  S )z?
    Returns the Python version as a dot-separated string.
    z%s.%s.%sN   )sysversion_info r   r   8/usr/lib/python3/dist-packages/twisted/python/runtime.pyr      s   r   win32posixjava)ntcer   r   zorg.python.modules.osc                   @   s   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dZdefd	d
Zde	e
 fddZdefddZdefddZdefddZdefddZdefddZd"de
defddZdefddZdefddZdefdd ZdS )#r   zC
    Gives us information about the platform we're running on.
    typeNnamer   r	   c                 C   s*   |d ur
t || _|d ur|| _d S d S )N)knownPlatformsgetr   	_platform)selfr   r   r   r   r   __init__,   s
   
zPlatform.__init__c                 C   s
   | 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   r   r   r   isKnown4      
zPlatform.isKnownc                 C   s   | j S )zX
        Get platform type.

        @return: Either 'posix', 'win32' or 'java'
        r   r   r   r   r   getType<   s   zPlatform.getTypec                 C   s
   | 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   r   r   r   isMacOSXD   r   zPlatform.isMacOSXc                 C   s   t jdtd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   r   r   r   isWinNTL   s   
zPlatform.isWinNTc                 C   s   |   dkS )z
        Are we running in Windows?

        @return: C{True} if the current platform has been detected as
            Windows.
        r   )r   r   r   r   r   r'   ^   s   zPlatform.isWindowsc                 C   s   t jdkot  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   r   r   r   isVistag   s   zPlatform.isVistac                 C   s   | 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   r   r   r   isLinuxo   s   zPlatform.isLinux/proc/1/cgroup_initCGroupLocationc                 C   sn   |   sdS ddlm} ||}| r5dd | dD }|D ]}t|dkr4|d d	r4 d
S q"d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                 S   s   g | ]}| d qS )   :)split).0xr   r   r   
<listcomp>   s    
z%Platform.isDocker.<locals>.<listcomp>   
r
   r"   s   /docker/T)r/   twisted.python.filepathr2   exists
getContentr4   lenr.   )r   r1   r2   initCGroupscontrolGroupsgroupr   r   r   isDockerw   s   zPlatform.isDockerc                 C   s.   |   rdS ztj W dS  ty   Y dS 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   r   r   r   _supportsSymlinks   s   zPlatform._supportsSymlinksc                 C   s(   z	ddl }|duW S  ty   Y dS w )zy
        Can threads be created?

        @return: C{True} if the threads are supported on the current platform.
        r   NF)	threadingImportError)r   rE   r   r   r   supportsThreads   s   
zPlatform.supportsThreadsc                 C   sR   z
ddl m}m} W n
 ty   Y dS w z	t|  W dS  |y(   Y dS w )zf
        Return C{True} if we can use the inotify API on this platform.

        @since: 10.1
        r   )INotifyErrorinitFT)twisted.python._inotifyrH   rI   rF   rA   close)r   rH   rI   r   r   r   supportsINotify   s   zPlatform.supportsINotify)NN)r0   )__name__
__module____qualname____doc__r   r   rA   r   r   r   str__annotations__staticmethodr   r   r   r   r   boolr   r   r!   r(   r'   r,   r/   r@   rD   rG   rL   r   r   r   r   r   #   s0   
 
	r   )__all__rA   r   r$   r   r   typingr   rQ   r   r   r   r   r   r   r   r   r   r   <module>   s"   	 )