Remove bespoke indent function. Honestly just use textwrap.
This commit is contained in:
parent
dc64fc3c47
commit
73483838c9
1 changed files with 2 additions and 8 deletions
|
@ -1,18 +1,12 @@
|
||||||
import functools
|
import functools
|
||||||
|
import textwrap
|
||||||
|
|
||||||
HELPSTRINGS = {'', 'help', '-h', '--help'}
|
HELPSTRINGS = {'', 'help', '-h', '--help'}
|
||||||
|
|
||||||
def docstring_preview(text, indent=None):
|
def docstring_preview(text):
|
||||||
text = text.split('\n\n')[0]
|
text = text.split('\n\n')[0]
|
||||||
if indent:
|
|
||||||
text = _indent(text, spaces=indent)
|
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def indent(text, spaces=4):
|
|
||||||
spaces = ' ' * spaces
|
|
||||||
return '\n'.join(spaces + line if line.strip() != '' else line for line in text.split('\n'))
|
|
||||||
_indent = indent
|
|
||||||
|
|
||||||
def listget(li, index, fallback=None):
|
def listget(li, index, fallback=None):
|
||||||
try:
|
try:
|
||||||
return li[index]
|
return li[index]
|
||||||
|
|
Loading…
Reference in a new issue