U  W[Ýã@s´dZddlmZmZddlZddlZdZdZdZdZ e eddƒZ Gd d „d e ƒZ zeZWnek rpe ZYnXe d ¡Ze d ¡Zd d„Zdd„ZGdd„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@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.pyrsrz(\\*)"z(\\+)\ZcCsDd|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 (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 arglist: 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Ú Csz"quoteArguments..)Újoin)Z argumentsr r rÚquoteArguments9s rc@s0eZdZdZdd„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}). cCs||_||_||_dS)N)ÚwinErrorÚ formatMessageÚerrorTab)ÚselfÚWinErrorÚ FormatMessager r r rÚ__init__Usz_ErrorFormatter.__init__cCsŠzddlm}Wntk r(d}YnXzddlm}Wntk rRd}YnXzddlm}Wntk r|d}YnX||||ƒ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 )Zctypesr"Ú ImportErrorZwin32apir#Zsocketr )Úclsr"r#r r r rÚfromEnvironmentZs   z_ErrorFormatter.fromEnvironmentcCsV|jdk r| |¡jS|jdk r*| |¡S|jdk rL|j |¡}|dk rL|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Ústrerrorrr ÚgetÚos)r!Z errorcodeÚresultr r rÚ formatErroros      z_ErrorFormatter.formatErrorN)r r r r r$r'Ú classmethodr,r r r rrFs r)r Z __future__rrÚrer*ZERROR_FILE_NOT_FOUNDZERROR_PATH_NOT_FOUNDZERROR_INVALID_NAMEZERROR_DIRECTORYÚgetattrrÚOSErrorrZ WindowsErrorÚ NameErrorÚcompilerrrrÚobjectrr'r,r r r rÚs&      B