/usr/lib/python2.7/dist-packages/sphinx_gallery/sphinx_compatibility.py is in python-sphinx-gallery 0.1.13-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | # -*- coding: utf-8 -*-
"""
Backwards-compatility shims for Sphinx
======================================
"""
from __future__ import division, absolute_import, print_function
from distutils.version import LooseVersion
import sphinx
import sphinx.util
# This gets set when the extension is initialized.
_app = None
def _app_get_logger(name):
class SphinxLoggerAdapter:
def _color_to_func(self, kwargs, default=''):
return getattr(sphinx.util.console,
kwargs.pop('color', default),
None)
def error(self, msg, *args, **kwargs):
msg = msg % args
colorfunc = self._color_to_func(kwargs, default='red')
return _app.warn(colorfunc(msg), **kwargs)
def critical(self, msg, *args, **kwargs):
msg = msg % args
colorfunc = self._color_to_func(kwargs, default='red')
return _app.warn(colorfunc(msg), **kwargs)
def warning(self, msg, *args, **kwargs):
msg = msg % args
colorfunc = self._color_to_func(kwargs)
if colorfunc:
# colorfunc is a valid kwarg in 1.5, but not older, so we just
# apply it ourselves.
msg = colorfunc(msg)
return _app.warn(msg, **kwargs)
def info(self, msg='', *args, **kwargs):
msg = msg % args
colorfunc = self._color_to_func(kwargs)
if colorfunc:
msg = colorfunc(msg)
return _app.info(msg, **kwargs)
def verbose(self, msg, *args, **kwargs):
return _app.verbose(msg, *args, **kwargs)
def debug(self, msg, *args, **kwargs):
return _app.debug(msg, *args, **kwargs)
return SphinxLoggerAdapter()
def _app_status_iterator(iterable, summary, **kwargs):
global _app
color = kwargs.pop('color', None)
if color is not None:
kwargs['colorfunc'] = getattr(sphinx.util.console, color)
for item in _app.status_iterator(iterable, summary, **kwargs):
yield item
if LooseVersion(sphinx.__version__) >= '1.6':
getLogger = sphinx.util.logging.getLogger
status_iterator = sphinx.util.status_iterator
else:
getLogger = _app_get_logger
status_iterator = _app_status_iterator
|