diff --git a/CHANGES.rst b/CHANGES.rst index 4c633e11d8c..1b4a05c0138 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,12 @@ Change log ========== +v2018.12.12 +----------- +* Support for IUPAC ordering of elements in Composition formulae (@utf) +* Various bug fixes including returning integer miller indices, catching negative values in Composition and fixes to graph analysis (@utf), fix to Composition serialization (@jmmshen), defect analysis (@HanmeiTang), removing sites in surfaces (@yiming-xu), and fix to support the new PROCAR format in VASP (@dkorotin) +* `PMG_MAPI_ENDPOINT` environment variable added to support different endpoints for the Materials Project REST interface (@mkhorton) + v2018.11.30 ----------- * MPRester.query now supports bulk queries for large scale requests. diff --git a/docs/_modules/collections.html b/docs/_modules/collections.html index d5c26661dc9..73ecd277e62 100644 --- a/docs/_modules/collections.html +++ b/docs/_modules/collections.html @@ -4,27 +4,16 @@ + - - collections — pymatgen 2018.11.30 documentation - + collections — pymatgen 2018.12.12 documentation - - + - + @@ -35,8 +24,7 @@ _gaq.push(['_trackPageview']); - - + @@ -808,12 +796,14 @@

Source code for collections

         
@@ -829,14 +819,14 @@

