File: _textwrap.py

package info (click to toggle)
python-dynaconf 3.2.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,900 kB
  • sloc: python: 21,464; sh: 9; makefile: 4
file content (19 lines) | stat: -rw-r--r-- 701 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import textwrap
from contextlib import contextmanager
class TextWrapper(textwrap.TextWrapper):
	def _handle_long_word(E,reversed_chunks,cur_line,cur_len,width):
		B=cur_line;A=reversed_chunks;C=max(width-cur_len,1)
		if E.break_long_words:D=A[-1];F=D[:C];G=D[C:];B.append(F);A[-1]=G
		elif not B:B.append(A.pop())
	@contextmanager
	def extra_indent(self,indent):
		B=indent;A=self;C=A.initial_indent;D=A.subsequent_indent;A.initial_indent+=B;A.subsequent_indent+=B
		try:yield
		finally:A.initial_indent=C;A.subsequent_indent=D
	def indent_only(A,text):
		B=[]
		for(D,E)in enumerate(text.splitlines()):
			C=A.initial_indent
			if D>0:C=A.subsequent_indent
			B.append(f"{C}{E}")
		return'\n'.join(B)