Previous topic

The cinder.openstack.common.setup Module

Next topic

The cinder.openstack.common.timeutils Module

This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Cinder 2011.2 docs or all OpenStack docs too.

The cinder.openstack.common.strutils Module

System-level utilities and helper functions.

bool_from_string(subject)

Interpret a string as a boolean.

Any string value in:

(‘True’, ‘true’, ‘On’, ‘on’, ‘Yes’, ‘yes’, ‘1’)

is interpreted as a boolean True.

Useful for JSON-decoded stuff and config file parsing

int_from_bool_as_string(subject)

Interpret a string as a boolean and return either 1 or 0.

Any string value in:

(‘True’, ‘true’, ‘On’, ‘on’, ‘1’)

is interpreted as a boolean True.

Useful for JSON-decoded stuff and config file parsing

safe_decode(text, incoming=None, errors='strict')

Decodes incoming str using incoming if they’re not already unicode.

Parameters:
Returns:

text or a unicode incoming encoded representation of it.

Raises TypeError:
 

If text is not an isntance of basestring

safe_encode(text, incoming=None, encoding='utf-8', errors='strict')

Encodes incoming str/unicode using encoding. If incoming is not specified, text is expected to be encoded with current python’s default encoding. (sys.getdefaultencoding)

Parameters:
Returns:

text or a bytestring encoding encoded representation of it.

Raises TypeError:
 

If text is not an isntance of basestring