Navigation

  • modules |
  • - +
    @@ -44,7 +44,8 @@

    Navigation

    All modules for which code is available

    -
    @@ -45,7 +45,7 @@

    Navigation

    Source code for logging

    -# Copyright 2001-2017 by Vinay Sajip. All Rights Reserved.
    +# Copyright 2001-2014 by Vinay Sajip. All Rights Reserved.
     #
     # Permission to use, copy, modify, and distribute this software and its
     # documentation for any purpose and without fee is hereby granted,
    @@ -65,14 +65,12 @@ 

    Source code for logging

     Logging package for Python. Based on PEP 282 and comments thereto in
     comp.lang.python.
     
    -Copyright (C) 2001-2017 Vinay Sajip. All Rights Reserved.
    +Copyright (C) 2001-2014 Vinay Sajip. All Rights Reserved.
     
     To use, simply 'import logging' and log away!
     """
     
    -import sys, os, time, io, traceback, warnings, weakref, collections.abc
    -
    -from string import Template
    +import sys, os, time, cStringIO, traceback, warnings, weakref, collections
     
     __all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR',
                'FATAL', 'FileHandler', 'Filter', 'Formatter', 'Handler', 'INFO',
    @@ -80,21 +78,57 @@ 

    Source code for logging

                'StreamHandler', 'WARN', 'WARNING', 'addLevelName', 'basicConfig',
                'captureWarnings', 'critical', 'debug', 'disable', 'error',
                'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass',
    -           'info', 'log', 'makeLogRecord', 'setLoggerClass', 'shutdown',
    -           'warn', 'warning', 'getLogRecordFactory', 'setLogRecordFactory',
    -           'lastResort', 'raiseExceptions']
    +           'info', 'log', 'makeLogRecord', 'setLoggerClass', 'warn', 'warning']
    +
    +try:
    +    import codecs
    +except ImportError:
    +    codecs = None
     
    -import threading
    +try:
    +    import thread
    +    import threading
    +except ImportError:
    +    thread = None
     
     __author__  = "Vinay Sajip <vinay_sajip@red-dove.com>"
     __status__  = "production"
    -# The following module attributes are no longer updated.
    +# Note: the attributes below are no longer maintained.
     __version__ = "0.5.1.2"
     __date__    = "07 February 2010"
     
     #---------------------------------------------------------------------------
     #   Miscellaneous module data
     #---------------------------------------------------------------------------
    +try:
    +    unicode
    +    _unicode = True
    +except NameError:
    +    _unicode = False
    +
    +# next bit filched from 1.5.2's inspect.py
    +def currentframe():
    +    """Return the frame object for the caller's stack frame."""
    +    try:
    +        raise Exception
    +    except:
    +        return sys.exc_info()[2].tb_frame.f_back
    +
    +if hasattr(sys, '_getframe'): currentframe = lambda: sys._getframe(3)
    +# done filching
    +
    +#
    +# _srcfile is used when walking the stack to check when we've got the first
    +# caller stack frame.
    +#
    +_srcfile = os.path.normcase(currentframe.__code__.co_filename)
    +
    +# _srcfile is only used in conjunction with sys._getframe().
    +# To provide compatibility with older versions of Python, set _srcfile
    +# to None if _getframe() is not available; this value will prevent
    +# findCaller() from being called.
    +#if not hasattr(sys, "_getframe"):
    +#    _srcfile = None
     
     #
     #_startTime is used as the base when calculating the relative time of events
    @@ -105,22 +139,22 @@ 

    Source code for logging

     #raiseExceptions is used to see if exceptions during handling should be
     #propagated
     #
    -raiseExceptions = True
    +raiseExceptions = 1
     
     #
     # If you don't want threading information in the log, set this to zero
     #
    -logThreads = True
    +logThreads = 1
     
     #
     # If you don't want multiprocessing information in the log, set this to zero
     #
    -logMultiprocessing = True
    +logMultiprocessing = 1
     
     #
     # If you don't want process information in the log, set this to zero
     #
    -logProcesses = True
    +logProcesses = 1
     
     #---------------------------------------------------------------------------
     #   Level related stuff
    @@ -142,23 +176,20 @@ 

    Source code for logging

     DEBUG = 10
     NOTSET = 0
     
    -_levelToName = {
    -    CRITICAL: 'CRITICAL',
    -    ERROR: 'ERROR',
    -    WARNING: 'WARNING',
    -    INFO: 'INFO',
    -    DEBUG: 'DEBUG',
    -    NOTSET: 'NOTSET',
    -}
    -_nameToLevel = {
    -    'CRITICAL': CRITICAL,
    -    'FATAL': FATAL,
    -    'ERROR': ERROR,
    -    'WARN': WARNING,
    -    'WARNING': WARNING,
    -    'INFO': INFO,
    -    'DEBUG': DEBUG,
    -    'NOTSET': NOTSET,
    +_levelNames = {
    +    CRITICAL : 'CRITICAL',
    +    ERROR : 'ERROR',
    +    WARNING : 'WARNING',
    +    INFO : 'INFO',
    +    DEBUG : 'DEBUG',
    +    NOTSET : 'NOTSET',
    +    'CRITICAL' : CRITICAL,
    +    'ERROR' : ERROR,
    +    'WARN' : WARNING,
    +    'WARNING' : WARNING,
    +    'INFO' : INFO,
    +    'DEBUG' : DEBUG,
    +    'NOTSET' : NOTSET,
     }
     
     def getLevelName(level):
    @@ -175,14 +206,7 @@ 

    Source code for logging

     
         Otherwise, the string "Level %s" % level is returned.
         """
    -    # See Issues #22386, #27937 and #29220 for why it's this way
    -    result = _levelToName.get(level)
    -    if result is not None:
    -        return result
    -    result = _nameToLevel.get(level)
    -    if result is not None:
    -        return result
    -    return "Level %s" % level
    +    return _levelNames.get(level, ("Level %s" % level))
     
     def addLevelName(level, levelName):
         """
    @@ -192,52 +216,18 @@ 

    Source code for logging

         """
         _acquireLock()
         try:    #unlikely to cause an exception, but you never know...
    -        _levelToName[level] = levelName
    -        _nameToLevel[levelName] = level
    +        _levelNames[level] = levelName
    +        _levelNames[levelName] = level
         finally:
             _releaseLock()
     
    -if hasattr(sys, '_getframe'):
    -    currentframe = lambda: sys._getframe(3)
    -else: #pragma: no cover
    -    def currentframe():
    -        """Return the frame object for the caller's stack frame."""
    -        try:
    -            raise Exception
    -        except Exception:
    -            return sys.exc_info()[2].tb_frame.f_back
    -
    -#
    -# _srcfile is used when walking the stack to check when we've got the first
    -# caller stack frame, by skipping frames whose filename is that of this
    -# module's source. It therefore should contain the filename of this module's
    -# source file.
    -#
    -# Ordinarily we would use __file__ for this, but frozen modules don't always
    -# have __file__ set, for some reason (see Issue #21736). Thus, we get the
    -# filename from a handy code object from a function defined in this module.
    -# (There's no particular reason for picking addLevelName.)
    -#
    -
    -_srcfile = os.path.normcase(addLevelName.__code__.co_filename)
    -
    -# _srcfile is only used in conjunction with sys._getframe().
    -# To provide compatibility with older versions of Python, set _srcfile
    -# to None if _getframe() is not available; this value will prevent
    -# findCaller() from being called. You can also do this if you want to avoid
    -# the overhead of fetching caller information, even when _getframe() is
    -# available.
    -#if not hasattr(sys, '_getframe'):
    -#    _srcfile = None
    -
    -
     def _checkLevel(level):
    -    if isinstance(level, int):
    +    if isinstance(level, (int, long)):
             rv = level
         elif str(level) == level:
    -        if level not in _nameToLevel:
    +        if level not in _levelNames:
                 raise ValueError("Unknown level: %r" % level)
    -        rv = _nameToLevel[level]
    +        rv = _levelNames[level]
         else:
             raise TypeError("Level not an integer or a valid string: %r" % level)
         return rv
    @@ -254,7 +244,10 @@ 

    Source code for logging

     #the lock would already have been acquired - so we need an RLock.
     #The same argument applies to Loggers and Manager.loggerDict.
     #
    -_lock = threading.RLock()
    +if thread:
    +    _lock = threading.RLock()
    +else:
    +    _lock = None
     
     def _acquireLock():
         """
    @@ -272,55 +265,6 @@ 

    Source code for logging

         if _lock:
             _lock.release()
     
    -
    -# Prevent a held logging lock from blocking a child from logging.
    -
    -if not hasattr(os, 'register_at_fork'):  # Windows and friends.
    -    def _register_at_fork_acquire_release(instance):
    -        pass  # no-op when os.register_at_fork does not exist.
    -else:  # The os.register_at_fork API exists
    -    os.register_at_fork(before=_acquireLock,
    -                        after_in_child=_releaseLock,
    -                        after_in_parent=_releaseLock)
    -
    -    # A collection of instances with acquire and release methods (logging.Handler)
    -    # to be called before and after fork.  The weakref avoids us keeping discarded
    -    # Handler instances alive forever in case an odd program creates and destroys
    -    # many over its lifetime.
    -    _at_fork_acquire_release_weakset = weakref.WeakSet()
    -
    -
    -    def _register_at_fork_acquire_release(instance):
    -        # We put the instance itself in a single WeakSet as we MUST have only
    -        # one atomic weak ref. used by both before and after atfork calls to
    -        # guarantee matched pairs of acquire and release calls.
    -        _at_fork_acquire_release_weakset.add(instance)
    -
    -
    -    def _at_fork_weak_calls(method_name):
    -        for instance in _at_fork_acquire_release_weakset:
    -            method = getattr(instance, method_name)
    -            try:
    -                method()
    -            except Exception as err:
    -                # Similar to what PyErr_WriteUnraisable does.
    -                print("Ignoring exception from logging atfork", instance,
    -                      method_name, "method:", err, file=sys.stderr)
    -
    -
    -    def _before_at_fork_weak_calls():
    -        _at_fork_weak_calls('acquire')
    -
    -
    -    def _after_at_fork_weak_calls():
    -        _at_fork_weak_calls('release')
    -
    -
    -    os.register_at_fork(before=_before_at_fork_weak_calls,
    -                        after_in_child=_after_at_fork_weak_calls,
    -                        after_in_parent=_after_at_fork_weak_calls)
    -
    -
     #---------------------------------------------------------------------------
     #   The logging record
     #---------------------------------------------------------------------------
    @@ -338,7 +282,7 @@ 

    Source code for logging

         information to be logged.
         """
         def __init__(self, name, level, pathname, lineno,
    -                 msg, args, exc_info, func=None, sinfo=None, **kwargs):
    +                 msg, args, exc_info, func=None):
             """
             Initialize a logging record with interesting information.
             """
    @@ -354,7 +298,7 @@ 

    Source code for logging

             # during formatting, we test to see if the arg is present using
             # 'if self.args:'. If the event being logged is e.g. 'Value is %d'
             # and if the passed arg fails 'if self.args:' then no formatting
    -        # is done. For example, logger.warning('Value is %d', 0) would log
    +        # is done. For example, logger.warn('Value is %d', 0) would log
             # 'Value is %d' instead of 'Value is 0'.
             # For the use case of passing a dictionary, this should not be a
             # problem.
    @@ -362,8 +306,8 @@ 

    Source code for logging

             # to hasattr(args[0], '__getitem__'). However, the docs on string
             # formatting still seem to suggest a mapping object is required.
             # Thus, while not removing the isinstance check, it does now look
    -        # for collections.abc.Mapping rather than, as before, dict.
    -        if (args and len(args) == 1 and isinstance(args[0], collections.abc.Mapping)
    +        # for collections.Mapping rather than, as before, dict.
    +        if (args and len(args) == 1 and isinstance(args[0], collections.Mapping)
                 and args[0]):
                 args = args[0]
             self.args = args
    @@ -378,19 +322,18 @@ 

    Source code for logging

                 self.module = "Unknown module"
             self.exc_info = exc_info
             self.exc_text = None      # used to cache the traceback text
    -        self.stack_info = sinfo
             self.lineno = lineno
             self.funcName = func
             self.created = ct
    -        self.msecs = (ct - int(ct)) * 1000
    +        self.msecs = (ct - long(ct)) * 1000
             self.relativeCreated = (self.created - _startTime) * 1000
    -        if logThreads:
    -            self.thread = threading.get_ident()
    +        if logThreads and thread:
    +            self.thread = thread.get_ident()
                 self.threadName = threading.current_thread().name
    -        else: # pragma: no cover
    +        else:
                 self.thread = None
                 self.threadName = None
    -        if not logMultiprocessing: # pragma: no cover
    +        if not logMultiprocessing:
                 self.processName = None
             else:
                 self.processName = 'MainProcess'
    @@ -402,7 +345,7 @@ 

    Source code for logging

                     # for an example
                     try:
                         self.processName = mp.current_process().name
    -                except Exception: #pragma: no cover
    +                except StandardError:
                         pass
             if logProcesses and hasattr(os, 'getpid'):
                 self.process = os.getpid()
    @@ -413,8 +356,6 @@ 

    Source code for logging

             return '<LogRecord: %s, %s, %s, %s, "%s">'%(self.name, self.levelno,
                 self.pathname, self.lineno, self.msg)
     
    -    __repr__ = __str__
    -
         def getMessage(self):
             """
             Return the message for this LogRecord.
    @@ -422,33 +363,19 @@ 

    Source code for logging

             Return the message for this LogRecord after merging any user-supplied
             arguments with the message.
             """
    -        msg = str(self.msg)
    +        if not _unicode: #if no unicode support...
    +            msg = str(self.msg)
    +        else:
    +            msg = self.msg
    +            if not isinstance(msg, basestring):
    +                try:
    +                    msg = str(self.msg)
    +                except UnicodeError:
    +                    msg = self.msg      #Defer encoding till later
             if self.args:
                 msg = msg % self.args
             return msg
     
    -#
    -#   Determine which class to use when instantiating log records.
    -#
    -_logRecordFactory = LogRecord
    -
    -def setLogRecordFactory(factory):
    -    """
    -    Set the factory to be used when instantiating a log record.
    -
    -    :param factory: A callable which will be called to instantiate
    -    a log record.
    -    """
    -    global _logRecordFactory
    -    _logRecordFactory = factory
    -
    -def getLogRecordFactory():
    -    """
    -    Return the factory to be used when instantiating a log record.
    -    """
    -
    -    return _logRecordFactory
    -
     def makeLogRecord(dict):
         """
         Make a LogRecord whose attributes are defined by the specified dictionary,
    @@ -456,7 +383,7 @@ 

    Source code for logging

         a socket connection (which is sent as a dictionary) into a LogRecord
         instance.
         """
    -    rv = _logRecordFactory(None, None, "", 0, "", (), None, None)
    +    rv = LogRecord(None, None, "", 0, "", (), None, None)
         rv.__dict__.update(dict)
         return rv
     
    @@ -464,54 +391,6 @@ 

    Source code for logging

     #   Formatter classes and functions
     #---------------------------------------------------------------------------
     
    -class PercentStyle(object):
    -
    -    default_format = '%(message)s'
    -    asctime_format = '%(asctime)s'
    -    asctime_search = '%(asctime)'
    -
    -    def __init__(self, fmt):
    -        self._fmt = fmt or self.default_format
    -
    -    def usesTime(self):
    -        return self._fmt.find(self.asctime_search) >= 0
    -
    -    def format(self, record):
    -        return self._fmt % record.__dict__
    -
    -class StrFormatStyle(PercentStyle):
    -    default_format = '{message}'
    -    asctime_format = '{asctime}'
    -    asctime_search = '{asctime'
    -
    -    def format(self, record):
    -        return self._fmt.format(**record.__dict__)
    -
    -
    -class StringTemplateStyle(PercentStyle):
    -    default_format = '${message}'
    -    asctime_format = '${asctime}'
    -    asctime_search = '${asctime}'
    -
    -    def __init__(self, fmt):
    -        self._fmt = fmt or self.default_format
    -        self._tpl = Template(self._fmt)
    -
    -    def usesTime(self):
    -        fmt = self._fmt
    -        return fmt.find('$asctime') >= 0 or fmt.find(self.asctime_format) >= 0
    -
    -    def format(self, record):
    -        return self._tpl.substitute(**record.__dict__)
    -
    -BASIC_FORMAT = "%(levelname)s:%(name)s:%(message)s"
    -
    -_STYLES = {
    -    '%': (PercentStyle, BASIC_FORMAT),
    -    '{': (StrFormatStyle, '{levelname}:{name}:{message}'),
    -    '$': (StringTemplateStyle, '${levelname}:${name}:${message}'),
    -}
    -
     class Formatter(object):
         """
         Formatter instances are used to convert a LogRecord to text.
    @@ -520,8 +399,7 @@ 

    Source code for logging

         responsible for converting a LogRecord to (usually) a string which can
         be interpreted by either a human or an external system. The base Formatter
         allows a formatting string to be specified. If none is supplied, the
    -    the style-dependent default value, "%(message)s", "{message}", or
    -    "${message}", is used.
    +    default value of "%s(message)\\n" is used.
     
         The Formatter can be initialized with a format string which makes use of
         knowledge of the LogRecord attributes - e.g. the default value mentioned
    @@ -557,32 +435,20 @@ 

    Source code for logging

     
         converter = time.localtime
     
    -    def __init__(self, fmt=None, datefmt=None, style='%'):
    +    def __init__(self, fmt=None, datefmt=None):
             """
             Initialize the formatter with specified format strings.
     
             Initialize the formatter either with the specified format string, or a
             default as described above. Allow for specialized date formatting with
    -        the optional datefmt argument. If datefmt is omitted, you get an
    -        ISO8601-like (or RFC 3339-like) format.
    -
    -        Use a style parameter of '%', '{' or '$' to specify that you want to
    -        use one of %-formatting, :meth:`str.format` (``{}``) formatting or
    -        :class:`string.Template` formatting in your format string.
    -
    -        .. versionchanged:: 3.2
    -           Added the ``style`` parameter.
    +        the optional datefmt argument (if omitted, you get the ISO8601 format).
             """
    -        if style not in _STYLES:
    -            raise ValueError('Style must be one of: %s' % ','.join(
    -                             _STYLES.keys()))
    -        self._style = _STYLES[style][0](fmt)
    -        self._fmt = self._style._fmt
    +        if fmt:
    +            self._fmt = fmt
    +        else:
    +            self._fmt = "%(message)s"
             self.datefmt = datefmt
     
    -    default_time_format = '%Y-%m-%d %H:%M:%S'
    -    default_msec_format = '%s,%03d'
    -
         def formatTime(self, record, datefmt=None):
             """
             Return the creation time of the specified LogRecord as formatted text.
    @@ -592,21 +458,21 @@ 

    Source code for logging

             in formatters to provide for any specific requirement, but the
             basic behaviour is as follows: if datefmt (a string) is specified,
             it is used with time.strftime() to format the creation time of the
    -        record. Otherwise, an ISO8601-like (or RFC 3339-like) format is used.
    -        The resulting string is returned. This function uses a user-configurable
    -        function to convert the creation time to a tuple. By default,
    -        time.localtime() is used; to change this for a particular formatter
    -        instance, set the 'converter' attribute to a function with the same
    -        signature as time.localtime() or time.gmtime(). To change it for all
    -        formatters, for example if you want all logging times to be shown in GMT,
    +        record. Otherwise, the ISO8601 format is used. The resulting
    +        string is returned. This function uses a user-configurable function
    +        to convert the creation time to a tuple. By default, time.localtime()
    +        is used; to change this for a particular formatter instance, set the
    +        'converter' attribute to a function with the same signature as
    +        time.localtime() or time.gmtime(). To change it for all formatters,
    +        for example if you want all logging times to be shown in GMT,
             set the 'converter' attribute in the Formatter class.
             """
             ct = self.converter(record.created)
             if datefmt:
                 s = time.strftime(datefmt, ct)
             else:
    -            t = time.strftime(self.default_time_format, ct)
    -            s = self.default_msec_format % (t, record.msecs)
    +            t = time.strftime("%Y-%m-%d %H:%M:%S", ct)
    +            s = "%s,%03d" % (t, record.msecs)
             return s
     
         def formatException(self, ei):
    @@ -616,12 +482,8 @@ 

    Source code for logging

             This default implementation just uses
             traceback.print_exception()
             """
    -        sio = io.StringIO()
    -        tb = ei[2]
    -        # See issues #9427, #1553375. Commented out for now.
    -        #if getattr(self, 'fullstack', False):
    -        #    traceback.print_stack(tb.tb_frame.f_back, file=sio)
    -        traceback.print_exception(ei[0], ei[1], tb, None, sio)
    +        sio = cStringIO.StringIO()
    +        traceback.print_exception(ei[0], ei[1], ei[2], None, sio)
             s = sio.getvalue()
             sio.close()
             if s[-1:] == "\n":
    @@ -632,23 +494,7 @@ 

    Source code for logging

             """
             Check if the format uses the creation time of the record.
             """
    -        return self._style.usesTime()
    -
    -    def formatMessage(self, record):
    -        return self._style.format(record)
    -
    -    def formatStack(self, stack_info):
    -        """
    -        This method is provided as an extension point for specialized
    -        formatting of stack information.
    -
    -        The input data is a string as returned from a call to
    -        :func:`traceback.print_stack`, but with the last trailing newline
    -        removed.
    -
    -        The base implementation just returns the value passed in.
    -        """
    -        return stack_info
    +        return self._fmt.find("%(asctime)") >= 0
     
         def format(self, record):
             """
    @@ -666,7 +512,15 @@ 

    Source code for logging

             record.message = record.getMessage()
             if self.usesTime():
                 record.asctime = self.formatTime(record, self.datefmt)
    -        s = self.formatMessage(record)
    +        try:
    +            s = self._fmt % record.__dict__
    +        except UnicodeDecodeError as e:
    +            # Issue 25664. The logger name may be Unicode. Try again ...
    +            try:
    +                record.name = record.name.decode('utf-8')
    +                s = self._fmt % record.__dict__
    +            except UnicodeDecodeError:
    +                raise e
             if record.exc_info:
                 # Cache the traceback text to avoid converting it multiple times
                 # (it's constant anyway)
    @@ -675,11 +529,17 @@ 

    Source code for logging

             if record.exc_text:
                 if s[-1:] != "\n":
                     s = s + "\n"
    -            s = s + record.exc_text
    -        if record.stack_info:
    -            if s[-1:] != "\n":
    -                s = s + "\n"
    -            s = s + self.formatStack(record.stack_info)
    +            try:
    +                s = s + record.exc_text
    +            except UnicodeError:
    +                # Sometimes filenames have non-ASCII chars, which can lead
    +                # to errors when s is Unicode and record.exc_text is str
    +                # See issue 8924.
    +                # We also use replace for when there are multiple
    +                # encodings, e.g. UTF-8 for the filesystem and latin-1
    +                # for a script. See issue 13232.
    +                s = s + record.exc_text.decode(sys.getfilesystemencoding(),
    +                                               'replace')
             return s
     
     #
    @@ -759,11 +619,11 @@ 

    Source code for logging

             yes. If deemed appropriate, the record may be modified in-place.
             """
             if self.nlen == 0:
    -            return True
    +            return 1
             elif self.name == record.name:
    -            return True
    +            return 1
             elif record.name.find(self.name, 0, self.nlen) != 0:
    -            return False
    +            return 0
             return (record.name[self.nlen] == ".")
     
     class Filterer(object):
    @@ -798,19 +658,11 @@ 

    Source code for logging

             The default is to allow the record to be logged; any filter can veto
             this and the record is then dropped. Returns a zero value if a record
             is to be dropped, else non-zero.
    -
    -        .. versionchanged:: 3.2
    -
    -           Allow filters to be just callables.
             """
    -        rv = True
    +        rv = 1
             for f in self.filters:
    -            if hasattr(f, 'filter'):
    -                result = f.filter(record)
    -            else:
    -                result = f(record) # assume callable - will raise if not
    -            if not result:
    -                rv = False
    +            if not f.filter(record):
    +                rv = 0
                     break
             return rv
     
    @@ -831,12 +683,19 @@ 

    Source code for logging

         # to prevent race conditions and failures during interpreter shutdown.
         acquire, release, handlers = _acquireLock, _releaseLock, _handlerList
         if acquire and release and handlers:
    -        acquire()
             try:
    -            if wr in handlers:
    -                handlers.remove(wr)
    -        finally:
    -            release()
    +            acquire()
    +            try:
    +                if wr in handlers:
    +                    handlers.remove(wr)
    +            finally:
    +                release()
    +        except TypeError:
    +            # https://bugs.python.org/issue21149 - If the RLock object behind
    +            # acquire() and release() has been partially finalized you may see
    +            # an error about NoneType not being callable.  Absolutely nothing
    +            # we can do in this GC during process shutdown situation.  Eat it.
    +            pass
     
     def _addHandlerRef(handler):
         """
    @@ -890,8 +749,10 @@ 

    Source code for logging

             """
             Acquire a thread lock for serializing access to the underlying I/O.
             """
    -        self.lock = threading.RLock()
    -        _register_at_fork_acquire_release(self)
    +        if thread:
    +            self.lock = threading.RLock()
    +        else:
    +            self.lock = None
     
         def acquire(self):
             """
    @@ -909,7 +770,7 @@ 

    Source code for logging

     
         def setLevel(self, level):
             """
    -        Set the logging level of this handler.  level must be an int or a str.
    +        Set the logging level of this handler.
             """
             self.level = _checkLevel(level)
     
    @@ -999,41 +860,16 @@ 

    Source code for logging

             The record which was being processed is passed in to this method.
             """
             if raiseExceptions and sys.stderr:  # see issue 13807
    -            t, v, tb = sys.exc_info()
    +            ei = sys.exc_info()
                 try:
    -                sys.stderr.write('--- Logging error ---\n')
    -                traceback.print_exception(t, v, tb, None, sys.stderr)
    -                sys.stderr.write('Call stack:\n')
    -                # Walk the stack frame up until we're out of logging,
    -                # so as to print the calling context.
    -                frame = tb.tb_frame
    -                while (frame and os.path.dirname(frame.f_code.co_filename) ==
    -                       __path__[0]):
    -                    frame = frame.f_back
    -                if frame:
    -                    traceback.print_stack(frame, file=sys.stderr)
    -                else:
    -                    # couldn't find the right stack frame, for some reason
    -                    sys.stderr.write('Logged from file %s, line %s\n' % (
    -                                     record.filename, record.lineno))
    -                # Issue 18671: output logging message and arguments
    -                try:
    -                    sys.stderr.write('Message: %r\n'
    -                                     'Arguments: %s\n' % (record.msg,
    -                                                          record.args))
    -                except Exception:
    -                    sys.stderr.write('Unable to print the message and arguments'
    -                                     ' - possible formatting error.\nUse the'
    -                                     ' traceback above to help find the error.\n'
    -                                    )
    -            except OSError: #pragma: no cover
    +                traceback.print_exception(ei[0], ei[1], ei[2],
    +                                          None, sys.stderr)
    +                sys.stderr.write('Logged from file %s, line %s\n' % (
    +                                 record.filename, record.lineno))
    +            except IOError:
                     pass    # see issue 5971
                 finally:
    -                del t, v, tb
    -
    -    def __repr__(self):
    -        level = getLevelName(self.level)
    -        return '<%s (%s)>' % (self.__class__.__name__, level)
    +                del ei
     
     class StreamHandler(Handler):
         """
    @@ -1042,8 +878,6 @@ 

    Source code for logging

         sys.stdout or sys.stderr may be used.
         """
     
    -    terminator = '\n'
    -
         def __init__(self, stream=None):
             """
             Initialize the handler.
    @@ -1080,52 +914,46 @@ 

    Source code for logging

             try:
                 msg = self.format(record)
                 stream = self.stream
    -            stream.write(msg)
    -            stream.write(self.terminator)
    +            fs = "%s\n"
    +            if not _unicode: #if no unicode support...
    +                stream.write(fs % msg)
    +            else:
    +                try:
    +                    if (isinstance(msg, unicode) and
    +                        getattr(stream, 'encoding', None)):
    +                        ufs = u'%s\n'
    +                        try:
    +                            stream.write(ufs % msg)
    +                        except UnicodeEncodeError:
    +                            #Printing to terminals sometimes fails. For example,
    +                            #with an encoding of 'cp1251', the above write will
    +                            #work if written to a stream opened or wrapped by
    +                            #the codecs module, but fail when writing to a
    +                            #terminal even when the codepage is set to cp1251.
    +                            #An extra encoding step seems to be needed.
    +                            stream.write((ufs % msg).encode(stream.encoding))
    +                    else:
    +                        stream.write(fs % msg)
    +                except UnicodeError:
    +                    stream.write(fs % msg.encode("UTF-8"))
                 self.flush()
    -        except Exception:
    +        except (KeyboardInterrupt, SystemExit):
    +            raise
    +        except:
                 self.handleError(record)
     
    -    def setStream(self, stream):
    -        """
    -        Sets the StreamHandler's stream to the specified value,
    -        if it is different.
    -
    -        Returns the old stream, if the stream was changed, or None
    -        if it wasn't.
    -        """
    -        if stream is self.stream:
    -            result = None
    -        else:
    -            result = self.stream
    -            self.acquire()
    -            try:
    -                self.flush()
    -                self.stream = stream
    -            finally:
    -                self.release()
    -        return result
    -
    -    def __repr__(self):
    -        level = getLevelName(self.level)
    -        name = getattr(self.stream, 'name', '')
    -        if name:
    -            name += ' '
    -        return '<%s %s(%s)>' % (self.__class__.__name__, name, level)
    -
    -
     class FileHandler(StreamHandler):
         """
         A handler class which writes formatted logging records to disk files.
         """
    -    def __init__(self, filename, mode='a', encoding=None, delay=False):
    +    def __init__(self, filename, mode='a', encoding=None, delay=0):
             """
             Open the specified file and use it as the stream for logging.
             """
    -        # Issue #27493: add support for Path objects to be passed in
    -        filename = os.fspath(filename)
             #keep the absolute path, otherwise derived classes which use this
             #may come a cropper when the current directory changes
    +        if codecs is None:
    +            encoding = None
             self.baseFilename = os.path.abspath(filename)
             self.mode = mode
             self.encoding = encoding
    @@ -1165,7 +993,11 @@ 

    Source code for logging

             Open the current base file with the (original) mode and encoding.
             Return the resulting stream.
             """
    -        return open(self.baseFilename, self.mode, encoding=self.encoding)
    +        if self.encoding is None:
    +            stream = open(self.baseFilename, self.mode)
    +        else:
    +            stream = codecs.open(self.baseFilename, self.mode, self.encoding)
    +        return stream
     
         def emit(self, record):
             """
    @@ -1178,31 +1010,6 @@ 

    Source code for logging

                 self.stream = self._open()
             StreamHandler.emit(self, record)
     
    -    def __repr__(self):
    -        level = getLevelName(self.level)
    -        return '<%s %s (%s)>' % (self.__class__.__name__, self.baseFilename, level)
    -
    -
    -class _StderrHandler(StreamHandler):
    -    """
    -    This class is like a StreamHandler using sys.stderr, but always uses
    -    whatever sys.stderr is currently set to rather than the value of
    -    sys.stderr at handler construction time.
    -    """
    -    def __init__(self, level=NOTSET):
    -        """
    -        Initialize the handler.
    -        """
    -        Handler.__init__(self, level)
    -
    -    @property
    -    def stream(self):
    -        return sys.stderr
    -
    -
    -_defaultLastResort = _StderrHandler(WARNING)
    -lastResort = _defaultLastResort
    -
     #---------------------------------------------------------------------------
     #   Manager classes and functions
     #---------------------------------------------------------------------------
    @@ -1217,18 +1024,22 @@ 

    Source code for logging

             """
             Initialize with the specified logger being a child of this placeholder.
             """
    +        #self.loggers = [alogger]
             self.loggerMap = { alogger : None }
     
         def append(self, alogger):
             """
             Add the specified logger as a child of this placeholder.
             """
    +        #if alogger not in self.loggers:
             if alogger not in self.loggerMap:
    +            #self.loggers.append(alogger)
                 self.loggerMap[alogger] = None
     
     #
     #   Determine which class to use when instantiating loggers.
     #
    +_loggerClass = None
     
     def setLoggerClass(klass):
         """
    @@ -1247,6 +1058,7 @@ 

    Source code for logging

         """
         Return the class to be used when instantiating a logger.
         """
    +
         return _loggerClass
     
     class Manager(object):
    @@ -1260,10 +1072,9 @@ 

    Source code for logging

             """
             self.root = rootnode
             self.disable = 0
    -        self.emittedNoHandlerWarning = False
    +        self.emittedNoHandlerWarning = 0
             self.loggerDict = {}
             self.loggerClass = None
    -        self.logRecordFactory = None
     
         def getLogger(self, name):
             """
    @@ -1277,8 +1088,10 @@ 

    Source code for logging

             placeholder to now point to the logger.
             """
             rv = None
    -        if not isinstance(name, str):
    -            raise TypeError('A logger name must be a string')
    +        if not isinstance(name, basestring):
    +            raise TypeError('A logger name must be string or Unicode')
    +        if isinstance(name, unicode):
    +            name = name.encode('utf-8')
             _acquireLock()
             try:
                 if name in self.loggerDict:
    @@ -1309,13 +1122,6 @@ 

    Source code for logging

                                     + klass.__name__)
             self.loggerClass = klass
     
    -    def setLogRecordFactory(self, factory):
    -        """
    -        Set the factory to be used when instantiating a log record with this
    -        Manager.
    -        """
    -        self.logRecordFactory = factory
    -
         def _fixupParents(self, alogger):
             """
             Ensure that there are either loggers or placeholders all the way
    @@ -1353,19 +1159,6 @@ 

    Source code for logging

                     alogger.parent = c.parent
                     c.parent = alogger
     
    -    def _clear_cache(self):
    -        """
    -        Clear the cache for all loggers in loggerDict
    -        Called when level changes are made
    -        """
    -
    -        _acquireLock()
    -        for logger in self.loggerDict.values():
    -            if isinstance(logger, Logger):
    -                logger._cache.clear()
    -        self.root._cache.clear()
    -        _releaseLock()
    -
     #---------------------------------------------------------------------------
     #   Logger classes and functions
     #---------------------------------------------------------------------------
    @@ -1393,17 +1186,15 @@ 

    Source code for logging

             self.name = name
             self.level = _checkLevel(level)
             self.parent = None
    -        self.propagate = True
    +        self.propagate = 1
             self.handlers = []
    -        self.disabled = False
    -        self._cache = {}
    +        self.disabled = 0
     
         def setLevel(self, level):
             """
    -        Set the logging level of this logger.  level must be an int or a str.
    +        Set the logging level of this logger.
             """
             self.level = _checkLevel(level)
    -        self.manager._clear_cache()
     
         def debug(self, msg, *args, **kwargs):
             """
    @@ -1441,10 +1232,7 @@ 

    Source code for logging

             if self.isEnabledFor(WARNING):
                 self._log(WARNING, msg, args, **kwargs)
     
    -    def warn(self, msg, *args, **kwargs):
    -        warnings.warn("The 'warn' method is deprecated, "
    -            "use 'warning' instead", DeprecationWarning, 2)
    -        self.warning(msg, *args, **kwargs)
    +    warn = warning
     
         def error(self, msg, *args, **kwargs):
             """
    @@ -1458,11 +1246,12 @@ 

    Source code for logging

             if self.isEnabledFor(ERROR):
                 self._log(ERROR, msg, args, **kwargs)
     
    -    def exception(self, msg, *args, exc_info=True, **kwargs):
    +    def exception(self, msg, *args, **kwargs):
             """
             Convenience method for logging an ERROR with exception information.
             """
    -        self.error(msg, *args, exc_info=exc_info, **kwargs)
    +        kwargs['exc_info'] = 1
    +        self.error(msg, *args, **kwargs)
     
         def critical(self, msg, *args, **kwargs):
             """
    @@ -1487,7 +1276,7 @@ 

    Source code for logging

     
             logger.log(level, "We have a %s", "mysterious problem", exc_info=1)
             """
    -        if not isinstance(level, int):
    +        if not isinstance(level, (int, long)):
                 if raiseExceptions:
                     raise TypeError("level must be an integer")
                 else:
    @@ -1495,7 +1284,7 @@ 

    Source code for logging

             if self.isEnabledFor(level):
                 self._log(level, msg, args, **kwargs)
     
    -    def findCaller(self, stack_info=False):
    +    def findCaller(self):
             """
             Find the stack frame of the caller so that we can note the source
             file name, line number and function name.
    @@ -1505,34 +1294,23 @@ 

    Source code for logging

             #IronPython isn't run with -X:Frames.
             if f is not None:
                 f = f.f_back
    -        rv = "(unknown file)", 0, "(unknown function)", None
    +        rv = "(unknown file)", 0, "(unknown function)"
             while hasattr(f, "f_code"):
                 co = f.f_code
                 filename = os.path.normcase(co.co_filename)
                 if filename == _srcfile:
                     f = f.f_back
                     continue
    -            sinfo = None
    -            if stack_info:
    -                sio = io.StringIO()
    -                sio.write('Stack (most recent call last):\n')
    -                traceback.print_stack(f, file=sio)
    -                sinfo = sio.getvalue()
    -                if sinfo[-1] == '\n':
    -                    sinfo = sinfo[:-1]
    -                sio.close()
    -            rv = (co.co_filename, f.f_lineno, co.co_name, sinfo)
    +            rv = (co.co_filename, f.f_lineno, co.co_name)
                 break
             return rv
     
    -    def makeRecord(self, name, level, fn, lno, msg, args, exc_info,
    -                   func=None, extra=None, sinfo=None):
    +    def makeRecord(self, name, level, fn, lno, msg, args, exc_info, func=None, extra=None):
             """
             A factory method which can be overridden in subclasses to create
             specialized LogRecords.
             """
    -        rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
    -                             sinfo)
    +        rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
             if extra is not None:
                 for key in extra:
                     if (key in ["message", "asctime"]) or (key in rv.__dict__):
    @@ -1540,29 +1318,25 @@ 

    Source code for logging

                     rv.__dict__[key] = extra[key]
             return rv
     
    -    def _log(self, level, msg, args, exc_info=None, extra=None, stack_info=False):
    +    def _log(self, level, msg, args, exc_info=None, extra=None):
             """
             Low-level logging routine which creates a LogRecord and then calls
             all the handlers of this logger to handle the record.
             """
    -        sinfo = None
             if _srcfile:
                 #IronPython doesn't track Python frames, so findCaller raises an
                 #exception on some versions of IronPython. We trap it here so that
                 #IronPython can use logging.
                 try:
    -                fn, lno, func, sinfo = self.findCaller(stack_info)
    -            except ValueError: # pragma: no cover
    +                fn, lno, func = self.findCaller()
    +            except ValueError:
                     fn, lno, func = "(unknown file)", 0, "(unknown function)"
    -        else: # pragma: no cover
    +        else:
                 fn, lno, func = "(unknown file)", 0, "(unknown function)"
             if exc_info:
    -            if isinstance(exc_info, BaseException):
    -                exc_info = (type(exc_info), exc_info, exc_info.__traceback__)
    -            elif not isinstance(exc_info, tuple):
    +            if not isinstance(exc_info, tuple):
                     exc_info = sys.exc_info()
    -        record = self.makeRecord(self.name, level, fn, lno, msg, args,
    -                                 exc_info, func, extra, sinfo)
    +        record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
             self.handle(record)
     
         def handle(self, record):
    @@ -1597,28 +1371,6 @@ 

    Source code for logging

             finally:
                 _releaseLock()
     
    -    def hasHandlers(self):
    -        """
    -        See if this logger has any handlers configured.
    -
    -        Loop through all handlers for this logger and its parents in the
    -        logger hierarchy. Return True if a handler was found, else False.
    -        Stop searching up the hierarchy whenever a logger with the "propagate"
    -        attribute set to zero is found - that will be the last logger which
    -        is checked for the existence of handlers.
    -        """
    -        c = self
    -        rv = False
    -        while c:
    -            if c.handlers:
    -                rv = True
    -                break
    -            if not c.propagate:
    -                break
    -            else:
    -                c = c.parent
    -        return rv
    -
         def callHandlers(self, record):
             """
             Pass a record to all relevant handlers.
    @@ -1640,14 +1392,10 @@ 

    Source code for logging

                     c = None    #break out
                 else:
                     c = c.parent
    -        if (found == 0):
    -            if lastResort:
    -                if record.levelno >= lastResort.level:
    -                    lastResort.handle(record)
    -            elif raiseExceptions and not self.manager.emittedNoHandlerWarning:
    -                sys.stderr.write("No handlers could be found for logger"
    -                                 " \"%s\"\n" % self.name)
    -                self.manager.emittedNoHandlerWarning = True
    +        if (found == 0) and raiseExceptions and not self.manager.emittedNoHandlerWarning:
    +            sys.stderr.write("No handlers could be found for logger"
    +                             " \"%s\"\n" % self.name)
    +            self.manager.emittedNoHandlerWarning = 1
     
         def getEffectiveLevel(self):
             """
    @@ -1667,17 +1415,9 @@ 

    Source code for logging

             """
             Is this logger enabled for level 'level'?
             """
    -        try:
    -            return self._cache[level]
    -        except KeyError:
    -            _acquireLock()
    -            if self.manager.disable >= level:
    -                is_enabled = self._cache[level] = False
    -            else:
    -                is_enabled = self._cache[level] = level >= self.getEffectiveLevel()
    -            _releaseLock()
    -
    -            return is_enabled
    +        if self.manager.disable >= level:
    +            return 0
    +        return level >= self.getEffectiveLevel()
     
         def getChild(self, suffix):
             """
    @@ -1698,19 +1438,6 @@ 

    Source code for logging

                 suffix = '.'.join((self.name, suffix))
             return self.manager.getLogger(suffix)
     
    -    def __repr__(self):
    -        level = getLevelName(self.getEffectiveLevel())
    -        return '<%s %s (%s)>' % (self.__class__.__name__, self.name, level)
    -
    -    def __reduce__(self):
    -        # In general, only the root logger will not be accessible via its name.
    -        # However, the root logger's class has its own __reduce__ method.
    -        if getLogger(self.name) is not self:
    -            import pickle
    -            raise pickle.PicklingError('logger cannot be pickled')
    -        return getLogger, (self.name,)
    -
    -
     class RootLogger(Logger):
         """
         A root logger is not that different to any other logger, except that
    @@ -1723,9 +1450,6 @@ 

    Source code for logging

             """
             Logger.__init__(self, "root", level)
     
    -    def __reduce__(self):
    -        return getLogger, ()
    -
     _loggerClass = Logger
     
     class LoggerAdapter(object):
    @@ -1761,113 +1485,69 @@ 

    Source code for logging

             kwargs["extra"] = self.extra
             return msg, kwargs
     
    -    #
    -    # Boilerplate convenience methods
    -    #
         def debug(self, msg, *args, **kwargs):
             """
    -        Delegate a debug call to the underlying logger.
    +        Delegate a debug call to the underlying logger, after adding
    +        contextual information from this adapter instance.
             """
    -        self.log(DEBUG, msg, *args, **kwargs)
    +        msg, kwargs = self.process(msg, kwargs)
    +        self.logger.debug(msg, *args, **kwargs)
     
         def info(self, msg, *args, **kwargs):
             """
    -        Delegate an info call to the underlying logger.
    +        Delegate an info call to the underlying logger, after adding
    +        contextual information from this adapter instance.
             """
    -        self.log(INFO, msg, *args, **kwargs)
    +        msg, kwargs = self.process(msg, kwargs)
    +        self.logger.info(msg, *args, **kwargs)
     
         def warning(self, msg, *args, **kwargs):
             """
    -        Delegate a warning call to the underlying logger.
    +        Delegate a warning call to the underlying logger, after adding
    +        contextual information from this adapter instance.
             """
    -        self.log(WARNING, msg, *args, **kwargs)
    -
    -    def warn(self, msg, *args, **kwargs):
    -        warnings.warn("The 'warn' method is deprecated, "
    -            "use 'warning' instead", DeprecationWarning, 2)
    -        self.warning(msg, *args, **kwargs)
    +        msg, kwargs = self.process(msg, kwargs)
    +        self.logger.warning(msg, *args, **kwargs)
     
         def error(self, msg, *args, **kwargs):
             """
    -        Delegate an error call to the underlying logger.
    +        Delegate an error call to the underlying logger, after adding
    +        contextual information from this adapter instance.
             """
    -        self.log(ERROR, msg, *args, **kwargs)
    +        msg, kwargs = self.process(msg, kwargs)
    +        self.logger.error(msg, *args, **kwargs)
     
    -    def exception(self, msg, *args, exc_info=True, **kwargs):
    +    def exception(self, msg, *args, **kwargs):
             """
    -        Delegate an exception call to the underlying logger.
    +        Delegate an exception call to the underlying logger, after adding
    +        contextual information from this adapter instance.
             """
    -        self.log(ERROR, msg, *args, exc_info=exc_info, **kwargs)
    +        msg, kwargs = self.process(msg, kwargs)
    +        kwargs["exc_info"] = 1
    +        self.logger.error(msg, *args, **kwargs)
     
         def critical(self, msg, *args, **kwargs):
             """
    -        Delegate a critical call to the underlying logger.
    +        Delegate a critical call to the underlying logger, after adding
    +        contextual information from this adapter instance.
             """
    -        self.log(CRITICAL, msg, *args, **kwargs)
    +        msg, kwargs = self.process(msg, kwargs)
    +        self.logger.critical(msg, *args, **kwargs)
     
         def log(self, level, msg, *args, **kwargs):
             """
             Delegate a log call to the underlying logger, after adding
             contextual information from this adapter instance.
             """
    -        if self.isEnabledFor(level):
    -            msg, kwargs = self.process(msg, kwargs)
    -            self.logger.log(level, msg, *args, **kwargs)
    +        msg, kwargs = self.process(msg, kwargs)
    +        self.logger.log(level, msg, *args, **kwargs)
     
         def isEnabledFor(self, level):
             """
    -        Is this logger enabled for level 'level'?
    +        See if the underlying logger is enabled for the specified level.
             """
             return self.logger.isEnabledFor(level)
     
    -    def setLevel(self, level):
    -        """
    -        Set the specified level on the underlying logger.
    -        """
    -        self.logger.setLevel(level)
    -
    -    def getEffectiveLevel(self):
    -        """
    -        Get the effective level for the underlying logger.
    -        """
    -        return self.logger.getEffectiveLevel()
    -
    -    def hasHandlers(self):
    -        """
    -        See if the underlying logger has any handlers.
    -        """
    -        return self.logger.hasHandlers()
    -
    -    def _log(self, level, msg, args, exc_info=None, extra=None, stack_info=False):
    -        """
    -        Low-level log implementation, proxied to allow nested logger adapters.
    -        """
    -        return self.logger._log(
    -            level,
    -            msg,
    -            args,
    -            exc_info=exc_info,
    -            extra=extra,
    -            stack_info=stack_info,
    -        )
    -
    -    @property
    -    def manager(self):
    -        return self.logger.manager
    -
    -    @manager.setter
    -    def manager(self, value):
    -        self.logger.manager = value
    -
    -    @property
    -    def name(self):
    -        return self.logger.name
    -
    -    def __repr__(self):
    -        logger = self.logger
    -        level = getLevelName(logger.getEffectiveLevel())
    -        return '<%s %s (%s)>' % (self.__class__.__name__, logger.name, level)
    -
     root = RootLogger(WARNING)
     Logger.root = root
     Logger.manager = Manager(Logger.root)
    @@ -1876,6 +1556,8 @@ 

    Source code for logging

     # Configuration classes and functions
     #---------------------------------------------------------------------------
     
    +BASIC_FORMAT = "%(levelname)s:%(name)s:%(message)s"
    +
     def basicConfig(**kwargs):
         """
         Do basic configuration for the logging system.
    @@ -1897,75 +1579,37 @@ 

    Source code for logging

                   (if filemode is unspecified, it defaults to 'a').
         format    Use the specified format string for the handler.
         datefmt   Use the specified date/time format.
    -    style     If a format string is specified, use this to specify the
    -              type of format string (possible values '%', '{', '$', for
    -              %-formatting, :meth:`str.format` and :class:`string.Template`
    -              - defaults to '%').
         level     Set the root logger level to the specified level.
         stream    Use the specified stream to initialize the StreamHandler. Note
                   that this argument is incompatible with 'filename' - if both
                   are present, 'stream' is ignored.
    -    handlers  If specified, this should be an iterable of already created
    -              handlers, which will be added to the root handler. Any handler
    -              in the list which does not have a formatter assigned will be
    -              assigned the formatter created in this function.
     
         Note that you could specify a stream created using open(filename, mode)
         rather than passing the filename and mode in. However, it should be
         remembered that StreamHandler does not close its stream (since it may be
         using sys.stdout or sys.stderr), whereas FileHandler closes its stream
         when the handler is closed.
    -
    -    .. versionchanged:: 3.2
    -       Added the ``style`` parameter.
    -
    -    .. versionchanged:: 3.3
    -       Added the ``handlers`` parameter. A ``ValueError`` is now thrown for
    -       incompatible arguments (e.g. ``handlers`` specified together with
    -       ``filename``/``filemode``, or ``filename``/``filemode`` specified
    -       together with ``stream``, or ``handlers`` specified together with
    -       ``stream``.
         """
         # Add thread safety in case someone mistakenly calls
         # basicConfig() from multiple threads
         _acquireLock()
         try:
             if len(root.handlers) == 0:
    -            handlers = kwargs.pop("handlers", None)
    -            if handlers is None:
    -                if "stream" in kwargs and "filename" in kwargs:
    -                    raise ValueError("'stream' and 'filename' should not be "
    -                                     "specified together")
    +            filename = kwargs.get("filename")
    +            if filename:
    +                mode = kwargs.get("filemode", 'a')
    +                hdlr = FileHandler(filename, mode)
                 else:
    -                if "stream" in kwargs or "filename" in kwargs:
    -                    raise ValueError("'stream' or 'filename' should not be "
    -                                     "specified together with 'handlers'")
    -            if handlers is None:
    -                filename = kwargs.pop("filename", None)
    -                mode = kwargs.pop("filemode", 'a')
    -                if filename:
    -                    h = FileHandler(filename, mode)
    -                else:
    -                    stream = kwargs.pop("stream", None)
    -                    h = StreamHandler(stream)
    -                handlers = [h]
    -            dfs = kwargs.pop("datefmt", None)
    -            style = kwargs.pop("style", '%')
    -            if style not in _STYLES:
    -                raise ValueError('Style must be one of: %s' % ','.join(
    -                                 _STYLES.keys()))
    -            fs = kwargs.pop("format", _STYLES[style][1])
    -            fmt = Formatter(fs, dfs, style)
    -            for h in handlers:
    -                if h.formatter is None:
    -                    h.setFormatter(fmt)
    -                root.addHandler(h)
    -            level = kwargs.pop("level", None)
    +                stream = kwargs.get("stream")
    +                hdlr = StreamHandler(stream)
    +            fs = kwargs.get("format", BASIC_FORMAT)
    +            dfs = kwargs.get("datefmt", None)
    +            fmt = Formatter(fs, dfs)
    +            hdlr.setFormatter(fmt)
    +            root.addHandler(hdlr)
    +            level = kwargs.get("level")
                 if level is not None:
                     root.setLevel(level)
    -            if kwargs:
    -                keys = ', '.join(kwargs.keys())
    -                raise ValueError('Unrecognised argument(s): %s' % keys)
         finally:
             _releaseLock()
     
    @@ -1985,11 +1629,18 @@ 

    Source code for logging

         else:
             return root
     
    +#def getRootLogger():
    +#    """
    +#    Return the root logger.
    +#
    +#    Note that getLogger('') now does the same thing, so this function is
    +#    deprecated and may disappear in the future.
    +#    """
    +#    return root
    +
     def critical(msg, *args, **kwargs):
         """
    -    Log a message with severity 'CRITICAL' on the root logger. If the logger
    -    has no handlers, call basicConfig() to add a console handler with a
    -    pre-defined format.
    +    Log a message with severity 'CRITICAL' on the root logger.
         """
         if len(root.handlers) == 0:
             basicConfig()
    @@ -1999,42 +1650,33 @@ 

    Source code for logging

     
     def error(msg, *args, **kwargs):
         """
    -    Log a message with severity 'ERROR' on the root logger. If the logger has
    -    no handlers, call basicConfig() to add a console handler with a pre-defined
    -    format.
    +    Log a message with severity 'ERROR' on the root logger.
         """
         if len(root.handlers) == 0:
             basicConfig()
         root.error(msg, *args, **kwargs)
     
    -def exception(msg, *args, exc_info=True, **kwargs):
    +def exception(msg, *args, **kwargs):
         """
    -    Log a message with severity 'ERROR' on the root logger, with exception
    -    information. If the logger has no handlers, basicConfig() is called to add
    -    a console handler with a pre-defined format.
    +    Log a message with severity 'ERROR' on the root logger,
    +    with exception information.
         """
    -    error(msg, *args, exc_info=exc_info, **kwargs)
    +    kwargs['exc_info'] = 1
    +    error(msg, *args, **kwargs)
     
     def warning(msg, *args, **kwargs):
         """
    -    Log a message with severity 'WARNING' on the root logger. If the logger has
    -    no handlers, call basicConfig() to add a console handler with a pre-defined
    -    format.
    +    Log a message with severity 'WARNING' on the root logger.
         """
         if len(root.handlers) == 0:
             basicConfig()
         root.warning(msg, *args, **kwargs)
     
    -def warn(msg, *args, **kwargs):
    -    warnings.warn("The 'warn' function is deprecated, "
    -        "use 'warning' instead", DeprecationWarning, 2)
    -    warning(msg, *args, **kwargs)
    +warn = warning
     
     def info(msg, *args, **kwargs):
         """
    -    Log a message with severity 'INFO' on the root logger. If the logger has
    -    no handlers, call basicConfig() to add a console handler with a pre-defined
    -    format.
    +    Log a message with severity 'INFO' on the root logger.
         """
         if len(root.handlers) == 0:
             basicConfig()
    @@ -2042,9 +1684,7 @@ 

    Source code for logging

     
     def debug(msg, *args, **kwargs):
         """
    -    Log a message with severity 'DEBUG' on the root logger. If the logger has
    -    no handlers, call basicConfig() to add a console handler with a pre-defined
    -    format.
    +    Log a message with severity 'DEBUG' on the root logger.
         """
         if len(root.handlers) == 0:
             basicConfig()
    @@ -2052,20 +1692,17 @@ 

    Source code for logging

     
     def log(level, msg, *args, **kwargs):
         """
    -    Log 'msg % args' with the integer severity 'level' on the root logger. If
    -    the logger has no handlers, call basicConfig() to add a console handler
    -    with a pre-defined format.
    +    Log 'msg % args' with the integer severity 'level' on the root logger.
         """
         if len(root.handlers) == 0:
             basicConfig()
         root.log(level, msg, *args, **kwargs)
     
    -def disable(level=CRITICAL):
    +def disable(level):
         """
         Disable all logging calls of severity 'level' and below.
         """
         root.manager.disable = level
    -    root.manager._clear_cache()
     
     def shutdown(handlerList=_handlerList):
         """
    @@ -2084,7 +1721,7 @@ 

    Source code for logging

                         h.acquire()
                         h.flush()
                         h.close()
    -                except (OSError, ValueError):
    +                except (IOError, ValueError):
                         # Ignore errors which might be caused
                         # because handlers have been closed but
                         # references to them are still around at
    @@ -2092,7 +1729,7 @@ 

    Source code for logging

                         pass
                     finally:
                         h.release()
    -        except: # ignore everything, as we're shutting down
    +        except:
                 if raiseExceptions:
                     raise
                 #else, swallow
    @@ -2114,10 +1751,10 @@ 

    Source code for logging

         package.
         """
         def handle(self, record):
    -        """Stub."""
    +        pass
     
         def emit(self, record):
    -        """Stub."""
    +        pass
     
         def createLock(self):
             self.lock = None
    @@ -2191,14 +1828,14 @@ 

    Navigation

  • modules |
  • - +
    @@ -305,14 +305,14 @@

    Navigation

  • modules |
  • - +
    @@ -57,7 +57,7 @@

    Source code for pymatgen

     __email__ ="pymatgen@googlegroups.com"
     __maintainer__ = "Shyue Ping Ong"
     __maintainer_email__ ="shyuep@gmail.com"
    -__version__ = "2018.11.30"
    +__version__ = "2018.12.12"
     
     
     SETTINGS_FILE = os.path.join(os.path.expanduser("~"), ".pmgrc.yaml")
    @@ -191,14 +191,14 @@ 

    Navigation

  • modules |
  • - +