aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Pygments/py2/pygments/formatters/__init__.py
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:45:01 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:01 +0300
commit2d37894b1b037cf24231090eda8589bbb44fb6fc (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/python/Pygments/py2/pygments/formatters/__init__.py
parent718c552901d703c502ccbefdfc3c9028d608b947 (diff)
downloadydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/Pygments/py2/pygments/formatters/__init__.py')
-rw-r--r--contrib/python/Pygments/py2/pygments/formatters/__init__.py72
1 files changed, 36 insertions, 36 deletions
diff --git a/contrib/python/Pygments/py2/pygments/formatters/__init__.py b/contrib/python/Pygments/py2/pygments/formatters/__init__.py
index d98b70fc230..6f1130a801e 100644
--- a/contrib/python/Pygments/py2/pygments/formatters/__init__.py
+++ b/contrib/python/Pygments/py2/pygments/formatters/__init__.py
@@ -5,7 +5,7 @@
Pygments formatters.
- :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -20,7 +20,7 @@ from pygments.plugin import find_plugin_formatters
from pygments.util import ClassNotFound, itervalues
__all__ = ['get_formatter_by_name', 'get_formatter_for_filename',
- 'get_all_formatters', 'load_formatter_from_file'] + list(FORMATTERS)
+ 'get_all_formatters', 'load_formatter_from_file'] + list(FORMATTERS)
_formatter_cache = {} # classes by name
_pattern_cache = {}
@@ -79,42 +79,42 @@ def get_formatter_by_name(_alias, **options):
return cls(**options)
-def load_formatter_from_file(filename, formattername="CustomFormatter",
- **options):
- """Load a formatter from a file.
-
- This method expects a file located relative to the current working
- directory, which contains a class named CustomFormatter. By default,
- it expects the Formatter to be named CustomFormatter; you can specify
- your own class name as the second argument to this function.
-
- Users should be very careful with the input, because this method
- is equivalent to running eval on the input file.
-
- Raises ClassNotFound if there are any problems importing the Formatter.
-
- .. versionadded:: 2.2
- """
- try:
- # This empty dict will contain the namespace for the exec'd file
- custom_namespace = {}
- with open(filename, 'rb') as f:
- exec(f.read(), custom_namespace)
- # Retrieve the class `formattername` from that namespace
- if formattername not in custom_namespace:
- raise ClassNotFound('no valid %s class found in %s' %
- (formattername, filename))
- formatter_class = custom_namespace[formattername]
- # And finally instantiate it with the options
- return formatter_class(**options)
- except IOError as err:
+def load_formatter_from_file(filename, formattername="CustomFormatter",
+ **options):
+ """Load a formatter from a file.
+
+ This method expects a file located relative to the current working
+ directory, which contains a class named CustomFormatter. By default,
+ it expects the Formatter to be named CustomFormatter; you can specify
+ your own class name as the second argument to this function.
+
+ Users should be very careful with the input, because this method
+ is equivalent to running eval on the input file.
+
+ Raises ClassNotFound if there are any problems importing the Formatter.
+
+ .. versionadded:: 2.2
+ """
+ try:
+ # This empty dict will contain the namespace for the exec'd file
+ custom_namespace = {}
+ with open(filename, 'rb') as f:
+ exec(f.read(), custom_namespace)
+ # Retrieve the class `formattername` from that namespace
+ if formattername not in custom_namespace:
+ raise ClassNotFound('no valid %s class found in %s' %
+ (formattername, filename))
+ formatter_class = custom_namespace[formattername]
+ # And finally instantiate it with the options
+ return formatter_class(**options)
+ except IOError as err:
raise ClassNotFound('cannot read %s: %s' % (filename, err))
except ClassNotFound:
- raise
- except Exception as err:
- raise ClassNotFound('error when loading custom formatter: %s' % err)
-
-
+ raise
+ except Exception as err:
+ raise ClassNotFound('error when loading custom formatter: %s' % err)
+
+
def get_formatter_for_filename(fn, **options):
"""Lookup and instantiate a formatter by filename pattern.