We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0430712 commit dde54feCopy full SHA for dde54fe
allofplos/utils.py
@@ -0,0 +1,27 @@
1
+import textwrap
2
+
3
+def dedent(text):
4
+ """Equivalent of textwrap.dedent that ignores unindented first line.
5
+ This means it will still dedent strings like:
6
+ '''foo
7
+ is a bar
8
+ '''
9
+ For use in wrap_paragraphs.
10
11
+ Taken from https://github.com/ipython/ipython_genutils/text.py
12
+ """
13
14
+ if text.startswith('\n'):
15
+ # text starts with blank line, don't ignore the first line
16
+ return textwrap.dedent(text)
17
18
+ # split first line
19
+ splits = text.split('\n',1)
20
+ if len(splits) == 1:
21
+ # only one line
22
23
24
+ first, rest = splits
25
+ # dedent everything but the first line
26
+ rest = textwrap.dedent(rest)
27
+ return '\n'.join([first, rest])
0 commit comments