File: //proc/thread-self/root/lib/python3/dist-packages/twisted/python/__pycache__/win32.cpython-38.pyc
U
W[� � @ s� d Z ddlmZmZ ddlZddlZdZdZdZdZ e
edd�ZG d d
� d
e�Z
zeZW n ek
rp e
ZY nX e�d�Ze�d�Zd
d� Zdd� ZG dd� de�Ze�� jZdS )z�
Win32 utilities.
See also twisted.python.shortcut.
@var O_BINARY: the 'binary' mode flag on Windows, or 0 on other platforms, so it
may safely be OR'ed into a mask for os.open.
� )�division�absolute_importN� � �{ i �O_BINARYc @ s e Zd ZdZdS )�FakeWindowsErrorz\
Stand-in for sometimes-builtin exception on platforms for which it
is missing.
N)�__name__�
__module__�__qualname__�__doc__� r
r
�6/usr/lib/python3/dist-packages/twisted/python/win32.pyr s r z(\\*)"z(\\+)\Zc C sD d| ks d| ks d| ks | dkr$dp&d}|t �dt�d| �� | S )aL
Internal method for quoting a single command-line argument.
@param s: an unquoted string that you want to quote so that something that
does cmd.exe-style unquoting will interpret it as a single argument,
even if it contains spaces.
@type s: C{str}
@return: a quoted string.
@rtype: C{str}
� � �"� z\1\1z\1\1\\")�_cmdLineQuoteRe2�sub�_cmdLineQuoteRe)�sZquoter
r
r �cmdLineQuote* s (r c C s d� dd� | D ��S )a^
Quote an iterable of command-line arguments for passing to CreateProcess or
a similar API. This allows the list passed to C{reactor.spawnProcess} to
match the child process's C{sys.argv} properly.
@param arglist: an iterable of C{str}, each unquoted.
@return: a single string, with the given sequence quoted as necessary.
r c S s g | ]}t |��qS r
)r )�.0�ar
r
r �
<listcomp>C s z"quoteArguments.<locals>.<listcomp>)�join)Z argumentsr
r
r �quoteArguments9 s
r c @ s0 e Zd ZdZdd� Zdd� Zee�Zdd� ZdS ) �_ErrorFormattera7
Formatter for Windows error messages.
@ivar winError: A callable which takes one integer error number argument
and returns an L{exceptions.WindowsError} instance for that error (like
L{ctypes.WinError}).
@ivar formatMessage: A callable which takes one integer error number
argument and returns a C{str} giving the message for that error (like
L{win32api.FormatMessage}).
@ivar errorTab: A mapping from integer error numbers to C{str} messages
which correspond to those erorrs (like I{socket.errorTab}).
c C s || _ || _|| _d S )N)�winError�
formatMessage�errorTab)�self�WinError�
FormatMessager r
r
r �__init__U s z_ErrorFormatter.__init__c C s� zddl m} W n tk
r( d}Y nX zddlm} W n tk
rR d}Y nX zddlm} W n tk
r| d}Y nX | |||�S )z�
Get as many of the platform-specific error translation objects as
possible and return an instance of C{cls} created with them.
r )r"