From 4a3f2bd829c2b649f6df60b6a34613e732c355dc Mon Sep 17 00:00:00 2001 From: Phil Adams Date: Fri, 7 Feb 2014 16:48:55 -0500 Subject: [PATCH] stop `shovel tasks` from choking in docstring newlines --- shovel/runner.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shovel/runner.py b/shovel/runner.py index d683789..676ef73 100644 --- a/shovel/runner.py +++ b/shovel/runner.py @@ -21,6 +21,7 @@ from __future__ import print_function +import re import logging from .tasks import Shovel, Task from .parser import parse @@ -82,7 +83,7 @@ def run(*args): print('No tasks found!') else: names = list(t.fullname for t in tasks) - docs = list(t.doc for t in tasks) + docs = list(re.sub(r'\s+', ' ', t.doc) for t in tasks) # The width of the screen width = 80 @@ -94,8 +95,8 @@ def run(*args): # Create the format with padding for the longest name, and to # accomodate the screen width - format = '%%-%is # %%-%is' % ( - max(len(name) for name in names), width) + namemax = max(len(name) for name in names) + format = '%%-%is => %%.%is...' % (namemax, width - namemax - 8) for name, doc in zip(names, docs): print(format % (name, doc)) elif clargs.method: