Skip to content

Commit 01256b4

Browse files
committed
FIX: strip extraneous whitespace in trait desc
1 parent dcce8f8 commit 01256b4

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

nipype/interfaces/base.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import datetime
1414
import errno
1515
import os
16+
import re
1617
from socket import gethostname
1718
from string import Template
1819
import select
@@ -703,27 +704,37 @@ def _get_trait_desc(self, inputs, name, spec):
703704
requires = spec.requires
704705

705706
manhelpstr = ['\t%s' % name]
707+
706708
try:
707709
setattr(inputs, name, None)
708710
except TraitError as excp:
709711
def_val = ''
710712
if getattr(spec, 'usedefault'):
711-
def_val = ', nipype default value: %s' % str(getattr(spec, 'default_value')()[1])
713+
def_arg = getattr(spec, 'default_value')()[1]
714+
def_val = ', nipype default value: %s' % def_arg
712715
line = "(%s%s)" % (excp.info, def_val)
713-
manhelpstr = wrap(line, 90, initial_indent=manhelpstr[0]+': ',
716+
manhelpstr = wrap(line, 70,
717+
initial_indent=manhelpstr[0]+': ',
714718
subsequent_indent='\t\t ')
719+
715720
if desc:
716721
for line in desc.split('\n'):
717-
manhelpstr += wrap(line, 90, initial_indent='\t\t',
722+
line = re.sub("\s+", " ", line)
723+
manhelpstr += wrap(line, 70,
724+
initial_indent='\t\t',
718725
subsequent_indent='\t\t')
726+
719727
if xor:
720728
line = '%s' % ', '.join(xor)
721-
manhelpstr += wrap(line, 90, initial_indent='\t\tmutually_exclusive: ',
729+
manhelpstr += wrap(line, 70,
730+
initial_indent='\t\tmutually_exclusive: ',
722731
subsequent_indent='\t\t ')
723-
if requires: # and name not in xor_done:
732+
733+
if requires:
724734
others = [field for field in requires if field != name]
725735
line = '%s' % ', '.join(others)
726-
manhelpstr += wrap(line, 90, initial_indent='\t\trequires: ',
736+
manhelpstr += wrap(line, 70,
737+
initial_indent='\t\trequires: ',
727738
subsequent_indent='\t\t ')
728739
return manhelpstr
729740

0 commit comments

Comments
 (0)