forked from VimPlug/jedi
Move indent_block to common
This commit is contained in:
@@ -6,7 +6,7 @@ import difflib
|
||||
from parso import split_lines
|
||||
|
||||
from jedi.api.exceptions import RefactoringError
|
||||
from jedi.utils import indent_block
|
||||
from jedi.common.utils import indent_block
|
||||
|
||||
_INLINE_NEEDS_BRACKET = (
|
||||
'xor_expr and_expr shift_expr arith_expr term factor power atom_expr '
|
||||
|
||||
@@ -24,3 +24,13 @@ def monkeypatch(obj, attribute_name, new_value):
|
||||
yield
|
||||
finally:
|
||||
setattr(obj, attribute_name, old_value)
|
||||
|
||||
|
||||
def indent_block(text, indention=' '):
|
||||
"""This function indents a text block with a default of four spaces."""
|
||||
temp = ''
|
||||
while text and text[-1] == '\n':
|
||||
temp += text[-1]
|
||||
text = text[:-1]
|
||||
lines = text.split('\n')
|
||||
return '\n'.join(map(lambda s: indention + s, lines)) + temp
|
||||
|
||||
@@ -23,7 +23,7 @@ from parso import parse, ParserSyntaxError
|
||||
|
||||
from jedi._compatibility import u
|
||||
from jedi import debug
|
||||
from jedi.utils import indent_block
|
||||
from jedi.common.utils import indent_block
|
||||
from jedi.inference.cache import inference_state_method_cache
|
||||
from jedi.inference.base_value import iterator_to_value_set, ValueSet, \
|
||||
NO_VALUES
|
||||
|
||||
@@ -132,13 +132,3 @@ def version_info():
|
||||
from jedi import __version__
|
||||
tupl = re.findall(r'[a-z]+|\d+', __version__)
|
||||
return Version(*[x if i == 3 else int(x) for i, x in enumerate(tupl)])
|
||||
|
||||
|
||||
def indent_block(text, indention=' '):
|
||||
"""This function indents a text block with a default of four spaces."""
|
||||
temp = ''
|
||||
while text and text[-1] == '\n':
|
||||
temp += text[-1]
|
||||
text = text[:-1]
|
||||
lines = text.split('\n')
|
||||
return '\n'.join(map(lambda s: indention + s, lines)) + temp
|
||||
|
||||
@@ -3,7 +3,7 @@ import os
|
||||
import pytest
|
||||
|
||||
from . import helpers
|
||||
from jedi.utils import indent_block
|
||||
from jedi.common.utils import indent_block
|
||||
from jedi import RefactoringError
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user