Fixed wrap from taking negative values

Now for wrap input it will take only postive integers as an input and
if any negative numbers are give it will give output as "Wrap argument
should be a positive integer".

Change-Id: Ic0310321f282213e254b591b08da9954d9e4968b
This commit is contained in:
bhavani.cr 2017-07-20 16:53:42 +05:30
parent e6fa257f5a
commit e09881a2e0
1 changed files with 3 additions and 0 deletions

View File

@ -202,6 +202,9 @@ def print_dict(dct, dict_property="Property", wrap=0, dict_value='Value'):
v = six.text_type(v)
if wrap > 0:
v = textwrap.fill(six.text_type(v), wrap)
# If value is negative then
elif wrap < 0:
raise ValueError(_("Wrap argument should be a positive integer"))
# if value has a newline, add in multiple rows
# e.g. fault with stacktrace
if v and isinstance(v, six.string_types) and r'\n' in v: