Show More
@@ -11,7 +11,36 b' here = abspath(dirname(__file__))' | |||||
11 | options = join(here, 'source', 'config', 'options') |
|
11 | options = join(here, 'source', 'config', 'options') | |
12 | generated = join(options, 'config-generated.txt') |
|
12 | generated = join(options, 'config-generated.txt') | |
13 |
|
13 | |||
14 | from ipython_genutils.text import indent, dedent |
|
14 | import textwrap | |
|
15 | indent = lambda text,n: textwrap.indent(text,n*' ') | |||
|
16 | ||||
|
17 | def dedent(text): | |||
|
18 | """Equivalent of textwrap.dedent that ignores unindented first line. | |||
|
19 | ||||
|
20 | This means it will still dedent strings like: | |||
|
21 | '''foo | |||
|
22 | is a bar | |||
|
23 | ''' | |||
|
24 | ||||
|
25 | For use in wrap_paragraphs. | |||
|
26 | """ | |||
|
27 | ||||
|
28 | if text.startswith('\n'): | |||
|
29 | # text starts with blank line, don't ignore the first line | |||
|
30 | return textwrap.dedent(text) | |||
|
31 | ||||
|
32 | # split first line | |||
|
33 | splits = text.split('\n',1) | |||
|
34 | if len(splits) == 1: | |||
|
35 | # only one line | |||
|
36 | return textwrap.dedent(text) | |||
|
37 | ||||
|
38 | first, rest = splits | |||
|
39 | # dedent everything but the first line | |||
|
40 | rest = textwrap.dedent(rest) | |||
|
41 | return '\n'.join([first, rest]) | |||
|
42 | ||||
|
43 | ||||
15 |
|
44 | |||
16 | def interesting_default_value(dv): |
|
45 | def interesting_default_value(dv): | |
17 | if (dv is None) or (dv is Undefined): |
|
46 | if (dv is None) or (dv is Undefined): |
General Comments 0
You need to be logged in to leave comments.
Login now