diff options
author | Nikita Slyusarev <nslus@yandex-team.com> | 2022-02-10 16:46:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:52 +0300 |
commit | cd77cecfc03a3eaf87816af28a33067c4f0cdb59 (patch) | |
tree | 1308e0bae862d52e0020d881fe758080437fe389 /contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/utils.py | |
parent | cdae02d225fb5b3afbb28990e79a7ac6c9125327 (diff) | |
download | ydb-cd77cecfc03a3eaf87816af28a33067c4f0cdb59.tar.gz |
Restoring authorship annotation for Nikita Slyusarev <nslus@yandex-team.com>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/utils.py')
-rw-r--r-- | contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/utils.py | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/utils.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/utils.py index 6087e76abe..75982af3ab 100644 --- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/utils.py +++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/utils.py @@ -1,45 +1,45 @@ -from __future__ import unicode_literals -from .base import DEFAULT_ATTRS, Attrs - -__all__ = ( - 'split_token_in_parts', - 'merge_attrs', -) - - -def split_token_in_parts(token): - """ - Take a Token, and turn it in a list of tokens, by splitting - it on ':' (taking that as a separator.) - """ - result = [] - current = [] - for part in token + (':', ): - if part == ':': - if current: - result.append(tuple(current)) - current = [] - else: - current.append(part) - - return result - - -def merge_attrs(list_of_attrs): - """ - Take a list of :class:`.Attrs` instances and merge them into one. - Every `Attr` in the list can override the styling of the previous one. - """ - result = DEFAULT_ATTRS - - for attr in list_of_attrs: - result = Attrs( - color=attr.color or result.color, - bgcolor=attr.bgcolor or result.bgcolor, - bold=attr.bold or result.bold, - underline=attr.underline or result.underline, - italic=attr.italic or result.italic, - blink=attr.blink or result.blink, - reverse=attr.reverse or result.reverse) - - return result +from __future__ import unicode_literals +from .base import DEFAULT_ATTRS, Attrs + +__all__ = ( + 'split_token_in_parts', + 'merge_attrs', +) + + +def split_token_in_parts(token): + """ + Take a Token, and turn it in a list of tokens, by splitting + it on ':' (taking that as a separator.) + """ + result = [] + current = [] + for part in token + (':', ): + if part == ':': + if current: + result.append(tuple(current)) + current = [] + else: + current.append(part) + + return result + + +def merge_attrs(list_of_attrs): + """ + Take a list of :class:`.Attrs` instances and merge them into one. + Every `Attr` in the list can override the styling of the previous one. + """ + result = DEFAULT_ATTRS + + for attr in list_of_attrs: + result = Attrs( + color=attr.color or result.color, + bgcolor=attr.bgcolor or result.bgcolor, + bold=attr.bold or result.bold, + underline=attr.underline or result.underline, + italic=attr.italic or result.italic, + blink=attr.blink or result.blink, + reverse=attr.reverse or result.reverse) + + return result |