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"   û	 )