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

        @return: Either 'posix', 'win32' or 'java'
        r!   r"   s    r   getTypezPlatform.getType<   s     yy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                 Z    t        j                  dt        d       | j                         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                 (    | j                         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                 n    t         j                  dk(  xr! 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+H+HA+MMr   c                 8    | j                   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1r   _initCGroupLocationc                 :   | j                         syddlm}  ||      }|j                         rg|j	                         j                  d      D cg c]  }|j                  d       }}|D ]'  }t        |      dk(  s|d   j                  d      s' y	 yc c}w )
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   )FilePath   
   :r   r*   s   /docker/T)r:   twisted.python.filepathr=   exists
getContentsplitlenr9   )r   r;   r=   initCGroupsxcontrolGroupsgroups          r   isDockerzPlatform.isDockerw   s     ||~4 23 (3'='='?'E'Ee'L"#M  '  u:?uQx':':;'G 
 s   Bc                 f    | j                         ry	 t        j                   y# t        $ r Y y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   s8     >> 

  " s   $ 	00c                 2    	 ddl }|duS # t        $ r Y y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   rP   s     r   supportsThreadszPlatform.supportsThreads   s'    	D(( 		s   
 	c                     	 ddl m}m} 	 t	        j
                   |              y# t        $ r Y yw xY w# |$ r Y yw xY w)zf
        Return C{True} if we can use the inotify API on this platform.

        @since: 10.1
        r   )INotifyErrorinitFT)twisted.python._inotifyrT   rU   rQ   rK   close)r   rT   rU   s      r   supportsINotifyzPlatform.supportsINotify   sI    	B	HHTV   		
  		s   & 5 	22==)NN)z/proc/1/cgroup)__name__
__module____qualname____doc__r   r   rK   r   r   r	   str__annotations__staticmethodr   r   r   r   r   boolr#   r%   r(   r0   r/   r6   r:   rI   rN   rR   rX   r   r   r   r   r   #   s     ),,RWW5D(3-57#GI EI&SM&4<SM&	&! !# *$ *   $)4 )N N2 2C t 84 2  r   r   )__all__rK   r   r,   r   r   typingr	   r]   r   r   r   r   r%   r   r   r   r   <module>rc      se   
 
 
    -C - 
#e eP :!r   