diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/python/ipython/py2/IPython | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/ipython/py2/IPython')
7 files changed, 87 insertions, 87 deletions
diff --git a/contrib/python/ipython/py2/IPython/core/completerlib.py b/contrib/python/ipython/py2/IPython/core/completerlib.py index e736ca73d1..d31357d0e1 100644 --- a/contrib/python/ipython/py2/IPython/core/completerlib.py +++ b/contrib/python/ipython/py2/IPython/core/completerlib.py @@ -19,7 +19,7 @@ from __future__ import print_function # Stdlib imports import glob import inspect -import itertools +import itertools import os import re import sys @@ -45,8 +45,8 @@ from IPython.utils.py3compat import string_types # FIXME: this should be pulled in with the right call via the component system from IPython import get_ipython -from __res import importer - +from __res import importer + #----------------------------------------------------------------------------- # Globals and constants #----------------------------------------------------------------------------- @@ -71,51 +71,51 @@ magic_run_re = re.compile(r'.*(\.ipy|\.ipynb|\.py[w]?)$') # Local utilities #----------------------------------------------------------------------------- -arcadia_rootmodules_cache = None -arcadia_modules_cache = None - - -def arcadia_init_cache(): - global arcadia_rootmodules_cache, arcadia_modules_cache - arcadia_rootmodules_cache = set() - arcadia_modules_cache = {} - - all_modules = itertools.chain( - sys.builtin_module_names, - importer.memory - ) - - for name in all_modules: - path = name.split('.') - arcadia_rootmodules_cache.add(path[0]) - - prefix = path[0] - for element in path[1:]: - if element == '__init__': - continue - - arcadia_modules_cache.setdefault(prefix, set()).add(element) - prefix += '.' + element - - arcadia_rootmodules_cache = sorted(arcadia_rootmodules_cache) - arcadia_modules_cache = {k: sorted(v) for k, v in arcadia_modules_cache.items()} - - -def arcadia_module_list(mod): - if arcadia_modules_cache is None: - arcadia_init_cache() - - return arcadia_modules_cache.get(mod, ()) - - -def arcadia_get_root_modules(): - if arcadia_rootmodules_cache is None: - arcadia_init_cache() - - return arcadia_rootmodules_cache - - - +arcadia_rootmodules_cache = None +arcadia_modules_cache = None + + +def arcadia_init_cache(): + global arcadia_rootmodules_cache, arcadia_modules_cache + arcadia_rootmodules_cache = set() + arcadia_modules_cache = {} + + all_modules = itertools.chain( + sys.builtin_module_names, + importer.memory + ) + + for name in all_modules: + path = name.split('.') + arcadia_rootmodules_cache.add(path[0]) + + prefix = path[0] + for element in path[1:]: + if element == '__init__': + continue + + arcadia_modules_cache.setdefault(prefix, set()).add(element) + prefix += '.' + element + + arcadia_rootmodules_cache = sorted(arcadia_rootmodules_cache) + arcadia_modules_cache = {k: sorted(v) for k, v in arcadia_modules_cache.items()} + + +def arcadia_module_list(mod): + if arcadia_modules_cache is None: + arcadia_init_cache() + + return arcadia_modules_cache.get(mod, ()) + + +def arcadia_get_root_modules(): + if arcadia_rootmodules_cache is None: + arcadia_init_cache() + + return arcadia_rootmodules_cache + + + def module_list(path): """ Return the list containing the names of the modules available in the given @@ -196,7 +196,7 @@ def get_root_modules(): rootmodules.extend(modules) if store: ip.db['rootmodules_cache'] = rootmodules_cache - rootmodules = list(set(rootmodules)) + rootmodules = list(set(rootmodules)) return rootmodules @@ -216,8 +216,8 @@ def try_import(mod, only_modules=False): for module in mods[1:]: m = getattr(m, module) - filename = getattr(m, '__file__', '') - m_is_init = '__init__' in (filename or '') or filename == mod + filename = getattr(m, '__file__', '') + m_is_init = '__init__' in (filename or '') or filename == mod completions = [] if (not hasattr(m, '__file__')) or (not only_modules) or m_is_init: @@ -226,10 +226,10 @@ def try_import(mod, only_modules=False): completions.extend(getattr(m, '__all__', [])) if m_is_init: - completions.extend(arcadia_module_list(mod)) + completions.extend(arcadia_module_list(mod)) completions = {c for c in completions if isinstance(c, string_types)} completions.discard('__init__') - return sorted(completions) + return sorted(completions) #----------------------------------------------------------------------------- @@ -278,10 +278,10 @@ def module_completion(line): # 'from xy<tab>' or 'import xy<tab>' if nwords < 3 and (words[0] in {'%aimport', 'import', 'from'}) : if nwords == 1: - return arcadia_get_root_modules() + return arcadia_get_root_modules() mod = words[1].split('.') if len(mod) < 2: - return arcadia_get_root_modules() + return arcadia_get_root_modules() completion_list = try_import('.'.join(mod[:-1]), True) return ['.'.join(mod[:-1] + [el]) for el in completion_list] diff --git a/contrib/python/ipython/py2/IPython/core/oinspect.py b/contrib/python/ipython/py2/IPython/core/oinspect.py index 55a4efe8c0..a64d4e7fc6 100644 --- a/contrib/python/ipython/py2/IPython/core/oinspect.py +++ b/contrib/python/ipython/py2/IPython/core/oinspect.py @@ -45,15 +45,15 @@ from IPython.utils.signatures import signature from IPython.utils.colorable import Colorable from pygments import highlight -try: - # PythonLexer was renamed to Python2Lexer in pygments 2.5 - from pygments.lexers import Python2Lexer -except ImportError: - from pygments.lexers import PythonLexer as Python2Lexer +try: + # PythonLexer was renamed to Python2Lexer in pygments 2.5 + from pygments.lexers import Python2Lexer +except ImportError: + from pygments.lexers import PythonLexer as Python2Lexer from pygments.formatters import HtmlFormatter def pylight(code): - return highlight(code, Python2Lexer(), HtmlFormatter(noclasses=True)) + return highlight(code, Python2Lexer(), HtmlFormatter(noclasses=True)) # builtin docstrings to ignore _func_call_docstring = types.FunctionType.__call__.__doc__ diff --git a/contrib/python/ipython/py2/IPython/core/release.py b/contrib/python/ipython/py2/IPython/core/release.py index 94dea1073b..03bed9bec3 100644 --- a/contrib/python/ipython/py2/IPython/core/release.py +++ b/contrib/python/ipython/py2/IPython/core/release.py @@ -20,7 +20,7 @@ name = 'ipython' # release. 'dev' as a _version_extra string means this is a development # version _version_major = 5 -_version_minor = 9 +_version_minor = 9 _version_patch = 0 _version_extra = '.dev' # _version_extra = 'rc1' diff --git a/contrib/python/ipython/py2/IPython/lib/lexers.py b/contrib/python/ipython/py2/IPython/lib/lexers.py index 9160ae1245..b8544003ac 100644 --- a/contrib/python/ipython/py2/IPython/lib/lexers.py +++ b/contrib/python/ipython/py2/IPython/lib/lexers.py @@ -34,12 +34,12 @@ This includes: import re # Third party -from pygments.lexers import BashLexer, Python3Lexer -try: - # PythonLexer was renamed to Python2Lexer in pygments 2.5 - from pygments.lexers import Python2Lexer -except ImportError: - from pygments.lexers import PythonLexer as Python2Lexer +from pygments.lexers import BashLexer, Python3Lexer +try: + # PythonLexer was renamed to Python2Lexer in pygments 2.5 + from pygments.lexers import Python2Lexer +except ImportError: + from pygments.lexers import PythonLexer as Python2Lexer from pygments.lexer import ( Lexer, DelegatingLexer, RegexLexer, do_insertions, bygroups, using, ) @@ -92,7 +92,7 @@ def build_ipy_lexer(python3): aliases = ['ipython3'] doc = """IPython3 Lexer""" else: - PyLexer = Python2Lexer + PyLexer = Python2Lexer name = 'IPython' aliases = ['ipython2', 'ipython'] doc = """IPython Lexer""" diff --git a/contrib/python/ipython/py2/IPython/terminal/pt_inputhooks/qt.py b/contrib/python/ipython/py2/IPython/terminal/pt_inputhooks/qt.py index 7395ac39eb..74c8c153cd 100644 --- a/contrib/python/ipython/py2/IPython/terminal/pt_inputhooks/qt.py +++ b/contrib/python/ipython/py2/IPython/terminal/pt_inputhooks/qt.py @@ -1,29 +1,29 @@ import sys -import os +import os from IPython.external.qt_for_kernel import QtCore, QtGui # If we create a QApplication, keep a reference to it so that it doesn't get # garbage collected. _appref = None -_already_warned = False +_already_warned = False def inputhook(context): global _appref app = QtCore.QCoreApplication.instance() if not app: - if sys.platform == 'linux': - if not os.environ.get('DISPLAY') \ - and not os.environ.get('WAYLAND_DISPLAY'): - import warnings - global _already_warned - if not _already_warned: - _already_warned = True - warnings.warn( - 'The DISPLAY or WAYLAND_DISPLAY enviroment variable is ' - 'not set or empty and Qt5 requires this enviroment ' - 'variable. Deactivate Qt5 code.' - ) - return + if sys.platform == 'linux': + if not os.environ.get('DISPLAY') \ + and not os.environ.get('WAYLAND_DISPLAY'): + import warnings + global _already_warned + if not _already_warned: + _already_warned = True + warnings.warn( + 'The DISPLAY or WAYLAND_DISPLAY enviroment variable is ' + 'not set or empty and Qt5 requires this enviroment ' + 'variable. Deactivate Qt5 code.' + ) + return _appref = app = QtGui.QApplication([" "]) event_loop = QtCore.QEventLoop(app) diff --git a/contrib/python/ipython/py2/IPython/testing/ipunittest.py b/contrib/python/ipython/py2/IPython/testing/ipunittest.py index da059816e2..4acc347703 100644 --- a/contrib/python/ipython/py2/IPython/testing/ipunittest.py +++ b/contrib/python/ipython/py2/IPython/testing/ipunittest.py @@ -147,8 +147,8 @@ class Doc2UnitTester(object): def test(self): # Make a new runner per function to be tested runner = DocTestRunner(verbose=d2u.verbose) - for the_test in d2u.finder.find(func, func.__name__): - runner.run(the_test) + for the_test in d2u.finder.find(func, func.__name__): + runner.run(the_test) failed = count_failures(runner) if failed: # Since we only looked at a single function's docstring, diff --git a/contrib/python/ipython/py2/IPython/utils/_sysinfo.py b/contrib/python/ipython/py2/IPython/utils/_sysinfo.py index 21dd2fcceb..78ce81a466 100644 --- a/contrib/python/ipython/py2/IPython/utils/_sysinfo.py +++ b/contrib/python/ipython/py2/IPython/utils/_sysinfo.py @@ -1,2 +1,2 @@ # GENERATED BY setup.py -commit = u"2348ebbe4" +commit = u"2348ebbe4" |