Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/click/_textwrap.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
| author | shellac |
|---|---|
| date | Sat, 02 May 2020 07:14:21 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:26e78fe6e8c4 |
|---|---|
| 1 import textwrap | |
| 2 from contextlib import contextmanager | |
| 3 | |
| 4 | |
| 5 class TextWrapper(textwrap.TextWrapper): | |
| 6 def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width): | |
| 7 space_left = max(width - cur_len, 1) | |
| 8 | |
| 9 if self.break_long_words: | |
| 10 last = reversed_chunks[-1] | |
| 11 cut = last[:space_left] | |
| 12 res = last[space_left:] | |
| 13 cur_line.append(cut) | |
| 14 reversed_chunks[-1] = res | |
| 15 elif not cur_line: | |
| 16 cur_line.append(reversed_chunks.pop()) | |
| 17 | |
| 18 @contextmanager | |
| 19 def extra_indent(self, indent): | |
| 20 old_initial_indent = self.initial_indent | |
| 21 old_subsequent_indent = self.subsequent_indent | |
| 22 self.initial_indent += indent | |
| 23 self.subsequent_indent += indent | |
| 24 try: | |
| 25 yield | |
| 26 finally: | |
| 27 self.initial_indent = old_initial_indent | |
| 28 self.subsequent_indent = old_subsequent_indent | |
| 29 | |
| 30 def indent_only(self, text): | |
| 31 rv = [] | |
| 32 for idx, line in enumerate(text.splitlines()): | |
| 33 indent = self.initial_indent | |
| 34 if idx > 0: | |
| 35 indent = self.subsequent_indent | |
| 36 rv.append(indent + line) | |
| 37 return "\n".join(rv) |
