doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
send(packet) Send a pickled byte-string packet to the socket. The format of the sent byte-string is as described in the documentation for makePickle(). This function allows for partial sends, which can happen when the network is busy.
python.library.logging.handlers#logging.handlers.SocketHandler.send
class logging.handlers.SysLogHandler(address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER, socktype=socket.SOCK_DGRAM) Returns a new instance of the SysLogHandler class intended to communicate with a remote Unix machine whose address is given by address in the form of a (host, port) tuple. If address is not spec...
python.library.logging.handlers#logging.handlers.SysLogHandler
close() Closes the socket to the remote host.
python.library.logging.handlers#logging.handlers.SysLogHandler.close
emit(record) The record is formatted, and then sent to the syslog server. If exception information is present, it is not sent to the server. Changed in version 3.2.1: (See: bpo-12168.) In earlier versions, the message sent to the syslog daemons was always terminated with a NUL byte, because early versions of these d...
python.library.logging.handlers#logging.handlers.SysLogHandler.emit
encodePriority(facility, priority) Encodes the facility and priority into an integer. You can pass in strings or integers - if strings are passed, internal mapping dictionaries are used to convert them to integers. The symbolic LOG_ values are defined in SysLogHandler and mirror the values defined in the sys/syslog.h...
python.library.logging.handlers#logging.handlers.SysLogHandler.encodePriority
mapPriority(levelname) Maps a logging level name to a syslog priority name. You may need to override this if you are using custom levels, or if the default algorithm is not suitable for your needs. The default algorithm maps DEBUG, INFO, WARNING, ERROR and CRITICAL to the equivalent syslog names, and all other level ...
python.library.logging.handlers#logging.handlers.SysLogHandler.mapPriority
class logging.handlers.TimedRotatingFileHandler(filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False, atTime=None, errors=None) Returns a new instance of the TimedRotatingFileHandler class. The specified file is opened and used as the stream for logging. On rotating it also sets the fi...
python.library.logging.handlers#logging.handlers.TimedRotatingFileHandler
doRollover() Does a rollover, as described above.
python.library.logging.handlers#logging.handlers.TimedRotatingFileHandler.doRollover
emit(record) Outputs the record to the file, catering for rollover as described above.
python.library.logging.handlers#logging.handlers.TimedRotatingFileHandler.emit
class logging.handlers.WatchedFileHandler(filename, mode='a', encoding=None, delay=False, errors=None) Returns a new instance of the WatchedFileHandler class. The specified file is opened and used as the stream for logging. If mode is not specified, 'a' is used. If encoding is not None, it is used to open the file wi...
python.library.logging.handlers#logging.handlers.WatchedFileHandler
emit(record) Outputs the record to the file, but first calls reopenIfNeeded() to reopen the file if it has changed.
python.library.logging.handlers#logging.handlers.WatchedFileHandler.emit
reopenIfNeeded() Checks to see if the file has changed. If it has, the existing stream is flushed and closed and the file opened again, typically as a precursor to outputting the record to the file. New in version 3.6.
python.library.logging.handlers#logging.handlers.WatchedFileHandler.reopenIfNeeded
logging.info(msg, *args, **kwargs) Logs a message with level INFO on the root logger. The arguments are interpreted as for debug().
python.library.logging#logging.info
logging.lastResort A “handler of last resort” is available through this attribute. This is a StreamHandler writing to sys.stderr with a level of WARNING, and is used to handle logging events in the absence of any logging configuration. The end result is to just print the message to sys.stderr. This replaces the earli...
python.library.logging#logging.lastResort
logging.log(level, msg, *args, **kwargs) Logs a message with level level on the root logger. The other arguments are interpreted as for debug(). Note The above module-level convenience functions, which delegate to the root logger, call basicConfig() to ensure that at least one handler is available. Because of this, ...
python.library.logging#logging.log
class logging.Logger propagate If this attribute evaluates to true, events logged to this logger will be passed to the handlers of higher level (ancestor) loggers, in addition to any handlers attached to this logger. Messages are passed directly to the ancestor loggers’ handlers - neither the level nor filters of...
python.library.logging#logging.Logger
addFilter(filter) Adds the specified filter filter to this logger.
python.library.logging#logging.Logger.addFilter
addHandler(hdlr) Adds the specified handler hdlr to this logger.
python.library.logging#logging.Logger.addHandler
critical(msg, *args, **kwargs) Logs a message with level CRITICAL on this logger. The arguments are interpreted as for debug().
python.library.logging#logging.Logger.critical
debug(msg, *args, **kwargs) Logs a message with level DEBUG on this logger. The msg is the message format string, and the args are the arguments which are merged into msg using the string formatting operator. (Note that this means that you can use keywords in the format string, together with a single dictionary argum...
python.library.logging#logging.Logger.debug
error(msg, *args, **kwargs) Logs a message with level ERROR on this logger. The arguments are interpreted as for debug().
python.library.logging#logging.Logger.error
exception(msg, *args, **kwargs) Logs a message with level ERROR on this logger. The arguments are interpreted as for debug(). Exception info is added to the logging message. This method should only be called from an exception handler.
python.library.logging#logging.Logger.exception
filter(record) Apply this logger’s filters to the record and return True if the record is to be processed. The filters are consulted in turn, until one of them returns a false value. If none of them return a false value, the record will be processed (passed to handlers). If one returns a false value, no further proce...
python.library.logging#logging.Logger.filter
findCaller(stack_info=False, stacklevel=1) Finds the caller’s source filename and line number. Returns the filename, line number, function name and stack information as a 4-element tuple. The stack information is returned as None unless stack_info is True. The stacklevel parameter is passed from code calling the debu...
python.library.logging#logging.Logger.findCaller
getChild(suffix) Returns a logger which is a descendant to this logger, as determined by the suffix. Thus, logging.getLogger('abc').getChild('def.ghi') would return the same logger as would be returned by logging.getLogger('abc.def.ghi'). This is a convenience method, useful when the parent logger is named using e.g....
python.library.logging#logging.Logger.getChild
getEffectiveLevel() Indicates the effective level for this logger. If a value other than NOTSET has been set using setLevel(), it is returned. Otherwise, the hierarchy is traversed towards the root until a value other than NOTSET is found, and that value is returned. The value returned is an integer, typically one of...
python.library.logging#logging.Logger.getEffectiveLevel
handle(record) Handles a record by passing it to all handlers associated with this logger and its ancestors (until a false value of propagate is found). This method is used for unpickled records received from a socket, as well as those created locally. Logger-level filtering is applied using filter().
python.library.logging#logging.Logger.handle
hasHandlers() Checks to see if this logger has any handlers configured. This is done by looking for handlers in this logger and its parents in the logger hierarchy. Returns True if a handler was found, else False. The method stops searching up the hierarchy whenever a logger with the ‘propagate’ attribute set to fals...
python.library.logging#logging.Logger.hasHandlers
info(msg, *args, **kwargs) Logs a message with level INFO on this logger. The arguments are interpreted as for debug().
python.library.logging#logging.Logger.info
isEnabledFor(level) Indicates if a message of severity level would be processed by this logger. This method checks first the module-level level set by logging.disable(level) and then the logger’s effective level as determined by getEffectiveLevel().
python.library.logging#logging.Logger.isEnabledFor
log(level, msg, *args, **kwargs) Logs a message with integer level level on this logger. The other arguments are interpreted as for debug().
python.library.logging#logging.Logger.log
makeRecord(name, level, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None) This is a factory method which can be overridden in subclasses to create specialized LogRecord instances.
python.library.logging#logging.Logger.makeRecord
propagate If this attribute evaluates to true, events logged to this logger will be passed to the handlers of higher level (ancestor) loggers, in addition to any handlers attached to this logger. Messages are passed directly to the ancestor loggers’ handlers - neither the level nor filters of the ancestor loggers in ...
python.library.logging#logging.Logger.propagate
removeFilter(filter) Removes the specified filter filter from this logger.
python.library.logging#logging.Logger.removeFilter
removeHandler(hdlr) Removes the specified handler hdlr from this logger.
python.library.logging#logging.Logger.removeHandler
setLevel(level) Sets the threshold for this logger to level. Logging messages which are less severe than level will be ignored; logging messages which have severity level or higher will be emitted by whichever handler or handlers service this logger, unless a handler’s level has been set to a higher severity level th...
python.library.logging#logging.Logger.setLevel
warning(msg, *args, **kwargs) Logs a message with level WARNING on this logger. The arguments are interpreted as for debug(). Note There is an obsolete method warn which is functionally identical to warning. As warn is deprecated, please do not use it - use warning instead.
python.library.logging#logging.Logger.warning
class logging.LoggerAdapter(logger, extra) Returns an instance of LoggerAdapter initialized with an underlying Logger instance and a dict-like object. process(msg, kwargs) Modifies the message and/or keyword arguments passed to a logging call in order to insert contextual information. This implementation takes th...
python.library.logging#logging.LoggerAdapter
process(msg, kwargs) Modifies the message and/or keyword arguments passed to a logging call in order to insert contextual information. This implementation takes the object passed as extra to the constructor and adds it to kwargs using key ‘extra’. The return value is a (msg, kwargs) tuple which has the (possibly modi...
python.library.logging#logging.LoggerAdapter.process
class logging.LogRecord(name, level, pathname, lineno, msg, args, exc_info, func=None, sinfo=None) Contains all the information pertinent to the event being logged. The primary information is passed in msg and args, which are combined using msg % args to create the message field of the record. Parameters name – T...
python.library.logging#logging.LogRecord
getMessage() Returns the message for this LogRecord instance after merging any user-supplied arguments with the message. If the user-supplied message argument to the logging call is not a string, str() is called on it to convert it to a string. This allows use of user-defined classes as messages, whose __str__ method...
python.library.logging#logging.LogRecord.getMessage
logging.makeLogRecord(attrdict) Creates and returns a new LogRecord instance whose attributes are defined by attrdict. This function is useful for taking a pickled LogRecord attribute dictionary, sent over a socket, and reconstituting it as a LogRecord instance at the receiving end.
python.library.logging#logging.makeLogRecord
class logging.NullHandler Returns a new instance of the NullHandler class. emit(record) This method does nothing. handle(record) This method does nothing. createLock() This method returns None for the lock, since there is no underlying I/O to which access needs to be serialized.
python.library.logging.handlers#logging.NullHandler
createLock() This method returns None for the lock, since there is no underlying I/O to which access needs to be serialized.
python.library.logging.handlers#logging.NullHandler.createLock
emit(record) This method does nothing.
python.library.logging.handlers#logging.NullHandler.emit
handle(record) This method does nothing.
python.library.logging.handlers#logging.NullHandler.handle
logging.setLoggerClass(klass) Tells the logging system to use the class klass when instantiating a logger. The class should define __init__() such that only a name argument is required, and the __init__() should call Logger.__init__(). This function is typically called before any loggers are instantiated by applicati...
python.library.logging#logging.setLoggerClass
logging.setLogRecordFactory(factory) Set a callable which is used to create a LogRecord. Parameters factory – The factory callable to be used to instantiate a log record. New in version 3.2: This function has been provided, along with getLogRecordFactory(), to allow developers more control over how the LogRecord...
python.library.logging#logging.setLogRecordFactory
logging.shutdown() Informs the logging system to perform an orderly shutdown by flushing and closing all handlers. This should be called at application exit and no further use of the logging system should be made after this call. When the logging module is imported, it registers this function as an exit handler (see ...
python.library.logging#logging.shutdown
class logging.StreamHandler(stream=None) Returns a new instance of the StreamHandler class. If stream is specified, the instance will use it for logging output; otherwise, sys.stderr will be used. emit(record) If a formatter is specified, it is used to format the record. The record is then written to the stream f...
python.library.logging.handlers#logging.StreamHandler
emit(record) If a formatter is specified, it is used to format the record. The record is then written to the stream followed by terminator. If exception information is present, it is formatted using traceback.print_exception() and appended to the stream.
python.library.logging.handlers#logging.StreamHandler.emit
flush() Flushes the stream by calling its flush() method. Note that the close() method is inherited from Handler and so does no output, so an explicit flush() call may be needed at times.
python.library.logging.handlers#logging.StreamHandler.flush
setStream(stream) Sets the instance’s stream to the specified value, if it is different. The old stream is flushed before the new stream is set. Parameters stream – The stream that the handler should use. Returns the old stream, if the stream was changed, or None if it wasn’t. New in version 3.7.
python.library.logging.handlers#logging.StreamHandler.setStream
terminator String used as the terminator when writing a formatted record to a stream. Default value is '\n'. If you don’t want a newline termination, you can set the handler instance’s terminator attribute to the empty string. In earlier versions, the terminator was hardcoded as '\n'. New in version 3.2.
python.library.logging.handlers#logging.StreamHandler.terminator
logging.warning(msg, *args, **kwargs) Logs a message with level WARNING on the root logger. The arguments are interpreted as for debug(). Note There is an obsolete function warn which is functionally identical to warning. As warn is deprecated, please do not use it - use warning instead.
python.library.logging#logging.warning
exception LookupError The base class for the exceptions that are raised when a key or index used on a mapping or sequence is invalid: IndexError, KeyError. This can be raised directly by codecs.lookup().
python.library.exceptions#LookupError
lzma — Compression using the LZMA algorithm New in version 3.3. Source code: Lib/lzma.py This module provides classes and convenience functions for compressing and decompressing data using the LZMA compression algorithm. Also included is a file interface supporting the .xz and legacy .lzma file formats used by the xz...
python.library.lzma
lzma.compress(data, format=FORMAT_XZ, check=-1, preset=None, filters=None) Compress data (a bytes object), returning the compressed data as a bytes object. See LZMACompressor above for a description of the format, check, preset and filters arguments.
python.library.lzma#lzma.compress
lzma.decompress(data, format=FORMAT_AUTO, memlimit=None, filters=None) Decompress data (a bytes object), returning the uncompressed data as a bytes object. If data is the concatenation of multiple distinct compressed streams, decompress all of these streams, and return the concatenation of the results. See LZMADecomp...
python.library.lzma#lzma.decompress
lzma.is_check_supported(check) Return True if the given integrity check is supported on this system. CHECK_NONE and CHECK_CRC32 are always supported. CHECK_CRC64 and CHECK_SHA256 may be unavailable if you are using a version of liblzma that was compiled with a limited feature set.
python.library.lzma#lzma.is_check_supported
class lzma.LZMACompressor(format=FORMAT_XZ, check=-1, preset=None, filters=None) Create a compressor object, which can be used to compress data incrementally. For a more convenient way of compressing a single chunk of data, see compress(). The format argument specifies what container format should be used. Possible v...
python.library.lzma#lzma.LZMACompressor
compress(data) Compress data (a bytes object), returning a bytes object containing compressed data for at least part of the input. Some of data may be buffered internally, for use in later calls to compress() and flush(). The returned data should be concatenated with the output of any previous calls to compress().
python.library.lzma#lzma.LZMACompressor.compress
flush() Finish the compression process, returning a bytes object containing any data stored in the compressor’s internal buffers. The compressor cannot be used after this method has been called.
python.library.lzma#lzma.LZMACompressor.flush
class lzma.LZMADecompressor(format=FORMAT_AUTO, memlimit=None, filters=None) Create a decompressor object, which can be used to decompress data incrementally. For a more convenient way of decompressing an entire compressed stream at once, see decompress(). The format argument specifies the container format that shoul...
python.library.lzma#lzma.LZMADecompressor
check The ID of the integrity check used by the input stream. This may be CHECK_UNKNOWN until enough of the input has been decoded to determine what integrity check it uses.
python.library.lzma#lzma.LZMADecompressor.check
decompress(data, max_length=-1) Decompress data (a bytes-like object), returning uncompressed data as bytes. Some of data may be buffered internally, for use in later calls to decompress(). The returned data should be concatenated with the output of any previous calls to decompress(). If max_length is nonnegative, re...
python.library.lzma#lzma.LZMADecompressor.decompress
eof True if the end-of-stream marker has been reached.
python.library.lzma#lzma.LZMADecompressor.eof
needs_input False if the decompress() method can provide more decompressed data before requiring new uncompressed input. New in version 3.5.
python.library.lzma#lzma.LZMADecompressor.needs_input
unused_data Data found after the end of the compressed stream. Before the end of the stream is reached, this will be b"".
python.library.lzma#lzma.LZMADecompressor.unused_data
exception lzma.LZMAError This exception is raised when an error occurs during compression or decompression, or while initializing the compressor/decompressor state.
python.library.lzma#lzma.LZMAError
class lzma.LZMAFile(filename=None, mode="r", *, format=None, check=-1, preset=None, filters=None) Open an LZMA-compressed file in binary mode. An LZMAFile can wrap an already-open file object, or operate directly on a named file. The filename argument specifies either the file object to wrap, or the name of the file ...
python.library.lzma#lzma.LZMAFile
peek(size=-1) Return buffered data without advancing the file position. At least one byte of data will be returned, unless EOF has been reached. The exact number of bytes returned is unspecified (the size argument is ignored). Note While calling peek() does not change the file position of the LZMAFile, it may change...
python.library.lzma#lzma.LZMAFile.peek
lzma.open(filename, mode="rb", *, format=None, check=-1, preset=None, filters=None, encoding=None, errors=None, newline=None) Open an LZMA-compressed file in binary or text mode, returning a file object. The filename argument can be either an actual file name (given as a str, bytes or path-like object), in which case...
python.library.lzma#lzma.open
mailbox — Manipulate mailboxes in various formats Source code: Lib/mailbox.py This module defines two classes, Mailbox and Message, for accessing and manipulating on-disk mailboxes and the messages they contain. Mailbox offers a dictionary-like mapping from keys to messages. Message extends the email.message module’s M...
python.library.mailbox
class mailbox.Babyl(path, factory=None, create=True) A subclass of Mailbox for mailboxes in Babyl format. Parameter factory is a callable object that accepts a file-like message representation (which behaves as if opened in binary mode) and returns a custom representation. If factory is None, BabylMessage is used as ...
python.library.mailbox#mailbox.Babyl
get_file(key) In Babyl mailboxes, the headers of a message are not stored contiguously with the body of the message. To generate a file-like representation, the headers and body are copied together into an io.BytesIO instance, which has an API identical to that of a file. As a result, the file-like object is truly in...
python.library.mailbox#mailbox.Babyl.get_file
get_labels() Return a list of the names of all user-defined labels used in the mailbox. Note The actual messages are inspected to determine which labels exist in the mailbox rather than consulting the list of labels in the Babyl options section, but the Babyl section is updated whenever the mailbox is modified.
python.library.mailbox#mailbox.Babyl.get_labels
lock() unlock() Three locking mechanisms are used—dot locking and, if available, the flock() and lockf() system calls.
python.library.mailbox#mailbox.Babyl.lock
lock() unlock() Three locking mechanisms are used—dot locking and, if available, the flock() and lockf() system calls.
python.library.mailbox#mailbox.Babyl.unlock
class mailbox.BabylMessage(message=None) A message with Babyl-specific behaviors. Parameter message has the same meaning as with the Message constructor. Certain message labels, called attributes, are defined by convention to have special meanings. The attributes are as follows: Label Explanation unseen Not rea...
python.library.mailbox#mailbox.BabylMessage
add_label(label) Add label to the list of labels on the message.
python.library.mailbox#mailbox.BabylMessage.add_label
get_labels() Return a list of labels on the message.
python.library.mailbox#mailbox.BabylMessage.get_labels
get_visible() Return an Message instance whose headers are the message’s visible headers and whose body is empty.
python.library.mailbox#mailbox.BabylMessage.get_visible
remove_label(label) Remove label from the list of labels on the message.
python.library.mailbox#mailbox.BabylMessage.remove_label
set_labels(labels) Set the list of labels on the message to labels.
python.library.mailbox#mailbox.BabylMessage.set_labels
set_visible(visible) Set the message’s visible headers to be the same as the headers in message. Parameter visible should be a Message instance, an email.message.Message instance, a string, or a file-like object (which should be open in text mode).
python.library.mailbox#mailbox.BabylMessage.set_visible
update_visible() When a BabylMessage instance’s original headers are modified, the visible headers are not automatically modified to correspond. This method updates the visible headers as follows: each visible header with a corresponding original header is set to the value of the original header, each visible header ...
python.library.mailbox#mailbox.BabylMessage.update_visible
exception mailbox.Error The based class for all other module-specific exceptions.
python.library.mailbox#mailbox.Error
exception mailbox.ExternalClashError Raised when some mailbox-related condition beyond the control of the program causes it to be unable to proceed, such as when failing to acquire a lock that another program already holds a lock, or when a uniquely-generated file name already exists.
python.library.mailbox#mailbox.ExternalClashError
exception mailbox.FormatError Raised when the data in a file cannot be parsed, such as when an MH instance attempts to read a corrupted .mh_sequences file.
python.library.mailbox#mailbox.FormatError
class mailbox.Mailbox A mailbox, which may be inspected and modified. The Mailbox class defines an interface and is not intended to be instantiated. Instead, format-specific subclasses should inherit from Mailbox and your code should instantiate a particular subclass. The Mailbox interface is dictionary-like, with sm...
python.library.mailbox#mailbox.Mailbox
add(message) Add message to the mailbox and return the key that has been assigned to it. Parameter message may be a Message instance, an email.message.Message instance, a string, a byte string, or a file-like object (which should be open in binary mode). If message is an instance of the appropriate format-specific Me...
python.library.mailbox#mailbox.Mailbox.add
clear() Delete all messages from the mailbox.
python.library.mailbox#mailbox.Mailbox.clear
close() Flush the mailbox, unlock it if necessary, and close any open files. For some Mailbox subclasses, this method does nothing.
python.library.mailbox#mailbox.Mailbox.close
remove(key) __delitem__(key) discard(key) Delete the message corresponding to key from the mailbox. If no such message exists, a KeyError exception is raised if the method was called as remove() or __delitem__() but no exception is raised if the method was called as discard(). The behavior of discard() may be pre...
python.library.mailbox#mailbox.Mailbox.discard
flush() Write any pending changes to the filesystem. For some Mailbox subclasses, changes are always written immediately and flush() does nothing, but you should still make a habit of calling this method.
python.library.mailbox#mailbox.Mailbox.flush
get(key, default=None) __getitem__(key) Return a representation of the message corresponding to key. If no such message exists, default is returned if the method was called as get() and a KeyError exception is raised if the method was called as __getitem__(). The message is represented as an instance of the appropr...
python.library.mailbox#mailbox.Mailbox.get
get_bytes(key) Return a byte representation of the message corresponding to key, or raise a KeyError exception if no such message exists. New in version 3.2.
python.library.mailbox#mailbox.Mailbox.get_bytes
get_file(key) Return a file-like representation of the message corresponding to key, or raise a KeyError exception if no such message exists. The file-like object behaves as if open in binary mode. This file should be closed once it is no longer needed. Changed in version 3.2: The file object really is a binary file...
python.library.mailbox#mailbox.Mailbox.get_file
get_message(key) Return a representation of the message corresponding to key as an instance of the appropriate format-specific Message subclass, or raise a KeyError exception if no such message exists.
python.library.mailbox#mailbox.Mailbox.get_message