# pibootctl.userstr

The `pibootctl.userstr` module provides the `UserStr` class which represents unparsed user input on the command line.

The module also provides a variety of functions for converting input (either from JSON, YAML, or other structured formats, or from unparsed `UserStr`) into common types (`to_bool()`, `to_int()`, `to_str()`, etc).

class `pibootctl.userstr.``UserStr`

  Type used to represent a value expressed as a string on the command line. In other words, any value bearing this type is a string representation of some other type (possibly `str`, `int`, `None`, etc.)

  Primarily used by various conversion routines (`to_bool()`, `to_str()`, etc.) to determine whether a value is a string parsed from some serialization format (like JSON or YAML) which should be treated as a string literal.

  Note

  The blank `UserStr` is special in that it always represents `None` in conversions.

`pibootctl.userstr.``to_bool`(s)

  Converts the `UserStr` (or other type) s to a `bool`. Various “typical” string representations of true and false are accepted including “true”, “yes”, and “on”, along with their counter-parts “false”, “no”, and “off”. Literal `None` passes through unchanged, and a blank `UserStr` will convert to `None`.

`pibootctl.userstr.``to_int`(s)

  Converts the `UserStr` (or other type) s to a `int`. As with all `UserStr` conversions, blank string inputs are converted to `None`, and literal `None` passes through unchanged. Otherwise, decimal integers and hexi-decimal integers prefixed with “0x” are accepted.

`pibootctl.userstr.``to_float`(s)

  Converts the `UserStr` (or other type) s to a `float`. As with all `UserStr` conversions, blank string inputs are converted to `None`, and literal `None` passes through unchanged. Otherwise, typical floating point values (optionally prefixed with sign, optionally suffixed with an exponent) are accepted.

`pibootctl.userstr.``to_str`(s)

  Converts the `UserStr` (or other type) s to a `str`. Blank `UserStr` are converted to `None`, and literal `None` passes through unchanged. Everything else is simply passed to the `str` constructor.

`pibootctl.userstr.``to_list`(s, sep=',')

  Converts the `UserStr` (or other type) s to a `list` based on the separator character sep (which defaults to “,”). Blank `UserStr` are converted to `None`, and literal `None` passes through unchanged. Everything else is passed to the `list` constructor. This ensures that the result is always a unique reference.