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