o ¯bºã@sòUdZddlZddlZddlmZddlmZdZdZdZ dZ e ed dƒZ Gd d „d e ƒZeed d ddƒddd ƒzeZe ed<Wn eyLeZYnweed d ddƒdddƒe d¡Ze d¡Zdd„Zdd„ZGdd„dƒ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. éN)ÚVersion)ÚdeprecatedModuleAttributeééé{i ÚO_BINARYc@seZdZdZdS)Ú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.pyrsrÚTwistedéz9Catch OSError and check presence of 'winerror' attribute.ztwisted.python.win32Ú WindowsErrorz(\\*)"z(\\+)\ZcCsDd|vsd|vsd|vs|dkrdpd}|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)ÚsÚquoter r rÚ cmdLineQuote>s( ÿþÿrcCsd 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 arguments: an iterable of C{str}, each unquoted. @return: a single string, with the given sequence quoted as necessary. rcSsg|]}t|ƒ‘qSr )r)Ú.0Úar r rÚ \sz"quoteArguments..)Újoin)Ú argumentsr r rÚquoteArgumentsRs r!c@s,eZdZdZdd„Zedd„ƒZdd„ZdS) Ú_ErrorFormattera{ Formatter for Windows error messages. @ivar winError: A callable which takes one integer error number argument and returns a L{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 U{win32api.FormatMessage}). @ivar errorTab: A mapping from integer error numbers to C{str} messages which correspond to those erorrs (like I{socket.errorTab}). cCs||_||_||_dS)N)ÚwinErrorÚ formatMessageÚerrorTab)ÚselfÚWinErrorÚ FormatMessager%r r rÚ__init__ps z_ErrorFormatter.__init__cCs„zddlm}Wn tyd}Ynwzddlm}Wn ty'd}Ynwzddlm}Wn ty;d}Ynw||||ƒ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'N)r()r%)Úctypesr'Ú ImportErrorÚwin32apir(Úsocketr%)Úclsr'r(r%r r rÚfromEnvironmentus  ÿ ÿ ÿ z_ErrorFormatter.fromEnvironmentcCsV|jdur | |¡jS|jdur| |¡S|jdur&|j |¡}|dur&|St |¡S)aÛ Returns the string associated with a Windows error message, such as the ones found in socket.error. Attempts direct lookup against the win32 API via ctypes and then pywin32 if available), then in the error table in the socket module, then finally defaulting to C{os.strerror}. @param errorcode: the Windows error code @type errorcode: C{int} @return: The error message string @rtype: C{str} N)r#Ústrerrorr$r%ÚgetÚos)r&Ú errorcodeÚresultr r rÚ formatError‰s       z_ErrorFormatter.formatErrorN)r r r r r)Ú classmethodr/r5r r r rr"_s   r")r r2ÚreÚ incrementalrÚtwisted.python.deprecaterÚERROR_FILE_NOT_FOUNDÚERROR_PATH_NOT_FOUNDÚERROR_INVALID_NAMEÚERROR_DIRECTORYÚgetattrrÚOSErrorrrÚ__annotations__Ú NameErrorÚcompilerrrr!r"r/r5r r r rÚsD     ü ÿ ü   D