# `cement.utils.misc`

Misc utilities.

`cement.utils.misc.``init_defaults`(*sections)

  Returns a standard dictionary object to use for application defaults. If sections are given, it will create a nested dict for each section name.

  Parameters: | sections – Section keys to create nested dictionaries for.
  Returns: | Dictionary of nested dictionaries (sections)
  Return type: | dict

      from cement.core import foundation
      from cement.utils.misc import init_defaults

      defaults = init_defaults('myapp', 'section2', 'section3')
      defaults['myapp']['debug'] = False
      defaults['section2']['foo'] = 'bar
      defaults['section3']['foo2'] = 'bar2'

      app = foundation.CementApp('myapp', config_defaults=defaults)

`cement.utils.misc.``is_true`(item)

  Given a value, determine if it is one of [True, ‘True’, ‘true’, 1, ‘1’].

  Parameters: | item – The item to convert to a boolean.
  Returns: | True if item is in `[True, 'True', 'true', 1, '1']`, False otherwise.
  Return type: | boolean

`cement.utils.misc.``minimal_logger`(namespace, debug=False)

  Setup just enough for cement to be able to do debug logging. This is the logger used by the Cement framework, which is setup and accessed before the application is functional (and more importantly before the applications log handler is usable).

  Parameters:

  - namespace – The logging namespace. This is generally ‘__name__’ or anything you want.
  - debug (boolean) – Toggle debug output. Default: False

  Returns: | Logger object

      from cement.utils.misc import minimal_logger
      LOG = minimal_logger('cement')
      LOG.debug('This is a debug message')

`cement.utils.misc.``rando`(salt=None)

  Generate a random MD5 hash for whatever purpose. Useful for testing or any other time that something random is required.

  Parameters: | salt – Optional ‘salt’, if None then random() is used.
  Returns: | Random MD5 hash (str).

`cement.utils.misc.``random`() → x in the interval [0, 1).

`cement.utils.misc.``wrap`(text, width=77, indent='', long_words=False, hyphens=False)

  Wrap text for cleaner output (this is a simple wrapper around textwrap.TextWrapper in the standard library).

  Parameters:

  - text – The text to wrap
  - width – The max width of a line before breaking
  - indent – String to prefix subsequent lines after breaking
  - long_words – Break on long words
  - hyphens – Break on hyphens

  Returns: | str(text)