aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2019-04-18 14:19:24 +0200
committerVratko Polak <vrpolak@cisco.com>2019-04-18 14:20:55 +0000
commit1fa2af771c1c6ead8ffee862cb972795b812e7a1 (patch)
tree6496fdc40731d03fb7f3429854e4802fe0b0ec7a /resources/libraries/python
parent012b57e651e4c3fc010dea49235aafd16b3bef66 (diff)
OptionString: Do not convert None to non-empty string
Change-Id: I2947394a478bde3fe048aef99fd7b5a394764ae2 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/python')
-rw-r--r--resources/libraries/python/OptionString.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/resources/libraries/python/OptionString.py b/resources/libraries/python/OptionString.py
index d6cb40f714..7c8b2d066a 100644
--- a/resources/libraries/python/OptionString.py
+++ b/resources/libraries/python/OptionString.py
@@ -93,8 +93,9 @@ class OptionString(object):
return self
def _check_and_add(self, part, prefixed):
- """Convert to string, strip, add conditionally prefixed if non-empty.
+ """Convert to string, strip, conditionally add prefixed if non-empty.
+ Value of None is converted to empty string.
Emptiness is tested before adding prefix.
:param part: Unchecked part to add to list of parts.
@@ -104,7 +105,7 @@ class OptionString(object):
:returns: The converted part without prefix, empty means not added.
:rtype: str
"""
- part = str(part).strip()
+ part = "" if part is None else str(part).strip()
if part:
prefixed_part = self.prefix + part if prefixed else part
self.parts.append(prefixed_part)