MCPcopy Create free account
hub / github.com/StackStorm/st2 / _cast_string

Function _cast_string

st2common/st2common/util/casts.py:66–78  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

64
65
66def _cast_string(x):
67 if x is None:
68 # Preserve None as-is
69 return x
70
71 if not isinstance(x, six.string_types):
72 value_type = type(x).__name__
73 msg = 'Value "%s" must either be a string or None. Got "%s".' % (x, value_type)
74 raise ValueError(msg)
75
76 x = to_unicode(x)
77 x = _cast_none(x)
78 return x
79
80
81def _cast_none(x):

Callers

nothing calls this directly

Calls 2

to_unicodeFunction · 0.90
_cast_noneFunction · 0.85

Tested by

no test coverage detected